RuntimeError: CUDA error: no kernel image is available for execution on the device

I was using GTX3060, CUDA11.2, DRIVER 460.80, UBUNTU18.04, PyTorch 1.9.0+cu102, python3.8(i also tried python3.9, but it gives me the same error message)
When I run the following code, I got the RuntimeError.

device = torch.device(“cuda:0” if torch.cuda.is_available() else “cpu”)
print(‘device’, device)
a = torch.Tensor(5,3)
a = a.cuda()

The code prints" device cuda:0" which means at least the code access to the GPU. However, it also gives me the RuntimeError.

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.

On my computer, I can run TensorFlow with GPU, but It seems like I have some trouble with PyTorch. My CUDA version, driver version seem all right for me. What did I do wrong?

Thank you

PyTorch version incompatible to cuda 11.2?
https://medium.com/analytics-vidhya/install-cuda-11-2-cudnn-8-1-0-and-python-3-9-on-rtx3090-for-deep-learning-fcf96c95f7a1

My PyTorch version is 1.9.0+cu102
On the link you shared with me, his PyTorch version is also 1.9.0

1 Like

I solved the problem by create a new Conda environment which has pytorch 3.7 and Cuda 11.1.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.