Ubuntu离线安装Pytorch和torchvision
Ubuntu离线安装Pytorch和torchvision首先明确torch和torchvision的对应依赖版本torchtorchvisionpythoncuda1.510.61>=3.610.1,10.21.500.6.0>=3.610.1,10.21.4.00,5.0>=3.5,<=3.89.2,10.01.3.10.4.2>=3.5,<=3.79.2,
·
Ubuntu离线安装Pytorch和torchvision
- 首先明确
torch
和torchvision
的对应依赖版本
torch |
torchvision |
python |
cuda |
---|---|---|---|
1.51 | 0.61 | >=3.6 | 10.1,10.2 |
1.50 | 0.6.0 | >=3.6 | 10.1,10.2 |
1.4.0 | 0,5.0 | >=3.5,<=3.8 | 9.2,10.0 |
1.3.1 | 0.4.2 | >=3.5,<=3.7 | 9.2,10.0 |
1.3.0 | 0.4.1 | >=3.5,<=3.7 | 9.2,10.0 |
-
将
pip
改为国内镜像源(当前用户)pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple # 想要全局更改,可以添加--global选项 # pip config --global set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
-
查看cuda和cudnn的版本信息i
# 查看cuda版本 nvcc -V # 或者 cat /usr/local/cuda/version.txt # 查看cudnn的版本 cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
cudnn输出版本信息如下所示:
#define CUDNN_MAJOR 7
#define CUDNN_MINOR 4
#define CUDNN_PATCHLEVEL 2
那么cudnn的版本为:7.4.2
-
下载对应版本的pytorch和torchvision的
.whl
文件 -
打开下载后的指定目录,进行pip本地安装
pip install 待安装包名.whl
-
安装成功后,测试,ok
import torch import torchvision # 查看cuda是否可用 torch.cuda.is_available() # 返回gpu名字,设备索引默认从0开始 torch.cuda.get_device_name(0)
更多推荐
所有评论(0)