GPU not detected in Linux: a layer-by-layer diagnosis
Updated · Scientifically reviewed by Dinkar Mishra, PhD on
Short answer
Work up the stack: (1) lspci | grep -i nvidia shows whether the hardware is visible; (2) nvidia-smi shows whether the driver is loaded. If it fails, check for Secure Boot, the nouveau driver, or a kernel update without a DKMS rebuild; (3) inside containers, start with --gpus all and the NVIDIA Container Toolkit; (4) in Python, torch.cuda.is_available() is False when you installed a CPU-only build or the CUDA runtime is too new for your driver.
Who this is for
Researchers and lab administrators setting up GPU workstations or servers for simulation and machine learning.
Software
Ubuntu 22.04 / 24.04 (commands similar on other distributions)NVIDIA driver any current branch
Symptoms
nvidia-smiprints: NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver.nvidia-smi: command not found.torch.cuda.is_available()returnsFalse, or your code falls back to the CPU.- In Docker:
could not select device driver "" with capabilities: [[gpu]]. - On a cluster: the job runs but no GPU is visible.
Diagnosis
Go layer by layer. Stop at the first layer that fails.
Layer 1: hardware on the PCIe bus
lspci | grep -i -E "nvidia|3d|vga"
No NVIDIA device listed means a hardware, power or BIOS problem. The driver cannot help.
Layer 2: kernel driver
lsmod | grep -E "^nvidia|nouveau" # which GPU driver is loaded?
sudo dmesg | grep -i -E "nvidia|nvrm" | tail -n 20
mokutil --sb-state # is Secure Boot enabled?
dkms status # was the module built for this kernel?
uname -r
| Finding | Meaning |
|---|---|
nouveau loaded, nvidia not | The open-source driver is in use; the proprietary driver is missing or blocked. |
| dmesg: “module verification failed” or “Key was rejected” | Secure Boot blocked the unsigned NVIDIA module. |
dkms status lacks your current kernel | The module was not rebuilt after a kernel update. |
| dmesg: “RmInitAdapter failed” or “fallen off the bus” | Hardware, power or thermal problem, or a driver/GPU mismatch. |
Layer 3: containers. Test the GPU outside the container first. Inside Docker, GPUs must be requested explicitly and the NVIDIA Container Toolkit installed:
docker run --rm --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smi
Layer 4: application or framework
python -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available())"
echo "CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES-unset}"
torch.version.cuda printing None means a CPU-only build. On Slurm clusters, a GPU is visible only if you requested one (--gpus=1 or --gres=gpu:1).
Fixes
Install or reinstall the driver (Ubuntu). Use the distribution’s packaged drivers. They integrate with DKMS and Secure Boot signing:
sudo ubuntu-drivers list # recommended driver ("ubuntu-drivers devices" on older releases)
sudo ubuntu-drivers install # installs the recommended driver
sudo reboot
Our NVIDIA driver installation guide covers choosing branches, servers and pinning.
Secure Boot. Either enrol the machine owner key that the installer offers (set a password during installation, then confirm it in the blue MOK manager screen at reboot), or disable Secure Boot in the firmware if your security policy allows.
Kernel updated, module missing. Reinstall the driver package so DKMS builds the module for the running kernel, or boot the previous kernel from GRUB while you fix it.
nouveau conflict. Packaged drivers blacklist nouveau automatically. If you installed from NVIDIA’s .run file, follow NVIDIA’s guide to blacklist it and rebuild the initramfs (sudo update-initramfs -u).
Containers. Install the NVIDIA Container Toolkit, configure the runtime (sudo nvidia-ctk runtime configure --runtime=docker), restart Docker, and run with --gpus all.
PyTorch or other frameworks. Install a CUDA-enabled build that your driver supports, using the official install selector, inside a clean virtual environment.
When to get help
If dmesg shows Xid errors, “fallen off the bus”, or the GPU disappears under load, the cause may be power, cooling, PCIe risers or failing hardware. We help labs diagnose and configure GPU servers and clusters, including drivers, CUDA, containers and Slurm GPU scheduling.
Assumptions and limitations
- Commands target Ubuntu 22.04/24.04. RHEL, Rocky and Alma use
dnfand NVIDIA’s repository or ELRepo packages, and the diagnosis steps are the same. - AMD GPUs use ROCm (
rocm-smi,amdgpudriver) and are not covered here. - Container image tags change over time. Pick a CUDA base image that your driver supports.
Frequently asked questions
nvidia-smi works but PyTorch does not see the GPU. Why?+
Most often the installed PyTorch is a CPU-only build (torch.version.cuda is None), or its CUDA runtime is newer than your driver supports. Reinstall PyTorch with a CUDA-enabled build matching your driver, using the selector on pytorch.org, and check that CUDA_VISIBLE_DEVICES is not set to an empty value.
What CUDA version does my driver support?+
The "CUDA Version" printed at the top right of nvidia-smi is the highest CUDA runtime that the driver supports, not the toolkit that is installed. Applications built with that version or older will run.
The GPU disappeared after a kernel update. What happened?+
The NVIDIA kernel module is compiled for a specific kernel. If DKMS did not rebuild it for the new kernel, the module cannot load. Check dkms status, reinstall the driver package, or boot the previous kernel from the GRUB menu.
lspci does not list the GPU at all. Is it broken?+
Not necessarily. Check that it is seated and powered (auxiliary power cables), that the PCIe slot is enabled in the BIOS/UEFI, and, on servers, that the slot is supported in the current riser configuration. If it is still missing, test it in another machine.
References
- NVIDIA CUDA Installation Guide for Linux · NVIDIA
- NVIDIA drivers installation (Ubuntu Server) · Canonical
- NVIDIA Container Toolkit installation guide · NVIDIA
- nvidia-smi documentation · NVIDIA
Still stuck?
Send us the error output and your job script. A computational scientist will diagnose it, usually within a day.
Services listed on this page are available today. Products marked “early access” or “in development” on our platform page are not yet generally available.
Spotted an error or an outdated command? Tell us. We correct verified issues promptly.