Skip to content

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.

Quick answer

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.
Environment#docker#nvidia-container-toolkit#nvml#kubernetes#systemd

What this failure is

nvidia-container-cli failed to initialize NVML inside a newly spawned container namespace despite GPU hardware existing on the host.

Live diagnosis, no signup

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.

training_logs.txt
No log to hand? Try one:

Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.

3 free cloud diagnoses per day

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.

SymptomPossible 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 errorStale 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 podStale 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

  1. 1Run nvidia-smi directly on the host to verify the driver and NVML work outside Docker.
  2. 2Check /etc/nvidia-container-runtime/config.toml and regenerate CDI definitions if needed.
  3. 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.

Use your company email, for example alex@yourcompany.com.

Who qualifies?

Company email domains activate the free 30-day Team evaluation (up to 50 diagnoses a day) after an email and domain check, whatever mail provider you use. If we cannot verify your domain automatically, support reviews it: write to support@denpex.com. Free local diagnosis in the editor extension needs no account.

Using a personal email (Gmail, Outlook, Naver, QQ) or solo cluster? Create a free $0 account (no work email required) to save 7-day history and unlock AI fallback, or send a cluster crash log for a live walkthrough.
Already have an account? Sign in

Searchable error signature

search key
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 Error

Use 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 logs

No 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

snippet
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.toml

This 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 / StackRecommendationNotes
Host nvidia-smi works, container failsInspect config.toml, CDI spec, and restart containerd/dockerResolves systemd cgroup BPF device drop.
Host nvidia-smi also failsFix host kernel/library NVML mismatch firstContainers inherit host NVML state.

With the fix vs without the fix

DimensionWith the fixWithout the fix
Container GPU injectionCDI / synced systemd cgroup permissionsIntermittent NVML unknown error after OS updates
Package hygienePinned NVIDIA driver and toolkit versionsUnattended 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 extension

Frequently 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?
Often an unattended systemd or unattended-upgrades run reloaded systemd cgroups or bumped libnvidia-ml libraries while containerd or nvidia.ko held stale state.
Should I set no-cgroups = true as a permanent fix?
Only follow NVIDIA Container Toolkit guidance for your exact Docker/containerd and CDI version; CDI mode is the modern standard avoiding legacy cgroup race conditions.

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.