Fix Docker Could Not Select Device Driver "" with Capabilities: [[gpu]]
When Docker Engine fails with could not select device driver "" with capabilities: [[gpu]], the host NVIDIA driver may already be active, but dockerd has no registered OCI runtime hook for GPU device injection. Use the 3-step remediation below to register nvidia-container-runtime and restore GPU passthrough.
Bottom Line Up Front (BLUF): 3-Step Fix
Estimated remediation time: 2 minutesExact daemon error signature:
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].If the host NVIDIA driver is already installed (verify with nvidia-smi) and nvidia-container-toolkit is present on the machine, run these three commands to register the runtime, reload the Docker daemon, and verify container GPU access:
# Step 1: Register the NVIDIA OCI runtime inside /etc/docker/daemon.json
sudo nvidia-ctk runtime configure --runtime=docker
# Step 2: Restart the Docker daemon so it loads the updated runtime table
sudo systemctl restart docker
# Step 3: Verify GPU passthrough inside an official CUDA base container
sudo docker run --rm --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smiIf nvidia-ctk is not found on your system, jump directly to OS-Specific Toolkit Installation Commands.
Try Denpex for 30 days. FREE.
No credit card. No automatic subscription. See whether Denpex helps with an incident you already understand.
Start your free 30-day Team evaluation
Up to 50 diagnoses a day for 30 days. Verify your work email to activate an eligible company evaluation, then replay a resolved incident and compare the evidence and next steps with your team's confirmed cause.
Root Causes Explained
When you pass --gpus all to the Docker CLI, Docker sends a device request to dockerd asking for a driver that advertises the [[gpu]] capability. The empty quotes "" in the error message indicate that Docker received a default GPU request without an explicit driver name and could not find any registered handler in its runtime table.
Unconfigured Docker daemon lacking nvidia-container-runtime registration
The host NVIDIA kernel module (nvidia.ko) and nvidia-smi work properly, but Docker Engine has no registered OCI runtime hook capable of satisfying the [[gpu]] capability request.
Failure Mechanism: Docker rejects every container launched with --gpus all or deploy.resources.reservations.devices before container creation begins.
Missing or corrupted /etc/docker/daemon.json
The /etc/docker/daemon.json file either does not exist, lacks the nvidia entry inside the runtimes dictionary, or was overwritten by a Docker Engine or cloud agent update.
Failure Mechanism: Docker falls back to the standard runc binary without the NVIDIA prestart hook, leaving device driver lookup empty ("").
Daemon not reloaded after package installation
Installing nvidia-container-toolkit via apt or dnf places binaries on disk at /usr/bin/nvidia-container-runtime, but does not automatically mutate daemon.json or restart dockerd.
Failure Mechanism: The running dockerd process continues using its cached in-memory runtime table until systemctl restart docker is executed.
Podman or Rootless Docker CDI requirements
Rootless Docker uses $HOME/.config/docker/daemon.json instead of /etc/docker/daemon.json, and Podman relies on Container Device Interface (CDI) YAML manifests under /etc/cdi/nvidia.yaml.
Failure Mechanism: System-level daemon.json changes are ignored by rootless user daemons, and Podman fails unless CDI specs are regenerated after driver upgrades.
OS-Specific NVIDIA Container Toolkit Installation
Before installing the container toolkit, verify that the host kernel driver is loaded by running nvidia-smi on the host machine. Once confirmed, run the repository setup and package installation commands for your Linux distribution.
1. Ubuntu 20.04 / 22.04 / 24.04 & Debian 11 / 12 (apt)
Package Manager: aptConfigure the official NVIDIA libnvidia-container GPG key and apt repository, install nvidia-container-toolkit, and register the runtime:
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker2. RHEL 9 / Rocky Linux 9 / AlmaLinux 9 (dnf)
Package Manager: dnfAdd the stable RPM repository definition to /etc/yum.repos.d/, refresh metadata, and configure Docker:
curl -s -L https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo | \
sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo
sudo dnf clean expire-cache
sudo dnf install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker3. Amazon Linux 2023 (EC2 G5, G6, P4d, P5 Instances)
AWS EC2 / dnfOn non-DLAMI Amazon Linux 2023 instances, add the NVIDIA libnvidia-container RPM repository, install the toolkit, and reload the Docker systemd unit:
curl -s -L https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo | \
sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo
sudo dnf install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart dockerComplete /etc/docker/daemon.json Configuration
Running sudo nvidia-ctk runtime configure --runtime=docker updates /etc/docker/daemon.json. If you manage configuration via Ansible, Terraform, cloud-init, or manual editing, inspect the file to verify it matches the structure below.
Standard Configuration (On-Demand via --gpus)
Registers the nvidia runtime while preserving runc as the default for non-GPU containers.
{
"runtimes": {
"nvidia": {
"args": [],
"path": "nvidia-container-runtime"
}
}
}Production Kubernetes / Default Runtime Configuration
Sets nvidia as the default runtime (useful for GPU build steps) and aligns cgroups with systemd.
{
"default-runtime": "nvidia",
"exec-opts": [
"native.cgroupdriver=systemd"
],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m",
"max-file": "3"
},
"runtimes": {
"nvidia": {
"args": [],
"path": "nvidia-container-runtime"
}
}
}Validate Daemon Registration Before Running Containers
After editing /etc/docker/daemon.json and running sudo systemctl restart docker, confirm that nvidia appears in the active runtime list:
$ docker info --format '{{json .Runtimes}}'
{"io.containerd.runc.v2":{"path":"runc"},"nvidia":{"path":"nvidia-container-runtime"},"runc":{"path":"runc"}}Podman and Rootless Docker CDI Configuration
If you run Rootless Docker or Podman, modifying /etc/docker/daemon.json alone will not resolve the device driver failure. Use Container Device Interface (CDI) or user-scoped daemon configs as shown below.
Rootless Docker Setup
Write the runtime entry to your user daemon configuration file and disable cgroup device restrictions in /etc/nvidia-container-runtime/config.toml:
nvidia-ctk runtime configure --runtime=docker \
--config=$HOME/.config/docker/daemon.json
sudo nvidia-ctk config --set nvidia-container-cli.no-cgroups --in-place
systemctl --user restart dockerPodman CDI Specification Setup
Generate the CDI YAML manifest so Podman (and CDI-enabled Docker daemons) can bind host GPU device nodes cleanly:
sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml
# Verify detected CDI devices
nvidia-ctk cdi list
# Run container with CDI device flag
podman run --rm --device nvidia.com/gpu=all \
nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smiVerification Using an Official CUDA Base Image
Test GPU device selection and library injection with a lightweight official NVIDIA CUDA base container. This image is under 100 MB and verifies that /dev/nvidia* nodes and libnvidia-ml.so are mounted inside the container namespace.
sudo docker run --rm --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smiExpected healthy output:
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.90.07 Driver Version: 550.90.07 CUDA Version: 12.4 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
|=========================================+========================+======================|
| 0 NVIDIA A100-SXM4-80GB On | 00000000:07:00.0 Off | 0 |
| N/A 34C P0 52W / 400W | 1MiB / 81920MiB | 0% Default |
+-----------------------------------------+------------------------+----------------------+Docker Compose GPU Reservation Syntax (compose.yaml)
If the error occurred during docker compose up, ensure your service specifies driver: nvidia and capabilities: [gpu]:
services:
inference-worker:
image: nvidia/cuda:12.4.1-base-ubuntu22.04
command: nvidia-smi
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]Frequently Asked Questions
Why does Docker say could not select device driver with capabilities gpu when nvidia-smi works on the host?
A working host nvidia-smi only confirms the kernel driver is loaded. Docker Engine still requires nvidia-container-toolkit to be installed, registered inside /etc/docker/daemon.json under the runtimes block, and loaded via a Docker daemon restart.
Do I still need nvidia-docker2 to fix the GPU device driver error?
No. The nvidia-docker2 wrapper package is deprecated. Install nvidia-container-toolkit and run sudo nvidia-ctk runtime configure --runtime=docker to register the NVIDIA runtime directly with Docker Engine 19.03 and newer.
How do I fix this GPU device driver failure in Rootless Docker or Podman?
Generate a Container Device Interface (CDI) specification using sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml. In Rootless Docker, also run nvidia-ctk runtime configure --runtime=docker --config=$HOME/.config/docker/daemon.json and restart the user service.
How do I enable GPU support in Docker Compose after fixing the runtime?
Inside your compose.yaml service definition, configure deploy.resources.reservations.devices with driver: nvidia, count: all, and capabilities: [gpu], then restart the compose stack.
Related GPU Diagnostic Tools & References
Denpex Engineering SuiteContinue debugging your GPU cluster, container logs, and VRAM budget with these interactive utilities:
GPU Log Analyzer
Paste container stderr, dmesg, or PyTorch tracebacks to pinpoint driver mismatches, Xid faults, and runtime startup failures.
/tools/gpu-log-analyzer
VRAM Calculator
Estimate exact GPU memory requirements for LLM weights, KV cache, activation buffers, and quantization formats before pulling images.
/tools/vram-calculator
NVIDIA Xid Error Reference
Look up NVIDIA kernel Xid fault codes from dmesg to distinguish container runtime misconfigurations from hardware or PCIe faults.
/xid
Denpex IDE Extensions
Install Denpex telemetry and log inspection tooling from OpenVSX to catch container and GPU anomalies directly in your editor.
/openvsx