利用清华镜像安装torch
时间: 2023-10-22 11:05:53 浏览: 193
可以按照以下步骤在清华镜像上安装torch:
1. 打开清华镜像网站:https://mirrors.tuna.tsinghua.edu.cn/
2. 在搜索框中输入“torch”,并选择相应的版本和操作系统。
3. 复制对应的安装命令到终端中执行。
例如,在Ubuntu 18.04中安装torch 1.8.0,可以执行以下命令:
```
# 添加清华镜像源
sudo apt-get install -y python3-pip
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 安装torch
pip3 install torch==1.8.0+cpu -f https://download.pytorch.org/whl/torch_stable.html --user
```
注意:如果需要GPU支持,需要安装相应的CUDA和cuDNN。
相关问题
利用清华镜像安装torch1.2.0
可以按照以下步骤利用清华镜像安装torch1.2.0:
1. 打开终端,输入以下命令进入root用户:
```
sudo -i
```
2. 输入以下命令添加清华镜像源:
```
export GITHUB=https://github.com.cnpmjs.org
```
3. 输入以下命令下载安装脚本:
```
curl -sL ${GITHUB}/torch/distro/raw/master/install-deps | bash
```
4. 输入以下命令下载安装torch:
```
git clone --recursive ${GITHUB}/torch/distro.git ~/torch --depth=1
cd ~/torch
bash install-deps
./install.sh
```
5. 安装完成后,退出root用户:
```
exit
```
6. 输入以下命令激活torch:
```
source ~/torch/install/bin/torch-activate
```
7. 输入以下命令验证torch是否安装成功:
```
th -e "print('Hello, Torch!')"
```
如果输出了“Hello, Torch!”则表示torch安装成功。
清华镜像安装torch CUDA 版本
您可以按照以下步骤在清华镜像上安装 Torch CUDA 版本:
1. 安装 CUDA
在清华镜像的 CUDA 页面(https://mirrors.tuna.tsinghua.edu.cn/cuda/)中选择您需要的版本,并下载对应的安装包。
然后,按照 CUDA 安装文档(https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html)的说明进行安装。
2. 安装 cuDNN
cuDNN 是 NVIDIA 深度神经网络库的加速库。您可以在清华镜像的 cuDNN 页面(https://mirrors.tuna.tsinghua.edu.cn/cuda/cudnn/)上下载对应版本的压缩包。
下载后,解压缩并将文件复制到 CUDA 安装目录下。例如,如果您的 CUDA 安装在 /usr/local/cuda 目录下,那么您可以将解压缩后的文件复制到 /usr/local/cuda/lib64 和 /usr/local/cuda/include 目录下。
3. 安装 Torch
使用清华镜像上的 pip 工具安装 Torch:
```
pip install torch torchvision -i https://pypi.tuna.tsinghua.edu.cn/simple/
```
这样就可以安装 Torch 的 CUDA 版本了。
阅读全文
相关推荐















