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.
Test on:
import torch
torch.zeros(1).cuda()
GeForce RTX 3080 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_61 sm_70 sm_75 compute_37.
CUDA capability sm_86:算力8.6
上面表面上是说PyTorch,实际上是PyTorch依赖的CUDA版本的问题
翻译一下就是:RTX 3080的算力是8.6,但是当前的PyTorch依赖的CUDA版本支持的算力只有3.7、5.0、6.0、6.1、7.0、7.5及3.7以下
原因:
GPU算力和cuda版本不匹配。
解决:
只有cuda 11.0以上版本支持当前GPU 8.6算力,安装cuda 11.1覆盖cuda 10.2。
Docker镜像经验:
镜像自带的CUDA会有一个驱动版本,这个版本一定要小于宿主机版本。
查看命令为:
ls -l /usr/lib/x86_64-linux-gnu/libcuda.so*
为什么Docker环境会引入forward compatibility 问题?
问题就出在,Gemfield的宿主机上的驱动版本是:
- GPU device driver:450.102.04;
- CUDA driver:libcuda.so.450.102.04。
而Gemfield所使用的下面两个image中的cuda runtime分别是:
- nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04的cuda runtime是libcudart.so.11.2
- nvidia/cuda:11.1.1-cudnn8-devel-ubuntu20.04的cuda runtime是libcudart.so.11.1 PyTorch的CUDA错误:Error 804: forward compatibility was attempted on non supported HW - 知乎
https://zhuanlan.zhihu.com/p/361545761参考链接