安装包时候出现这样的问题
RuntimeError:
The detected CUDA version (11.8) mismatches the version that was used to compile
原因分析
安装pytorch时候使用nvidia-smi
查看cuda版本,安装了12.1的torch
解决方案
使用nvcc --version
查看真实cuda版本
cuda版本为11.8。首先卸载torch
pip uninstall torch
参考https://pytorch.org/get-started/previous-versions/
我这里是要安装torch==2.1.2,大家可以按需查找别的版本,
pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu118
重新按照包,发现不报错了。