[已解决]RuntimeError: CUDA error: no kernel image is available for execution on the device

[已解决]RuntimeError: CUDA error: no kernel image is available for execution on the device

问题描述

在ubuntu服务器上用python炼丹的时候遇到的两个问题,一个warning和一个runtimeErro,我的环境是用conda配置的,我就切换了一下环境,然后切回来就报这两个错误,期间啥也没干,之前重新安装opencv疯狂报错也是这种样子的。

  • warning
    warning:NVIDIA GeForce RTX 3090 with CUDA capability sm_86 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 GeForce RTX 3090 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
  • 主要是这个erro:
    RuntimeError: CUDA error: no kernel image is available for execution on the device
    CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
    For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
    问题展示

问题分析

对于第一个warning,他的意思是我的CUDA版本不对,cuda支持的算力和显卡3090不匹配。去网上搜了,确实有类似的问题,但是我的cudatoolkit=11.3,和3090算力是匹配的,所以这个warning是误导我的,这个时候我们需要在系统里面再确认一下机器的cuda版本,在xshell中输入以下命令查看:

nvidia-smi

在这里插入图片描述
可以看到CUDA的版本是没有问题的,因此这个问题可以不管,处理了后面的问题之后自然就好了。

对于这个RuntimeErro,意思是显卡的cuda内核有问题,看上去挺离谱的,但是这个问题我已经是第二次遇到了,之前报opencv错误的时候也是这样,上网查了一下,各种办法都有,我试了一遍,只有重装torch是最有效的。
直接先卸载torch:

pip uninstall torch #需要用pip卸载,conda我这里卸不了

卸载torch
然后,重新安装torch,我用的conda装的,命令如下:

conda install torch

在这里插入图片描述
最后再运行咱们的代码发现又能跑了,这个问题就解决了。

总结

报错的具体内容不用研究,只要是这个描述的,基本就是重装torch来解决。

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2023年3月5日 下午12:47
下一篇 2023年3月5日 下午12:48

相关推荐