nvidia-smi stops working after the NVIDIA driver packages change
Fix it fast
Most common cause, 1 of 2The 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.
sudo rebootShort 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.
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.
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 / FedoraThen find the line you see in this list and open its fix:
- 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 - 2A .run installer and distribution packages are both on the machine
The 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 mismatchnvidia-container-cli: initialization error: nvml error: driver/library version mismatch: unknownNVRM: 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.
uptime -s
sudo dnf needs-restarting -r # DNF 4 systems; lists nvidia-driver-cuda when a reboot is dueFix
Reboot the machine so the kernel module from the new packages is loaded, then recreate any GPU containers that were running before.
sudo rebootVerify
nvidia-smi prints its table again, and /proc/driver/nvidia/version now shows the same release as the installed packages.
cat /proc/driver/nvidia/version
nvidia-smiConfirmed by docs.nvidia.com
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.
ls -l /usr/bin/nvidia-installer
dpkg -l | grep -c nvidiaFix
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.
sudo nvidia-installer --uninstall
sudo apt install nvidia-open # Ubuntu, with NVIDIA's repository enabled
sudo rebootVerify
After the reboot, the version in /proc/driver/nvidia/version matches the package, and nvidia-smi runs.
nvidia-smiConfirmed by download.nvidia.com
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.