Fix NVML Driver/Library Version Mismatch
“Failed to initialize NVML: Driver/library version mismatch” means the NVIDIA kernel driver currently loaded by Linux does not match the NVML user-space library that nvidia-smi is trying to use. The most common fix after a normal driver update is a reboot, which loads the updated kernel module; if that fails, repair the driver as one consistent package set rather than mixing distro packages with NVIDIA’s .run installer.
Use this table to choose the safest first action.
| Symptom | Likely Cause | First Safe Action |
|---|---|---|
| The error appeared immediately after system updates | Updated NVIDIA libraries are installed, but the old NVIDIA kernel module is still loaded | Reboot and test again |
| The NVML library version differs from the loaded NVRM version | A partial package update or stale module is active | Reinstall the distro driver package, then reboot |
You previously used NVIDIA’s .run installer and later used apt, dnf, zypper, or another package manager |
Files from two installation methods are mixed | Uninstall the .run driver, then install through one package manager |
| The error happens only in a container or one shell | A container image or LD_LIBRARY_PATH is finding incompatible NVIDIA libraries |
Confirm the host works first, then rebuild or recreate the container |
| The GPU does not appear on the PCI bus | This may be a hardware, firmware, VM passthrough, or PCIe issue rather than an NVML mismatch | Investigate hardware visibility before reinstalling drivers |
What the NVML Version Mismatch Error Means
NVML is the NVIDIA Management Library. Tools such as nvidia-smi, monitoring agents, CUDA tooling, and container runtimes use it to query the NVIDIA driver for GPU temperature, memory use, processes, power state, and driver capabilities.
On Linux, the NVIDIA driver has two connected parts:
- A kernel module, such as
nvidia, loaded into the running Linux kernel. - User-space files, including the NVML library, usually named
libnvidia-ml.so.
Those parts must come from compatible driver releases. For example, the kernel may still have an older NVRM driver loaded while package updates have installed a newer libnvidia-ml.so. NVML rejects that combination rather than returning unreliable GPU information.
Treat a post-update mismatch and a mixed-installation mismatch as different problems: reboot for a stale loaded module, but remove one installation method when package-managed and .run drivers have been combined.
Before changing drivers, confirm that Linux can still see the physical GPU on PCI:
lspci | grep -i nvidia
An NVIDIA entry means the hardware is visible to the operating system, so the repair should focus on the driver stack. No output does mean reinstalling NVML libraries alone is unlikely to help.
How to Fix the NVML Driver/Library Mismatch
Step 1: Record the Loaded Driver and Library Versions
Start by capturing the current state. The error from nvidia-smi often includes an “NVML library version” line, while the /proc file reports the version of the driver module loaded into the running kernel.
nvidia-smi
cat /proc/driver/nvidia/version
Also check whether NVIDIA modules are currently loaded:
lsmod | grep -i '^nvidia'
A mismatch is clear when the loaded NVRM version and the NVML library version belong to different NVIDIA releases. If /proc/driver/nvidia/version does not exist, the NVIDIA kernel module is not loaded at all; this is a driver-loading problem rather than a normal post-update mismatch.
Step 2: Reboot Once After a Normal Driver Update
If the error started after an apt, dnf, zypper, or system update, reboot before reinstalling anything.
sudo reboot
After the system returns, test the driver:
nvidia-smi
A reboot loads the current NVIDIA module built or installed for the running kernel. This is especially important after a driver update because updating files on disk does not replace a module that is already active in memory.
Save open work before rebooting. A reboot is safer than trying to unload NVIDIA modules on a desktop system that is using the GPU for the display server.
Step 3: Identify Whether the Driver Was Installed by Packages or a .run File
Use one driver installation method per host.
On Ubuntu and Debian, inspect installed NVIDIA packages:
dpkg -l | grep -E 'nvidia|libnvidia'
For a package-managed Ubuntu or Debian installation, reinstall the repository driver package as one coherent set rather than adding a .run installer.
If you remember running a file with a name like NVIDIA-Linux-x86_64-...run, or the system has the NVIDIA uninstaller available, you have likely used NVIDIA’s standalone installer:
command -v nvidia-uninstall
Do not install a newer .run file on top of apt, dnf, or zypper packages to “make the versions match.” That usually leaves the kernel module, GL libraries, CUDA-related files, or NVML library managed by different installers.
Step 4: Reinstall One Coherent Driver Stack
Choose the path that matches your installation history.
If the system uses Ubuntu or Debian repository packages and the generic nvidia-driver package is available, refresh and reinstall the driver package:
sudo apt update
sudo apt install --reinstall nvidia-driver
Then reboot so the repaired module is loaded:
sudo reboot
Verify that the driver and library can communicate:
nvidia-smi
If you mixed an NVIDIA .run installation with apt packages, first remove the standalone installation. Run this only when the earlier check found the uninstaller:
sudo nvidia-uninstall
The standalone uninstaller may require a text console because it can remove files used by the graphical session. If the command is not available, use the exact NVIDIA .run installer version that was originally used and select its uninstall option; do not manually delete random files from /usr/lib, /usr/local, or /lib/modules.
After the .run installation is removed, remove the remaining package-managed NVIDIA stack:
sudo apt purge 'nvidia*' 'libnvidia*'
Reinstall the distribution-supported driver as a single set:
sudo apt update
sudo apt install nvidia-driver
Finish by rebooting and testing:
sudo reboot
nvidia-smi
This method intentionally removes the old stack before installing the new one. It is more disruptive than a reboot, but it prevents a manually installed NVML library from being loaded beside a package-managed kernel module.
Repairing Distribution-Specific Driver Problems
Rebuilding modules or initramfs and updating matching packages resolves distribution-specific NVIDIA driver mismatches.
Fedora Systems Using RPM Fusion and Akmods
Fedora systems using the RPM Fusion NVIDIA packages commonly build the driver module with Akmods. A mismatch can occur when the user-space driver packages have updated but the kernel module for the current kernel has not finished building, or when an older module remains in the boot image.
List the installed NVIDIA packages:
rpm -qa | grep -i nvidia
Check the active module version:
cat /proc/driver/nvidia/version
For an RPM Fusion Akmods installation, rebuild the module and regenerate the initramfs:
sudo akmods --rebuild
sudo dracut --force
Then reboot and test:
sudo reboot
nvidia-smi
Let package transactions and Akmods module builds finish before rebooting after a kernel or NVIDIA driver update. An interrupted build can leave the new libraries installed while the booted kernel still uses the old module.
RHEL and Other Dracut-Based Systems
On RHEL-family systems, an old NVIDIA kernel module can remain inside the initramfs even after the driver packages on disk have changed. Regenerating the initramfs for the active kernel can remove that stale copy.
First confirm that the installed module can be found:
modinfo -F version nvidia
Rebuild the initramfs for the running kernel:
sudo dracut --force --kver "$(uname -r)"
Reboot and validate the result:
sudo reboot
nvidia-smi
If modinfo cannot find an NVIDIA module, repair the NVIDIA driver package or DKMS build through the same repository that originally supplied the driver. Do not copy a module from another kernel version into /lib/modules.
openSUSE Systems
On openSUSE, inspect the installed NVIDIA packages and their versions before removing anything:
zypper se -si nvidia
A mismatch can occur when libnvidia-ml is newer than the installed NVIDIA KMP driver package. Update the repository metadata and let zypper resolve a matching set of NVIDIA packages:
sudo zypper refresh
sudo zypper update
Then reboot and test:
sudo reboot
nvidia-smi
If the package list still shows an NVML library from a different release family than the installed KMP driver, reinstall the matching KMP and library packages from the same NVIDIA repository family. Do not install a separate NVML package solely to chase the number printed in the error; the kernel module, compute libraries, and utilities need to remain aligned.
Recovering Without a Reboot
A no-reboot recovery is possible only when the updated driver module already exists on disk and the GPU is not being used by the graphical desktop, a CUDA job, a container, or another service. It is best suited to a headless compute server during a planned maintenance window.
First see which processes have NVIDIA device files open:
sudo lsof /dev/nvidia*
Record the listed GPU workloads for the maintenance window.
Unload the modules in dependency order:
sudo rmmod nvidia_uvm
sudo rmmod nvidia_drm
sudo rmmod nvidia_modeset
sudo rmmod nvidia
If any command reports that a module is in use, stop there. Forced removal can disrupt GPU memory or the display stack.
Load the base module again:
sudo modprobe nvidia
Then confirm that NVML and the loaded driver agree:
nvidia-smi
If this fails, reboot when possible. Unloading and reloading modules cannot fix package files that are genuinely from incompatible releases.
Fixing the Error in Docker and Other Containers
A container does not load its own NVIDIA kernel driver. It uses the host’s loaded NVIDIA kernel module, while the container runtime exposes compatible driver libraries inside the container.
Start by testing the host directly:
nvidia-smi
If the host shows the same mismatch, repair the host first. Rebuilding a container will not fix an inconsistent host driver.
If the host works but the container fails, the container is probably finding an incompatible NVML library. Common causes include:
- Installing a full Linux NVIDIA driver inside the image.
- Bind-mounting a host
libnvidia-ml.sofile manually. - Setting
LD_LIBRARY_PATHto an older CUDA or NVIDIA library directory. - Reusing a long-lived container created before a host driver upgrade.
Test whether a shell-specific library path is responsible:
env -u LD_LIBRARY_PATH nvidia-smi
If that works, remove the stale NVIDIA library directory from the environment configuration that launches the application. If the problem exists only in a container, recreate the container from its image and let the NVIDIA container runtime supply the host-compatible driver libraries. Avoid installing a kernel driver inside a normal GPU application container.
Confirming the Repair and Preventing a Repeat
A successful repair produces normal nvidia-smi output with a driver version, GPU list, and running-process table rather than the NVML mismatch message.
Check the loaded module version:
cat /proc/driver/nvidia/version
Check the module version installed for the current kernel:
modinfo -F version nvidia
The versions should be compatible, and nvidia-smi should run successfully. If a CUDA application is the real workload, test that application after nvidia-smi succeeds; a healthy NVML connection confirms the driver stack is communicating, not that every application dependency is correct.
To prevent the problem:
- Use either distro packages or NVIDIA’s
.runinstaller, not both. - Reboot after NVIDIA driver updates unless you have a planned module-reload procedure for a headless host.
- Let Akmods or DKMS builds complete after kernel updates.
- Keep container images free of host kernel driver packages.
- Avoid manually copying
libnvidia-ml.sobetween machines, driver releases, or container images.
Frequently Asked Questions
What does “can’t initialize NVML” mean?
“Can’t initialize NVML” means an NVIDIA tool cannot communicate with the active NVIDIA driver through the NVML management library. With a driver/library version mismatch, the loaded kernel module and the user-space NVML library come from incompatible driver releases. Rebooting fixes the common post-update case; reinstalling a single driver stack fixes mixed or partial installations.
What is NVIDIA NVML?
NVML is NVIDIA Management Library, the interface used to read GPU status such as memory use, temperature, active processes, power information, and driver details. The nvidia-smi utility uses NVML to display its GPU table. NVML must remain compatible with the NVIDIA kernel driver loaded by Linux.
How do I fix an NVIDIA driver update that failed?
First reboot once, because an update can place new driver libraries on disk while the system is still running the old kernel module. If the mismatch remains, reinstall the NVIDIA driver through the same package manager that installed it, then reboot and run nvidia-smi. If you previously used an NVIDIA .run installer and later switched to repository packages, uninstall the .run driver before reinstalling the package-managed stack.
How do I get the CUDA driver version?
Run the following command and read the Driver Version and CUDA Version fields in its header:
nvidia-smi
The CUDA Version field is the highest CUDA runtime API version supported by the installed NVIDIA driver; it is not necessarily the CUDA toolkit version installed on the machine. To check an installed CUDA compiler toolkit, run:
nvcc --version
Can I fix the NVML mismatch without rebooting?
Yes, but only on a headless system after all GPU users have stopped. Unload nvidia_uvm, nvidia_drm, nvidia_modeset, and nvidia, then load nvidia again and run nvidia-smi. If a module is in use or the system uses NVIDIA for its desktop display, rebooting is the safe option.
