# NVIDIA L40s | CUDA driver initialization failed, you might not have a CUDA gpu

**URL:** <https://discuss.pytorch.org/t/nvidia-l40s-cuda-driver-initialization-failed-you-might-not-have-a-cuda-gpu/217505>\
**Category:** deployment\
**Created:** [March 6, 2025, 6:08am UTC](https://discuss.pytorch.org/t/nvidia-l40s-cuda-driver-initialization-failed-you-might-not-have-a-cuda-gpu/217505 "2025-03-06T06:08:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![afnanrahman](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/afnanrahman/32/76009_2.png) [@afnanrahman](https://discuss.pytorch.org/u/afnanrahman)\
**Post date:** [March 6, 2025, 6:08am UTC](https://discuss.pytorch.org/t/nvidia-l40s-cuda-driver-initialization-failed-you-might-not-have-a-cuda-gpu/217505/1 "2025-03-06T06:08:05Z")

</div>

My OS: Ubuntu 24.04.2 LTS  
Driver Version: 570.86.15  
nvcc --version

```auto
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2025 NVIDIA Corporation
Built on Wed_Jan_15_19:20:09_PST_2025
Cuda compilation tools, release 12.8, V12.8.61
Build cuda_12.8.r12.8/compiler.35404655_0

```

Torch version cuda:

```auto
>>> print(torch.version.cuda)
12.8

```

Nvidia-smi:

```auto
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.86.15 Driver Version: 570.86.15 CUDA Version: 12.8 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA L40S On | 00000000:03:00.0 Off | 0 |
| N/A 27C P8 23W / 350W | 1MiB / 46068MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 1 NVIDIA L40S On | 00000000:04:00.0 Off | 0 |
| N/A 28C P8 20W / 350W | 1MiB / 46068MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 2 NVIDIA L40S On | 00000000:63:00.0 Off | 0 |
| N/A 27C P8 22W / 350W | 1MiB / 46068MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 3 NVIDIA L40S On | 00000000:64:00.0 Off | 0 |
| N/A 26C P8 22W / 350W | 1MiB / 46068MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 4 NVIDIA L40S On | 00000000:83:00.0 Off | 0 |
| N/A 27C P8 22W / 350W | 1MiB / 46068MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 5 NVIDIA L40S On | 00000000:84:00.0 Off | 0 |
| N/A 26C P8 21W / 350W | 1MiB / 46068MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 6 NVIDIA L40S On | 00000000:E3:00.0 Off | 0 |
| N/A 27C P8 21W / 350W | 1MiB / 46068MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 7 NVIDIA L40S On | 00000000:E4:00.0 Off | 0 |
| N/A 26C P8 22W / 350W | 1MiB / 46068MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| No running processes found |
+-----------------------------------------------------------------------------------------+

```

Collect\_env.py:  
[Gitlab Snippets](https://gitlab.com/-/snippets/4819121)

Testing with Pytorch:

```auto
python3
Python 3.12.3 (main, Feb 4 2025, 14:48:35) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch 
>>> torch.cuda.is_available() 
/usr/local/lib/python3.12/dist-packages/torch/cuda/ __init__.py:174: UserWarning: CUDA initialization: CUDA driver initialization failed, you might not have a CUDA gpu. (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:109.)
  return torch._C._cuda_getDeviceCount() > 0
False
>>> torch.cuda.current_device() 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.12/dist-packages/torch/cuda/ __init__.py", line 1029, in current_device
    _lazy_init()
  File "/usr/local/lib/python3.12/dist-packages/torch/cuda/ __init__.py", line 376, in _lazy_init
    torch._C._cuda_init()
RuntimeError: CUDA driver initialization failed, you might not have a CUDA gpu.
>>> torch.cuda.device(0)
<torch.cuda.device object at 0x7c8b02a44560>
>>> exit()

```

What has been done:

1. Enable persistent mode
2. Reboot

Need help…

---

<div class="post-metadata">

**Author:** ![paulge](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/p/82dd89/32.png) [@paulge](https://discuss.pytorch.org/u/paulge)\
**Post date:** [March 6, 2025, 3:05pm UTC](https://discuss.pytorch.org/t/nvidia-l40s-cuda-driver-initialization-failed-you-might-not-have-a-cuda-gpu/217505/2 "2025-03-06T15:05:57Z")

</div>

Is it possible that you installed the cuda runtime separately using pip? Meaning you installed both cuda and torch?

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [March 6, 2025, 4:43pm UTC](https://discuss.pytorch.org/t/nvidia-l40s-cuda-driver-initialization-failed-you-might-not-have-a-cuda-gpu/217505/3 "2025-03-06T16:43:17Z")

</div>

The error points to a driver issue and you could run a simple CUDA example to try to reproduce it as it’s most likely unrelated to PyTorch.
