If you run nvidia-smi and get "Failed to initialize NVML: Driver/Library version mismatch", this usually happens after an apt upgrade or a kernel update. This guide shows you how to confirm the cause, fix it safely, and test your GPU workloads.
How to Fix NVML Errors After a Kernel Update on Ubuntu
Table of Contents
- Why NVML Driver/Library Mismatch Happens
- Confirm the Error on the Host
- Find the NVIDIA Version Mismatch
- How to Find the Cause of the NVML Error
- Fix A: Planned Reboot (Best Option)
- Fix B: Reload the Module Without a Reboot
- Fix C: Repair After a Kernel Update
- Fix NVML Errors Inside Docker Containers
- Verify the Fix: Test the Host and Docker
- Best Practices for NVIDIA Driver Updates
- Conclusion

Why NVML Driver/Library Mismatch Happens
NVML is the NVIDIA Management Library, and nvidia-smi uses it. The error means two parts of the driver have different versions:
- The kernel module loaded in memory (the old version).
- The user-space libraries on disk (the new version, installed by
apt).
An update replaces the files on disk, but the old module stays loaded until you reboot or reload it. If you use GPU dedicated server hosting, this is a common problem after unattended upgrades.
Now let's check your server step by step to confirm this problem and fix it.
Confirm the Error on the Host
Start on the host, not inside a container. Run nvidia-smi in a normal terminal on the server:
If you see this on the host, it is a host problem, and the next steps will fix it. If it works on the host, the problem is only in your container, so skip to the container section.
Find the NVIDIA Version Mismatch
Now, you must check which driver version is loaded and which one is installed. The error happens when these two are different.
First, check the running kernel and the loaded module version with the commands below:
Then, check the installed driver module version with the commands below:
Next, check for the installed packages with the following commands:
Also, check DKMS and held packages with the commands below:
Here is an example of a version mismatch:
If the two numbers are different, the old module is still in memory. This is the classic mismatch.
How to Find the Cause of the NVML Error
Use this short checklist to find the cause of your error. Answer each question in order, based on the results you found in the above steps.
-
nvidia-smifails on the host. Go to the next question. -
Does
/proc/driver/nvidia/versionexist?-
No: The module is not loaded. Go to "Module Missing After Kernel Update".
-
Yes: Compare it with
modinfo -F version nvidia.
-
-
Are the versions different? Do a planned reboot (Fix A).
-
Are the versions the same, but the error stays after reboot? Check for held packages, mixed driver branches, or a stale initramfs (Fix C).
-
Does the host work, but a container fails? Go to "Container-Only Errors".
Fix A: Planned Reboot (Best Option)
A reboot is the simplest and safest fix. NVIDIA says a reboot will typically resolve this error. First, stop your GPU workloads and then reboot:
After the reboot, log in and run nvidia-smi again. If you see the GPU table with your driver version, the fix worked.
Fix B: Reload the Module Without a Reboot
Use this method only if you cannot reboot right now. You can unload the old driver from memory and load the new one. To do this, follow the steps below:
- Stop everything that uses the GPU:
- Unload the modules:
- Load the new module and test:
If a module says "in use", find the process with sudo lsof /dev/nvidia*, stop it, and try again. If it still will not unload, you must reboot.
Fix C: Repair After a Kernel Update
A kernel update can break the NVIDIA driver, because every kernel needs its own matching module. Use these steps if the module is missing, or if the versions still do not match after a reboot.
Module Missing After Kernel Update
A new kernel needs a matching NVIDIA module. With DKMS, the module is rebuilt for the new kernel, and it needs the kernel headers. Check the status with:
A good result looks like this:
If the entry is missing, install the headers and rebuild:
Note: Ubuntu can also use precompiled modules. So if DKMS shows no entry, the module may still be there. Run modinfo -n nvidia to check.
Stale or Mixed Packages
If the versions still differ after a reboot, reinstall the driver package you already use, and do not purge everything:
Replace <branch> with your branch from dpkg -l | grep nvidia-driver. Or let Ubuntu pick the recommended driver:
Secure Boot
If Secure Boot is on, an unsigned module will not load. Run this command to check if Secure Boot is on:
If it says enabled, make sure the NVIDIA module is signed, then reboot.
Note: Do not blindly purge drivers. Purging can remove packages you still need and can leave a server without a working GPU stack. First, try the steps above. Use a full reinstall only as a last choice, and use a console or IPMI so you can recover.
Fix NVML Errors Inside Docker Containers
Sometimes nvidia-smi works on the host, but fails inside a Docker container. In this case, the driver is fine, and the problem is in the container setup. Use this step to find the exact error message and fix it.
Run this command to test if a Docker container can use your GPU:
Read the exact error message:
- Driver/library version mismatch: The host is the problem. Fix the host, then restart the container.
- Unknown Error (the container worked, then lost the GPU): This is a known container issue. A container update can remove GPU access. Delete the container and start it again.
You can run this command to create the missing GPU device links that containers need:
Also, you can set Docker to use cgroupfs. Edit /etc/docker/daemon.json with your desired text editor and set:
If the file already has other settings, add this line and keep the JSON valid. Then, restart Docker:
This helps with the daemon-reload case, but not with every container update.
- Insufficient Permissions: This is usually SELinux on Red Hat systems. It is not common on Ubuntu.
Tips: To set up Docker with GPU access from scratch, you can follow our guide on AI serving with Docker on a dedicated server.
Verify the Fix: Test the Host and Docker
Now make sure the fix really worked. First, check that nvidia-smi works on the host and that the driver versions match:
Then, run this command to check that Docker can use your GPU:
Next, start your GPU workloads again, for example vLLM or Triton, and check the logs for errors.
Best Practices for NVIDIA Driver Updates
You can avoid this error with a few simple steps. Most cases happen after an update, so plan your updates and reboots. Follow these tips to keep your GPU server stable:
- Plan a reboot after every driver or kernel update.
- Do not run driver upgrades during busy hours.
- Keep one driver source. Do not mix Ubuntu packages and the NVIDIA
.runinstaller. - Check
dkms statusafter each kernel update.
If you need a separate machine to test driver updates, you can try a dedicated NVIDIA GPU VPS for smaller jobs.
Conclusion
The failed to initialize NVML error means the loaded driver and the installed libraries have different versions. Compare the two versions, then do a planned reboot. If the error stays, check DKMS, kernel headers, packages, and Secure Boot. If only a container fails, fix the container, not the host. Always finish by running nvidia-smi on the host and in a container.
We hope you enjoy this troubleshooting guide. For more detailed information, you can check the NVIDIA Enterprise Support.