1.查看服务器gpu版本
cat /usr/local/cuda/version.txt
2.在pytorch官网查找符合的torch 、torchvision、 torchaudio版本组合
eg.比如这里gpu为cuda92
找到 :
torch==1.7.1+cu92 torchvision==0.8.2+cu92 torchaudio==0.7.2
3.在-f 后的指定地址找到下载链接(这里是python3.8)
curl -C- -O https://download.pytorch.org/whl/cu92/torch-1.7.1%2Bcu92-cp38-cp38-linux_x86_64.whl
curl -O -C- https://download.pytorch.org/whl/cu92/torchvision-0.8.2%2Bcu92-cp38-cp38-linux_x86_64.whl
curl -O -C- https://download.pytorch.org/whl/torchaudio-0.7.2-cp38-cp38-linux_x86_64.whl
4.依次安装
有需要额外安装的库,因此加上镜像源
pip install torch-1.7.1%2Bcu92-cp38-cp38-linux_x86_64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install torchvision-0.8.2%2Bcu92-cp38-cp38-linux_x86_64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install torchaudio-0.7.2-cp38-cp38-linux_x86_64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple/