pytorch==1.7.0 conda 和 pip 均无法安装的问题
因为cuda是11.0的,然后根据pytorch官网,需要安装如下配置:
# CUDA 11.0
conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=11.0 -c pytorch
pip install torch==1.7.0 torchvision==0.8.0 torchaudio=0.7.0
但是都无法安装成功,都出现无法下载的问题
ERROR: Could not find a version that satisfies the requirement torchvision==0.8.0+cu110 (from versions: 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.2.0, 0.2.1, 0.2.2, 0.2.2.post2, 0.2.2.post3, 0.3.0, 0.4.0, 0.4.0+cpu, 0.4.0+cu92, 0.4.1, 0.4.1+cpu, 0.4.1+cu100, 0.4.1+cu92, 0.4.2, 0.4.2+cpu, 0.4.2+cu100, 0.4.2+cu92, 0.5.0, 0.5.0+cpu, 0.5.0+cu100, 0.5.0+cu92, 0.6.0, 0.6.0+cpu, 0.6.0+cu101, 0.6.0+cu92, 0.6.1, 0.6.1+cpu, 0.6.1+cu101, 0.6.1+cu92, 0.7.0, 0.7.0+cpu, 0.7.0+cu101, 0.7.0+cu92, 0.8.0) ERROR: No matching distribution found for torchvision==0.8.0+cu110
解决方法:
1.使用轮子下载
# CUDA 11.0
pip install torch==1.7.0+cu110 torchvision==0.8.0+cu110 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
2.如果仍然不行,尝试
pip install -f https://download.pytorch.org/whl/cu110/torch_stable.html torch==1.7.0+cu110 torchvision==0.8.0
参考:
https://github.com/pytorch/vision/issues/2912
https://pytorch.org/get-started/previous-versions/
一定要根据cuda对应版本安装,不然无法使用gpu,默认cpu