How to fix Error response from daemon: Unknown runtime specified nvidia in Docker
This error occurs when Docker cannot find the NVIDIA container runtime. It typically means the nvidia-container-toolkit is not installed, Docker's daemon.json is not configured correctly, or Docker needs to be restarted after installation.
Quick fix
Fixes Error response from daemon: Unknown runtime specified nvidia
docker info | grep -i runtime- Check if NVIDIA runtime is available
- Install the NVIDIA Container Toolkit
- Configure Docker to use the NVIDIA runtime
- Restart the Docker daemon
docker info | grep -i runtimeError response from daemon: Unknown runtime specified nvidia
What this error means
When you try to run a Docker container with `--runtime=nvidia` or use GPU acceleration, Docker looks for the NVIDIA runtime in its configuration. This runtime acts as a bridge between Docker and your NVIDIA GPU drivers, allowing containers to access GPU resources. The "Unknown runtime specified nvidia" error indicates that Docker doesn't recognize "nvidia" as a valid runtime. This happens because: 1. The NVIDIA Container Toolkit (which includes `nvidia-container-runtime`) is not installed 2. Docker's daemon.json configuration doesn't include the nvidia runtime entry 3. Docker daemon hasn't been restarted after installing the toolkit 4. The runtime binary path is incorrect in the configuration
Typical symptoms
- Running containers with --runtime=nvidia fails immediately
- Docker Compose files with 'runtime: nvidia' fail to start services
- GPU-accelerated containers (CUDA, TensorFlow GPU) won't launch
- Error message appears before container creation begins
- The same container runs fine without the --runtime=nvidia flag
Common causes
- nvidia-container-toolkit is not installed on the host system
- Docker daemon.json is missing the nvidia runtime configuration
- Docker daemon was not restarted after installing the toolkit
- Using --runtime=nvidia on Docker 19.03+ instead of --gpus flag
- nvidia-container-runtime binary is not in the expected path
- Conflicting Docker runtime configurations
How to fix "Error response from daemon: Unknown runtime specified nvidia"
First, verify what runtimes Docker currently knows about:
docker info | grep -i runtimeIf you see only Runtimes: runc (without nvidia), the NVIDIA runtime is not configured. If nvidia is listed but still failing, the configuration may be incorrect.
Install the NVIDIA Container Toolkit which provides the nvidia-container-runtime:
For Ubuntu/Debian:
# Add the NVIDIA GPG key
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
# Add the repository
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
# Install the toolkit
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkitFor RHEL/CentOS:
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 yum install -y nvidia-container-toolkitUse the nvidia-ctk tool to automatically configure Docker:
sudo nvidia-ctk runtime configure --runtime=dockerThis command modifies /etc/docker/daemon.json to include the nvidia runtime. You can verify the configuration:
cat /etc/docker/daemon.jsonYou should see something like:
{
"runtimes": {
"nvidia": {
"path": "/usr/bin/nvidia-container-runtime",
"runtimeArgs": []
}
}
}Apply the configuration changes by restarting Docker:
sudo systemctl restart dockerAlternatively, you can send a SIGHUP signal:
sudo pkill -SIGHUP dockerdVerify the runtime is now available:
docker info | grep -i runtime
# Should show: Runtimes: nvidia runcVerify everything works by running a test container:
# Using the new --gpus flag (recommended for Docker 19.03+)
docker run --rm --gpus all nvidia/cuda:12.0-base nvidia-smi
# Or using the legacy --runtime=nvidia flag
docker run --rm --runtime=nvidia nvidia/cuda:12.0-base nvidia-smiYou should see the output of nvidia-smi showing your GPU(s).
Advanced notes
## Using --gpus instead of --runtime=nvidia
Starting with Docker 19.03, the recommended approach is to use --gpus instead of --runtime=nvidia:
# Access all GPUs
docker run --gpus all nvidia/cuda:12.0-base nvidia-smi
# Access specific GPUs by index
docker run --gpus '"device=0,1"' nvidia/cuda:12.0-base nvidia-smi
# Access specific GPU by UUID
docker run --gpus '"device=GPU-xxxxx"' nvidia/cuda:12.0-base nvidia-smiThe --gpus flag works even without the runtimes section in daemon.json, as long as the nvidia-container-toolkit is installed.
## Docker Compose Configuration
For Docker Compose (version 2.x or later), use the deploy section:
services:
gpu-service:
image: nvidia/cuda:12.0-base
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]## WSL2 Considerations
On Windows with WSL2, the NVIDIA drivers are installed on the Windows side, but you still need the nvidia-container-toolkit inside WSL:
# In WSL2, verify NVIDIA driver is accessible
nvidia-smi
# Then install the toolkit as normal
sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker## Troubleshooting Tips
- If nvidia-container-runtime is not found, verify installation: which nvidia-container-runtime
- Check for conflicting configurations in ~/.docker/daemon.json vs /etc/docker/daemon.json
- On some systems, you may need to enable the nvidia-persistenced service
Frequently asked questions
- What does "Error response from daemon: Unknown runtime specified nvidia" mean?
- When you try to run a Docker container with --runtime=nvidia or use GPU acceleration, Docker looks for the NVIDIA runtime in its configuration. This runtime acts as a bridge between Docker and your NVIDIA GPU drivers, allowing containers to access GPU resources. The "Unknown runtime specified nvidia" error indicates that Docker doesn't recognize "nvidia" as a valid runtime.
- How do I fix "Error response from daemon: Unknown runtime specified nvidia"?
- This error occurs when Docker cannot find the NVIDIA container runtime. It typically means the nvidia-container-toolkit is not installed, Docker's daemon.json is not configured correctly, or Docker needs to be restarted after installation.
- What causes "Error response from daemon: Unknown runtime specified nvidia"?
- nvidia-container-toolkit is not installed on the host system Docker daemon.json is missing the nvidia runtime configuration Docker daemon was not restarted after installing the toolkit
- Is the "Error response from daemon: Unknown runtime specified nvidia" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐Docker Official Documentation
- ๐ฌStack Overflow: Unknown runtime specified nvidia(Stack Overflow)
- ๐
- ๐NVIDIA Container Toolkit Installation Guide(Official Docs)
- ๐ฌNVIDIA Forums: Docker nvidia runtime error(Stack Overflow)