利用清华镜像安装torch1.2.0
时间: 2024-01-14 15:03:51 浏览: 25
可以按照以下步骤利用清华镜像安装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安装成功。
相关问题
如何用清华镜像安装torch1.2.0
您可以按照以下步骤使用清华镜像安装torch1.2.0:
1. 首先打开终端,并输入以下命令以安装pip:
```
sudo apt-get install python-pip
```
2. 然后使用以下命令安装torch:
```
pip install torch==1.2.0 -f https://pypi.tuna.tsinghua.edu.cn/simple
```
这将从清华镜像下载并安装torch1.2.0。
3. 最后,您可以使用以下代码测试您的torch安装是否成功:
```
import torch
print(torch.__version__)
```
如果输出为1.2.0,则表示您已经成功安装了torch1.2.0。
利用清华镜像安装torch
可以按照以下步骤在清华镜像上安装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。