服务器环境
cuda: 11.4
cudnn: 8.5.1
ubuntu: 20.04
安装pytorch1.9
进入官网确定所需版本
找到所需版本
以pytorch1.9.1为例
由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
确定pytorch版本和torchvision版本
找到所需.whl安装包
wheel下载地址
根据上图确定所需pytorch版本为1.9.1+cuda111, torchvision版本为0.10.1+cuda111
下载相应的whl文件:
以pytorch为例,即cu111/torch-1.9.1%2Bcu111-cp37-cp37m-linux_x86_64.whl
cu111: cuda11.1
torch-1.9.1: pytorch1.9.1
cp37: python3.7
linux_x86_64: 适配ubuntu环境
pip 离线安装
进入已下载的whl文件地址,进入所建立的conda环境,运行下面语句:
pip install torch-1.9.1+cu111-cp37-cp37m-linux_x86_64.whl
pip install torchvision-0.10.1+cu111-cp37-cp37m-linux_x86_64.whl
测试是否安装成功
import torch
torch.__version__
torch.cuda.is_available()