【Pytorch】CUDA error: no kernel image is available for execution on the device

记录一下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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值