cuda报错,RuntimeError: CUDA error: no kernel image is available for execution on the device
1、用torch.version.cuda查到版本是10.2;或者用nvcc --version
我的cuda版本是11.1
2、然后 Previous PyTorch Versions | PyTorch 匹配torch和cuda
3、直接安装
pip install torch==1.12.0+cu102 torchvision==0.13.0+cu102 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu102
,解决问题
4、如果3的代码下载慢
pip install torch==1.12.0+cu102 torchvision==0.13.0+cu102 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu102 --index-url https://pypi.mirrors.ustc.edu.cn/simple/
加入清华镜像源,下载速度快 --index-url https://pypi.mirrors.ustc.edu.cn/simple/