查看cuda版本
NVIDIA-SMI
官网找到cuda对应的pytorch版本
https://pytorch.org/get-started/previous-versions/
例如我的版本11.7,并且需要pytorch版本在1.x.x
复制下conda安装代码进行安装
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.7 -c pytorch -c nvidia
检查是否安装成功
import torch
print(torch.__version__)
确保能使用cuda
import torch
print(torch.cuda.is_available())
print(torch.version.cuda)