2022525安装pytorch记录
1 关闭杀毒软件!关闭VPN!
报错:
collecting package metadata (current_repodata.json): failed
collecting package metadata (current_repodata.json): failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/current_repodata.json>
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
'http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64'
不关闭火绒,换源也无济于事!
2 配置清华源
Anaconda prompt 窗口输入:
conda config --set show_channel_urls yes
生成 .condarc 文件
位置在 C:\Users\xxx
.condarc 文件复制
https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/ 中的
修改好 .condarc 文件
3 安装
输入以下内容:
conda create -n PyTorch python=3.8
进入pytorch官网:https://pytorch.org/
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch-lts -c conda-forge
安装pytorch。
4 测试
打开 Anaconda prompt 窗口
激活环境
conda activate PyTorch
输入python,进入python开发环境中
python
import torch
import torchvision
print(torch.__version__) # pytorch版本
print(torch.version.cuda) # cuda版本
print(torch.cuda.is_available()) # 查看cuda是否可用
返回
1.8.2
11.1
True
则PyTorch正常
5 问题
3安装中
报错:
Preparing transaction: done
Verifying transaction: failed
RemoveError: 'requests' is a dependency of conda and cannot be removed from
conda's operating environment.
退出所有虚拟环境再更新
使用下面命令:
conda deactivate
conda update conda
不行使用
conda update --force conda
然后会弹出
是否允许Python.exe
选是
出现done
重新进入环境:
conda cactivate PyTorch
重新安装pytorch
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch-lts -c conda-forge
然后返回4验证
结束