NVIDIA Container Toolkit: Failed to initialize NVML: Unknown Error
Fix nvidia-container-cli / NVIDIA Container Toolkit Failed to initialize NVML: Unknown Error in Docker and Kubernetes after systemd or driver updates.
This error occurs inside Docker or containerd when the container runtime cgroup driver or systemd reload invalidates GPU device cgroup access, or when host NVML itself is broken. Test nvidia-smi on the host first, then check nvidia-container-runtime no-cgroups / CDI settings and restart the container daemon.
- Symptom
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running prestart hook #0: exit status 1, stdout: , stderr: Auto-detected mode as 'legacy' nvidia-container-cli: initialization error: nvml error: driver/library version mismatch: unknown.- Root cause
- Stale cgroup device permissions after systemd reload, misconfigured /etc/nvidia-container-runtime/config.toml, or broken host NVML.
- Recommended fix
- Run nvidia-smi directly on the host first. If the host itself fails with Failed to initialize NVML: Driver/library version mismatch, compare cat /proc/driver/nvidia/version with modinfo -F version nvidia, check dmesg -T | grep -iE 'NVRM|API mismatch', and reboot during maintenance.
- How Denpex helps
- Denpex investigates NVIDIA Container Toolkit: Failed to initialize NVML: Unknown Error using the evidence you provide or your connected workload collects. Earlier rank, host or application evidence is needed to distinguish an initiating failure from a downstream report.
What this failure is
nvidia-container-cli failed to initialize NVML inside a newly spawned container namespace despite GPU hardware existing on the host.
Is this what broke your run? Paste your log.
You're reading about NVIDIA Container Toolkit: Failed to initialize NVML: Unknown Error. Paste your own traceback and relevant evidence for an investigation of your workload, with a next action or a specific missing fact. A reference entry does not establish your cause. No account or card for the free diagnosis. Review data handling before submitting sensitive logs.
Before uploading, review cloud data handling and local options.
Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.
Why it happens (the mechanism)
On systemd-based Linux hosts, daemon-reload or systemd updates without restarting Docker/containerd can drop BPF device cgroup permissions for running containers, or a background NVIDIA library update created a host NVML mismatch.
What you'll observe
- Containers fail at startup with Failed to initialize NVML: Unknown Error
- Running GPU pods suddenly lose NVML access after host systemd updates
Common symptoms and what they mean
Check possible explanations against the incident evidence. A matching symptom alone does not establish its cause.
| Symptom | Possible explanation |
|---|---|
| docker: Error response from daemon: failed to create task for container: nvidia-container-cli: initialization error: nvml error: driver/library version mismatch or unknown error | Stale cgroup device permissions after systemd reload, misconfigured /etc/nvidia-container-runtime/config.toml, or broken host NVML. |
| Failed to initialize NVML: Unknown Error inside Docker or Kubernetes pod | Stale cgroup device permissions after systemd reload, misconfigured /etc/nvidia-container-runtime/config.toml, or broken host NVML. |
Which systems are affected
- Docker Engine and containerd with NVIDIA Container Toolkit
- Kubernetes GPU nodes using systemd cgroup driver
How to confirm this is the problem
Use this checklist to test the hypothesis against a small reproduction. No single line proves the root cause, so preserve the preceding events and compare one variable at a time.
- ✓Run docker run --rm --gpus all nvidia/cuda:12.6.0-base-ubuntu24.04 nvidia-smi and verify all expected GPUs appear.
Root cause
- Stale cgroup device permissions after systemd reload, misconfigured /etc/nvidia-container-runtime/config.toml, or broken host NVML.
The fix and how to prevent it
How to fix it
- Run nvidia-smi directly on the host first. If the host itself fails with Failed to initialize NVML: Driver/library version mismatch, compare cat /proc/driver/nvidia/version with modinfo -F version nvidia, check dmesg -T | grep -iE 'NVRM|API mismatch', and reboot during maintenance.
- Check /etc/nvidia-container-runtime/config.toml and run sudo nvidia-container-cli -k -d /dev/stderr info to inspect exact library mounting and cgroup errors.
- Run sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml if using CDI, and restart containerd/docker cleanly (sudo systemctl restart containerd docker) during a drain window.
Step-by-step remediation
- 1Run nvidia-smi directly on the host to verify the driver and NVML work outside Docker.
- 2Check /etc/nvidia-container-runtime/config.toml and regenerate CDI definitions if needed.
- 3Restart containerd/docker on a drained node and run a test nvidia-smi container.
How to prevent it
- Hold NVIDIA driver and toolkit packages against unattended upgrades on active GPU nodes
- Include nvidia-smi container smoke checks in node readiness probes
Save this diagnosis and catch the next crash automatically
All root cause, fix, and prevention steps above are free to read. Create a free account with any email or GitHub to keep your saved diagnosis history across the encyclopedia and run cloud checks, or use a work email below for the 30-day Team evaluation. No card required.
Or start a 30-day free Team trial (work email)
Verified work email unlocks all 14 fleet diagnostic tools, Slack alerts, and team history for 30 days. No card and no automatic charge.
Searchable error signature
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running prestart hook #0: exit status 1, stdout: , stderr: Auto-detected mode as 'legacy'
nvidia-container-cli: initialization error: nvml error: driver/library version mismatch: unknown.
Failed to initialize NVML: Unknown ErrorUse this text as a lookup key in logs and upstream issue trackers. It is not presented as a captured customer log. Confirm the cause from your own preceding events, versions, configuration and the cited references.
Diagnose your own log automatically
The root cause and fix steps above stay free. Create a free account to analyze full job logs, attribute the first failed rank, and keep saved incident history.
Sign up free. Analyze your cluster logsNo credit card. Daily allowance follows verified trust tier. Instant access.
Why the recommended fix works
Testing host nvidia-smi alongside nvidia-container-cli -k -d /dev/stderr info separates host kernel/library drift (which needs rebooting into the matching driver) from stale container runtime cgroup permissions or CDI config.
Code examples
nvidia-smi
cat /proc/driver/nvidia/version && modinfo -F version nvidia
sudo nvidia-container-cli -k -d /dev/stderr info
grep -n -E 'no-cgroups|ldconfig|mode' /etc/nvidia-container-runtime/config.tomlThis snippet illustrates the entry-specific check. Verify the installed versions, permissions, target and workload context before using it. A command or API example is not proof of recovery.
Best practices by model family
| Model / Stack | Recommendation | Notes |
|---|---|---|
| Host nvidia-smi works, container fails | Inspect config.toml, CDI spec, and restart containerd/docker | Resolves systemd cgroup BPF device drop. |
| Host nvidia-smi also fails | Fix host kernel/library NVML mismatch first | Containers inherit host NVML state. |
With the fix vs without the fix
| Dimension | With the fix | Without the fix |
|---|---|---|
| Container GPU injection | CDI / synced systemd cgroup permissions | Intermittent NVML unknown error after OS updates |
| Package hygiene | Pinned NVIDIA driver and toolkit versions | Unattended apt drift breaks live nodes |
Diagnostic note
“On Ubuntu systems with cgroups v2, running systemctl daemon-reload while containers hold GPU device permissions can silently break NVML inside long-lived pods or new exec shells unless CDI or no-cgroups is configured properly.”
Diagnose this failure in VS Code
Select the traceback or open the failed terminal, then run Denpex locally to inspect matched failure patterns, supporting evidence and next checks without uploading the log. Verify recommendations against your workload before changing production.
Install the free VS Code extensionFrequently asked questions
Questions engineers and on-call staff commonly ask about this failure.
Why does Failed to initialize NVML: Unknown Error start happening suddenly on a running server?
Should I set no-cgroups = true as a permanent fix?
Don't just read the fix, diagnose your run
The encyclopedia explains documented failure patterns. Denpex investigates your logs, configuration and stack, shows the supporting evidence, and asks for missing details when needed.