解决RuntimeError: CUDA error: no kernel image is available for execution on the deviceCUDA

解决RuntimeError: CUDA error: no kernel image is available for execution on the deviceCUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.

在服务器复现代码的时候,遇到了上述错误,解决办法如下。

问题描述:nvidia-smi 下的GPU编号与Pytorch上的不同

可能原因:nvidia-smi的gpu编号默认使用的是PCI_BUS_ID,而Pytorch默认的是FASTEST_FIRST

解决方法:将 export CUDA_DEVICE_ORDER=”PCI_BUS_ID” 写进用户目录下的.bashrc,然后source ~/.bashrc

.bashrc文件在服务器上初始页面的配置文件的地方

参考:https://discuss.pytorch.org/t/gpu-devices-nvidia-smi-and-cuda-get-device-name-output-appear-inconsistent/13150

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

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

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2023年8月8日
下一篇 2023年8月8日

相关推荐