pip install pytorch cuda

Download:
1.13.1
https://download.pytorch.org/whl/cu116/torch-1.13.1%2Bcu116-cp39-cp39-win_amd64.whl
https://download.pytorch.org/whl/cu116/torchvision-0.14.1%2Bcu116-cp39-cp39-win_amd64.whl
https://download.pytorch.org/whl/cu116/torchaudio-0.13.1%2Bcu116-cp39-cp39-win_amd64.whl

下载安装CUDA 11.6.2
https://developer.nvidia.com/cuda-toolkit-archive
下载cudnn8.9.2:
https://developer.nvidia.com/rdp/cudnn-archive
cudnn-windows-x86_64-8.9.2.26_cuda11-archive.zip
解压到CUDA安装目录,如C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6

pip install xxx.whl

测试
import torch
print(torch.cuda.is_available())
print(torch.__version__)
输出
True
1.13.1+cu116
则成功

修改PyTorch预训练模型的下载路径
import os
os.environ['TORCH_HOME']='D:/pytorch-model/'



旧版1.11.0:
https://download.pytorch.org/whl/cu113/torch-1.11.0%2Bcu113-cp37-cp37m-win_amd64.whl
https://download.pytorch.org/whl/cu113/torchvision-0.12.0%2Bcu113-cp37-cp37m-win_amd64.whl
https://download.pytorch.org/whl/cu113/torchaudio-0.11.0%2Bcu113-cp37-cp37m-win_amd64.whl