记录一下pytorch安装的cuda版本和GPU cuda不一致的解决。
RuntimeError: CUDA error: no kernel image is available for execution on the device
一般就是pytorch和cuda安装的不匹配。
如果我安装的torch配的cuda信息如下,
torch.__version__: 1.8.1+cu102
torch.version.cuda: 10.2
torch.backends.cudnn.version(): 7605
# 检测torch、cuda、cudnn版本
print("torch.__version__: ", torch.__version__)
print("torch.version.cuda: ", torch.version.cuda)
print("torch.backends.cudnn.version(): ", torch.backends.cudnn.version())
然后报错,
NVIDIA A100-SXM4-40GB with CUDA capability sm_80 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70.
If you want to use the NVIDIA A100-SXM4-40GB GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
翻译一下,
具有 CUDA 功能 sm_80 的 NVIDIA A100-SXM4-40GB 与当前 PyTorch 安装不兼容。
当前的 PyTorch 安装支持 CUDA 功能 sm_37 sm_50 sm_60 sm_70。
https://blog.csdn.net/weixin_42642296/article/details/115598760
sm_80对应的cuda是11.1,而我安装的cuda是10.2
改一下就好了,根据官网 Previous PyTorch Versions | PyTorch
# CUDA 11.1
pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html