1、打开 ”NVIDIA控制面板-系统信息-组件” 查看CUDA版本。
2、查看CUDA版本对应的torch和torchvision版本。
PyTorch碎片:PyToch和Torchvision对应版本_pytorch对应的torchvision版本-CSDN博客
3、安装torch和torchvision:
(1)方法一:使用官网口令直接下载(速度较慢):
例:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
(2)方法二:首先下载好对应的whl文件(cp36 即 python 3.6),然后cmd进入存放该文件的目录进行安装:
https://download.pytorch.org/whl/torch_stable.html
例:
- activate pytorch
- D:
- cd D:\torch
- pip install torch1.5.1+cu92-cp36-cp36m-win_amd64.whl
- pip install torchvision0.6.1+cu92-cp36-cp36m-win_amd64.whl
4、检查是否安装好
例:
- activate pytorch
- python
- import torch
- import torchvision
- print(torch.__version__)
# 例如返回 "1.7.1+cu110" 即正确
- print(torchvision.__version__)
- torch.cuda.is_available()
# 例如返回 "TRUE" 即正确