Fix "NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver"

Quick fix

Try to load the module and read the error it gives; that tells you which cause you have. The most common fix is rebuilding the module for the running kernel and rebooting.

sudo modprobe nvidia
# Ubuntu / Debian: rebuild for the current kernel
sudo apt install linux-headers-$(uname -r)
sudo dkms autoinstall
# Fedora (RPM Fusion): rebuild with akmods
sudo akmods --force
sudo reboot

The full message:

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

What the error means

nvidia-smi is installed (it comes with the driver's userspace packages), but it cannot open the GPU through the NVIDIA kernel module. Either the module is not loaded at all, or it refuses to work with this GPU. CUDA programs, PyTorch (torch.cuda.is_available() returning False), Ollama and similar tools fail for the same reason.

Start with these checks:

lsmod | grep -E '^nvidia|nouveau'
lspci -nnk | grep -A3 -Ei 'vga|3d'
sudo modprobe nvidia; echo "exit code $?"
uname -r

The modprobe error usually names the cause directly:

modprobe saysCause
FATAL: Module nvidia not found in directory /lib/modules/...Module not built for this kernel (cause 1)
ERROR: could not insert 'nvidia': Key was rejected by serviceSecure Boot blocks it (cause 2)
ERROR: could not insert 'nvidia': No such deviceDriver does not support this GPU, or nouveau holds it (cause 3, 4)
Nothing, exit code 0, but nvidia-smi still failsVersion mismatch or container/WSL setup (cause 5, 6)

The kernel log adds detail: sudo journalctl -k -b | grep -iE 'nvidia|nvrm'.

Cause 1: kernel updated, module not rebuilt

This is the most common cause. Distribution kernels update often, and the NVIDIA module has to be compiled for each one. DKMS or akmods does that automatically, but it fails silently if the kernel headers are missing or the driver is too old for the new kernel. Check what is built:

dkms status

Example output:

nvidia/580.95.05, 7.0.0-15-generic, x86_64: installed

If your running kernel (uname -r) is not listed as installed, rebuild:

# Ubuntu, Debian, Mint
sudo apt install linux-headers-$(uname -r)
sudo dkms autoinstall
sudo reboot

If the build fails, the driver branch may not support that kernel yet. Install the newer branch your distro offers (sudo ubuntu-drivers install on Ubuntu picks the recommended one), or boot the previous kernel from the GRUB "Advanced options" menu until an update arrives. The Ubuntu NVIDIA driver guide covers choosing a branch.

On Fedora with RPM Fusion, akmod-nvidia builds the module in the background after a kernel update, which takes a few minutes. Rebooting too early boots a kernel without a module. Fix it with:

sudo akmods --force
sudo dracut --force
sudo reboot

Cause 2: Secure Boot rejects the module

With Secure Boot enabled, the kernel only loads signed modules. Self-built NVIDIA modules are signed with a local Machine Owner Key (MOK) that must be enrolled in the firmware once. If you skipped the blue MOK enrollment screen after installing the driver, the module is rejected:

mokutil --sb-state
sudo modprobe nvidia
modprobe: ERROR: could not insert 'nvidia': Key was rejected by service

Enroll the key and reboot; choose "Enroll MOK" on the screen that appears and enter the password you set:

# Ubuntu / Debian DKMS key
sudo mokutil --import /var/lib/shim-signed/mok/MOK.der
# Fedora akmods key
sudo mokutil --import /etc/pki/akmods/certs/public_key.der
sudo reboot

Key paths vary by setup; the full procedure, including how to check which key signed the module, is in our Secure Boot and MOK guide. Enrolling the key is safer than disabling Secure Boot.

Cause 3: the driver does not support your GPU

Current NVIDIA drivers default to the open kernel modules, which only support Turing (GTX 16 / RTX 20) and newer GPUs. On a Pascal card (GTX 10 series) or older, the open module loads but finds no supported device, and the kernel log shows a message that the GPU is not supported by the open module. Use the proprietary legacy branch instead; 580 is the last branch that supports Maxwell, Pascal and Volta:

ubuntu-drivers devices          # Ubuntu: shows the recommended package per GPU

Very old cards (Kepler and earlier) have no current driver; nouveau is the supported option there. On laptops, also check that the dGPU is not switched off: on Ubuntu, prime-select query printing intel means the NVIDIA GPU is disabled; run sudo prime-select on-demand and reboot.

Cause 4: nouveau is loaded instead

If lsmod shows nouveau, the open-source driver claimed the GPU and the NVIDIA module cannot bind to it. Driver packages normally blacklist nouveau and rebuild the initramfs; if that step was missed:

echo -e "blacklist nouveau\noptions nouveau modeset=0" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
# Ubuntu 26.04 and Fedora use dracut; older Ubuntu/Debian use update-initramfs
sudo dracut --force          # or: sudo update-initramfs -u
sudo reboot

If you get a black screen after this, see NVIDIA black screen fix; booting once with nomodeset (see kernel parameters) gets you to a console to repair it.

Cause 5: driver/library version mismatch

After a driver upgrade, before rebooting, you may see a slightly different error:

Failed to initialize NVML: Driver/library version mismatch
NVML library version: 580.95

The new libraries are installed but the old module is still in memory. Reboot. If it persists after a reboot, an old module is still in the initramfs (rebuild it as in cause 4), or packages from two sources are mixed (for example the .run installer from nvidia.com on top of distro packages). Remove one: the distro packages are easier to keep working across kernel updates.

Cause 6: containers and WSL

  • Docker / Podman: the driver runs on the host; the container only gets access to it. Install the NVIDIA Container Toolkit on the host and start containers with --gpus all (Docker) or --device nvidia.com/gpu=all (Podman with CDI). Do not install a driver inside the image. If nvidia-smi fails on the host, fix the host first. See Docker on Linux.
  • WSL 2: install only the Windows NVIDIA driver. Inside WSL, nvidia-smi lives in /usr/lib/wsl/lib/. If you installed a Linux nvidia-driver package inside WSL, remove it; install only the CUDA toolkit packages meant for WSL.

Distro notes

  • Ubuntu, Mint: use sudo ubuntu-drivers install (Mint: Driver Manager). These pull prebuilt, signed modules for the stock kernel where available, which avoids causes 1 and 2.
  • Debian 13: enable contrib non-free non-free-firmware and install nvidia-driver (with linux-headers-amd64 for DKMS).
  • Fedora: RPM Fusion's akmod-nvidia; wait for akmods after kernel updates, or run sudo akmods --force.
  • Arch: nvidia-open matches only the stock linux kernel. With linux-lts, linux-zen or custom kernels use nvidia-open-dkms plus the matching headers package. Upgrade the kernel and driver together with pacman -Syu.
  • openSUSE: use the NVIDIA packages described on the openSUSE NVIDIA drivers wiki page.

How to prevent it

  • Install drivers from your distribution's tools, not the .run installer.
  • Keep kernel headers installed so DKMS can rebuild automatically, and reboot only after updates finish.
  • Keep at least one older kernel installed so you can boot it from GRUB if a new one breaks the driver.
  • Enroll the MOK key once when prompted, and leave Secure Boot enabled.

Frequently asked questions

Why does nvidia-smi fail after a kernel update?

The NVIDIA kernel module is built for one kernel version. If DKMS (Ubuntu, Debian, Arch DKMS packages) or akmods (Fedora) did not build it for the new kernel, nothing is loaded after reboot. Install the matching headers and rebuild, or boot the previous kernel from GRUB.

What does Failed to initialize NVML: Driver/library version mismatch mean?

The driver userspace libraries were upgraded but the old kernel module is still loaded. Rebooting loads the new module and fixes it.

Does Secure Boot stop the NVIDIA driver?

It can. With Secure Boot on, the kernel only loads modules signed with a trusted key. modprobe nvidia then fails with "Key was rejected by service" until you enroll the signing key with MOK.

Should I install the NVIDIA Linux driver inside WSL?

No. In WSL 2 the Windows NVIDIA driver provides the GPU, and nvidia-smi comes from Windows at /usr/lib/wsl/lib/nvidia-smi. Installing a Linux driver inside WSL breaks it.

Spotted a mistake or a command that no longer works? Send a correction — pages are re-checked when reports come in.