比如我想在环境里安装cuda版本为11.1,pytorch版本为1.9.1,但是官网只有
官网地址:https://pytorch.org/get-started/previous-versions/
这时候就要使用万能神奇的pip了,命令如下:
pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
但是速度可能会有点慢,甚至直接报错(我就是报错了),建议直接去网站里下载对应的三个版本,网址:https://download.pytorch.org/whl/torch_stable.html
然后再使用如下命令安装即可:
pip install torch-1.9.1+cu111-cp37-cp37m-linux_x86_64.whl torchvision-0.10.1+cu111-cp37-cp37m-linux_x86_64.whl torchaudio-0.9.1-cp37-cp37m-linux_x86_64.whl
然后就ok了,建议自查一下
(***) ***# python
Python 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:21)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> import torchvision
>>> torch.__version__
'1.9.1+cu111'
>>> torchvision.__version__
'0.10.1+cu111'
>>> torch.version.cuda
'11.1'
>>> torch.backends.cudnn.version()
8005
>>> torch.cuda.is_available()
True
>>> exit()