检查pytorch安装的版本和cuda是否对应
nvcc -V
输出:
nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2022 NVIDIA Corporation
Built on Tue_May__3_18:49:52_PDT_2022
Cuda compilation tools, release 11.7, V11.7.64
Build cuda_11.7.r11.7/compiler.31294372_0
conda list | grep torch
输出:
ffmpeg 4.3 hf484d3e_0 pytorch
pytorch 1.12.1 py3.9_cuda11.3_cudnn8.3.2_0 pytorch
pytorch-mutex 1.0 cuda pytorch
pytorchvideo 0.1.5
torch 2.2.1
torchaudio 0.12.1 py39_cu113 pytorch
torchvision 0.13.1 py39_cu113 pytorch
去官网查找可以安装的版本:https://pytorch.org/get-started/previous-versions/
pip install torch==1.13.0+cu117 torchvision==0.14.0+cu117 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu117
直接安装即可
在更改了PyTorch版本后,最好重启并清理环境。可以使用以下命令清理conda环境:
conda clean -a