Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
AI and LLM integration

nvidia-smi stops working after the NVIDIA driver packages change

Your error

Failed to initialize NVML: Driver/library version mismatch2 more lines it can show

Fix it fast

Most common cause, 1 of 2

The driver was upgraded and the old kernel module is still loaded

Reboot the machine so the kernel module from the new packages is loaded, then recreate any GPU containers that were running before.

Fix
sudo reboot
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Failed to initialize NVML: Driver/library version mismatch means the NVIDIA kernel module in memory and the NVML library on disk come from different driver releases. Usually the driver packages were upgraded and the machine has not rebooted since. Compare /proc/driver/nvidia/version with the installed package version, then reboot. Applies to NVIDIA Linux drivers up to branch 620.

  • Applies to NVIDIA Linux driver 620.73.04 (branch 620), Ubuntu 22.04, 24.04 and 26.04, RHEL, Rocky and AlmaLinux 8-10, Fedora 44 with DNF 5
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Read the version of the module that is loaded right now, then the version the package manager installed. Two different numbers with no reboot in between is cause 1. The same mismatch surviving a fresh boot is cause 2.

Run this first
cat /proc/driver/nvidia/version
sudo dmesg | grep -A4 "NVRM: API mismatch"
dpkg -l | grep -E "nvidia-driver|libnvidia-compute"   # Ubuntu / Debian
rpm -qa | grep -E "^nvidia-driver"                     # RHEL family / Fedora

Then find the line you see in this list and open its fix:

  1. 1The driver was upgraded and the old kernel module is still loaded/proc/driver/nvidia/version shows an older release than the installed packages, and uptime goes back to before the upgrade
  2. 2A .run installer and distribution packages are both on the machineThe mismatch is still there right after a reboot, and /usr/bin/nvidia-installer exists next to nvidia packages listed by dpkg or rpm

What does the error look like?

  • Failed to initialize NVML: Driver/library version mismatch
  • nvidia-container-cli: initialization error: nvml error: driver/library version mismatch: unknown
  • NVRM: API mismatch: the client 'nvidia-smi' (pid 4120)

Cause 1 of 2

The driver was upgraded and the old kernel module is still loaded

You see/proc/driver/nvidia/version shows an older release than the installed packages, and uptime goes back to before the upgrade

Check

NVML refuses to start with a Driver/library version mismatch because NVIDIA requires the kernel modules and the user-space parts of the driver to be the same version. A package upgrade, manual or unattended, replaces the libraries at once, but the new module only loads on the next boot. Starting a GPU container runs the same check on the host, which is where the nvidia-container-cli form of the message comes from.

Check
uptime -s
sudo dnf needs-restarting -r   # DNF 4 systems; lists nvidia-driver-cuda when a reboot is due

Fix

Reboot the machine so the kernel module from the new packages is loaded, then recreate any GPU containers that were running before.

Fix
sudo reboot

Verify

nvidia-smi prints its table again, and /proc/driver/nvidia/version now shows the same release as the installed packages.

Verify
cat /proc/driver/nvidia/version
nvidia-smi

Confirmed by docs.nvidia.com

Did this fix it?

Cause 2 of 2

A .run installer and distribution packages are both on the machine

You seeThe mismatch is still there right after a reboot, and /usr/bin/nvidia-installer exists next to nvidia packages listed by dpkg or rpm

Check

The .run installer copies its files outside the package manager and records them for later removal. When distribution packages are added on top, or the reverse, the module and the libraries can come from different releases on every boot. NVIDIA's README recommends the distribution's repackaged driver where one exists.

Check
ls -l /usr/bin/nvidia-installer
dpkg -l | grep -c nvidia

Fix

Keep one method. Undo the .run install with its own uninstall option, reinstall the driver from your distribution's packages, and reboot. If you keep the .run driver instead, remove the packages with the commands on NVIDIA's Removing the Driver page before rerunning it.

Fix
sudo nvidia-installer --uninstall
sudo apt install nvidia-open   # Ubuntu, with NVIDIA's repository enabled
sudo reboot

Verify

After the reboot, the version in /proc/driver/nvidia/version matches the package, and nvidia-smi runs.

Verify
nvidia-smi

Confirmed by download.nvidia.com

Did this fix it?

How do I stop it coming back?

  • On Ubuntu, install NVIDIA's version-specific pinning package (apt install nvidia-driver-pinning-<version>) and move to a new driver only in a window that includes a reboot.
  • On DNF 5 hosts, set reboot = when-needed in the [commands] section of /etc/dnf/automatic.conf so automatic driver updates end with a restart.
  • Add dnf needs-restarting -r, or a check that compares /proc/driver/nvidia/version with the package version, to your monitoring.
  • Use one installation method per machine and write it in the server's runbook.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.