Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pytorch CUDA error: no kernel image is available for execution on the device on RTX 3090 with cuda 11.1

If I run the following:

import torch
import sys
print('A', sys.version)
print('B', torch.__version__)
print('C', torch.cuda.is_available())
print('D', torch.backends.cudnn.enabled)
device = torch.device('cuda')
print('E', torch.cuda.get_device_properties(device))
print('F', torch.tensor([1.0, 2.0]).cuda())

I get this:

A 3.7.5 (default, Nov  7 2019, 10:50:52) 
[GCC 8.3.0]
B 1.8.0.dev20210115+cu110
C True
D True
E _CudaDeviceProperties(name='GeForce RTX 3090', major=8, minor=6, total_memory=24267MB, multi_processor_count=82)
F 
<stacktrace>
CUDA error: no kernel image is available for execution on the device

More info about my system:

  • Nvidia version: NVIDIA-SMI 455.38 Driver Version: 455.38 CUDA Version: 11.1
  • python 3.7, Ubuntu 18.04
like image 513
Benjamin Crouzier Avatar asked Jan 15 '21 16:01

Benjamin Crouzier


People also ask

What version of CUDA does PyTorch support?

GPU Requirements Release 20.01 supports CUDA compute capability 6.0 and higher.

Is CUDA 11.6 compatible with PyTorch?

Can PyTorch work with CUDA 11.6 or 11.7? Thanks. Yes, you could install the binaries with the CUDA 11.6 runtime by swapping the version from the provided install commands and you can of course build from source using both CUDA versions.

Is CUDA available torch?

In PyTorch, the torch. cuda package has additional support for CUDA tensor types, that implement the same function as CPU tensors, but they utilize GPUs for computation. If you want a tensor to be on GPU you can call .


1 Answers

Found a fix for my problem here: https://github.com/pytorch/pytorch/issues/31285#issuecomment-739139454

pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cu110/torch_nightly.html -U

Then my code snippet gives:

A 3.7.5 (default, Nov  7 2019, 10:50:52) 
[GCC 8.3.0]
B 1.8.0.dev20210115+cu110
C True
D True
E _CudaDeviceProperties(name='GeForce RTX 3090', major=8, minor=6, total_memory=24267MB, multi_processor_count=82)
F tensor([1., 2.], device='cuda:0')
like image 196
Benjamin Crouzier Avatar answered Sep 19 '22 22:09

Benjamin Crouzier