ubuntu服务器CUDA版本为11.2,查询官网发现pytorch没有对应版本,直接安装CUDA11.3版本的torch:
pip3 install torch torchvision torchaudio --extra-index-url /whl/cu113
报错如下:
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/root/anaconda3/envs/mmdetection/lib/python3.7/site-packages/torch/_C.cpython-37m-x86_64-linux-gnu.so'
此报错与pytorch版本和cuda版本不对应无关,是权限不足引发的报错,解决方法为在pip install后面加上--user:
pip3 install --user torch torchvision torchaudio --extra-index-url /whl/cu113
torch安装成功,代码能够成功运行,没有与CUDA版本不兼容的问题!