CUDA initialization: CUDA driver initialization failed, you might not have a CUDA gpu

I am getting the following error :-

import torch

torch._C._cuda_getDeviceCount()

:1: UserWarning: CUDA initialization: CUDA driver initialization failed, you might not have a CUDA gpu. (Triggered internally at …/c10/cuda/CUDAFunctions.cpp:109.)
0


torch version cuda is 11.7

torch.version.cuda
‘11.7’


nvcc - V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0

print(torch. version)
2.0.0+cu117

From the release compatibility matrix I know that torch version 2.0.0 is compatible with cuda 11.7 stable and 11.8 experimental.

Can you please suggest on what might be the issue here ?

Your system seems to have issues initializing the driver. I don’t know if this system was working before but you might need to reinstall a proper NVIDIA driver.

I am using docker enviroment and face the same issue.

  1. torch version is ‘2.0.1+cu118’
  2. NVIDIA-SMI 515.105.01 Driver Version: 515.105.01 CUDA Version: 11.8
    Any help will be thankful, thanks.

Is this resolved? I am facing this same issue.