当前环境:
CUDA-11.3
torch-1.11.0
torchvision-0.10.0+cpu
报错原因:
在官网下的torchvision是cpu版本:torchvision-0.10.0+cpu,不能调用CUDA
尝试解决:
在官网用conda重新安装
但是安装torchvision仍然是cpu版本。折腾几番,发现是因为torch-1.11.0还没有对应torchvision的gpu版本。
解决方案:
换成CUDA 11.3 对应的更低版本的torch与torchvision
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 -i https://pypi.tuna.tsinghua.edu.cn/simple/
安装后
torch-1.10.2+cu113
torchvision-0.11.3+cu113