Docker Container Can't See the GPU? NVIDIA Container Toolkit, Runtime & Driver Version Diagnosis Guide

Key takeaway
When the host sees the card but a Docker container cannot, the fault usually sits in the runtime chain, not the card. This guide explains how the NVIDIA Container Toolkit hands the GPU to a container, and works through six tests separating a missing runtime from a host driver fault, a missing flag, a version mismatch, or a WSL2 problem.
What this pattern actually looks like
This guide only applies when two conditions are both true at the same time. If either one is missing, the fault belongs to a different diagnosis path, and following the steps below will lead in the wrong direction.
First, the host can see the card, and the container cannot. On the host, `nvidia-smi` runs normally and shows the card, the driver version, and the CUDA version. On the same host, inside the container, `nvidia-smi` reports no device, or a program reports that CUDA is not available, or Docker reports `could not select device driver "" with capabilities: [[gpu]]`.
Second, the problem follows the container, not the card. The same card on the same host works when a program runs directly on the host, for example PyTorch, llama.cpp, or vLLM run without a container, and fails as soon as the same work moves inside a container.
These two conditions have to be separated from nearby faults, because the tests are different. If `nvidia-smi` fails on the host as well, the fault is at the host detection layer, where the driver is not installed properly or the card is not recognised. If the container can see the card but PyTorch reports an out-of-memory error, the fault is in the PyTorch allocator or the vLLM budget, and the container has already handed the card over successfully. If a virtual machine reports Code 43 during device passthrough, the fault is at the virtual machine passthrough layer. This guide is about the container runtime layer: the card is present, the driver is present, but the container cannot reach them.
The scope of this guide is deliberately narrow. It covers NVIDIA discrete graphics cards used through Docker only. Intel integrated graphics through the device files, AMD ROCm, LXC and Proxmox containers, and rootless Podman are all out of scope. Each of those has its own setup path, and the steps for an NVIDIA card through Docker should not be applied to them directly. Readers using those setups should follow the dedicated guide for their own runtime instead.
Why a container cannot see the GPU by default
A Docker container has no access to host devices by default. Even when `nvidia-smi` works on the host, the container must be explicitly granted access through the NVIDIA runtime. The NVIDIA Container Toolkit exists to make that grant. It registers a runtime called `nvidia` with Docker, and when a container starts with that runtime, the runtime bind-mounts the GPU device files and the CUDA libraries into the container. Without that runtime, there are no device files inside the container at all, and any program inside it will naturally report that no card exists.
The whole chain has five links, and the fault sits in whichever link is broken. The first link is the host driver: the NVIDIA driver must be installed on the host, and `nvidia-smi` must run there. If this link fails, the container cannot succeed. The second link is the toolkit installation: the NVIDIA Container Toolkit must be installed on the host, on a Linux host, or inside the WSL2 distribution when Docker Desktop runs through the WSL2 backend on Windows. The third link is the runtime registration: the Docker daemon configuration file, `/etc/docker/daemon.json`, must point at the `nvidia` runtime, and the Docker daemon must be restarted after the toolkit is installed. Restarting only the container does not register the runtime. The fourth link is the flag or Compose setting: every container start must explicitly request the GPU, either with `--gpus all` on the command line, or with the older `--runtime nvidia -e NVIDIA_VISIBLE_DEVICES=all`, or with a device reservation in a Compose file. The fifth link is the version match: the CUDA version inside the container must not be newer than the version the host driver supports. The driver sets the ceiling, and the CUDA toolkit version inside the container must respect it.
On Windows there is one more link: the WSL2 backend. Docker Desktop on Windows runs containers through the WSL2 backend, and GPU access follows NVIDIA's CUDA on WSL path. The driver is installed on Windows, and the CUDA toolkit is installed inside WSL. A Linux GPU driver must never be installed inside WSL itself; NVIDIA's own guide forbids it, and doing so breaks the whole chain. WSL2 GPU acceleration requires a Pascal architecture card or newer, running in WDDM mode. Quadro and Tesla cards in TCC mode are not supported. The NVIDIA documentation lists Container Toolkit version 2.6.0 as the minimum, with libnvidia-container 1.5.1 or newer, and states that both the command line and Docker Desktop are supported. Inside WSL2, `nvidia-smi` only offers a limited set of functions, so it should not be used to judge the full driver.
The five suspect layers
A container that cannot see the GPU has five possible layers. Only the first is the main subject of this guide; the other four must be separated out before any conclusion is drawn.
Layer 1: Toolkit and runtime — the container has no GPU runtime at all
Running `docker run --gpus all` returns `could not select device driver "" with capabilities: [[gpu]]`, or the container has no device files at all. The evidence is the two tests that check the runtime registration and compare the host and the container.
Layer 2: Host driver — the host itself cannot see the card
`nvidia-smi` fails on the host as well. This layer must be separated first, or a host driver fault will be misdiagnosed as a container fault. The separation is made by running the host check before touching any container setting.
Layer 3: Flags and Compose — the container was started without asking for the GPU
The toolkit is installed and the runtime is registered, but the container was started without the GPU flag, or the Compose file has no device reservation. The evidence is the flag comparison: adding the flag makes the same image work at once. This layer differs from the first: in the first layer the runtime does not exist at all, while in this layer the runtime exists but was not used for this particular container.
Layer 4: Version mismatch — the container CUDA version is newer than the host driver supports
The container can see the device, but a CUDA program reports no device detected, or the versions do not match. The evidence is the version comparison between the host driver and the container CUDA version. The fix is to change the image or the driver, not to reinstall the toolkit.
Layer 5: WSL2 backend — only on Windows, the WSL2 passthrough was never established
On Windows, `nvidia-smi.exe` works, but `nvidia-smi` inside WSL2 does not, or someone installed a Linux driver inside WSL and broke the chain. The separation is made by comparing Windows and WSL2 directly.
Six decisive tests
Each of these tests answers a different question, and none of them overlaps with the tests for other CUDA faults.
T1: Host comparison — does nvidia-smi work on the host
Outside any container, run the host `nvidia-smi` first: directly on a Linux host, or as `nvidia-smi.exe` on a Windows host. If it shows the card, the driver version, and the CUDA version, the host layer is confirmed, and the container tests can continue. If it fails on the host, stop. The fault belongs to the host detection layer, and no container setting should be changed. This ordering matters: if the host check does not work, the container cannot work either, so fixing the host comes first.
This test is new because no other guide in this series makes a host comparison the first step of a container diagnosis. The CUDA detection guide works through seven steps that are all at the application layer, and none of them touches a container.
T2: Inside and outside the container — the same command, working on the host and failing in the container
Run `docker run --rm --gpus all nvidia/cuda:12.x-base nvidia-smi`, choosing the image version to match what the host driver supports, rather than simply taking the newest image. If the host succeeds and the container reports no device, the fault is locked to the container runtime layer, and the diagnosis moves to the runtime and flag layers. If the container succeeds as well, the fault is not in the runtime. It sits in the individual program or image layer instead, for example a CPU-only PyTorch image that never uses the GPU however it is started.
This test is new because no other guide in this series uses a container image as a comparison tool. The cross-system comparison in the Windows-versus-Linux guide compares two operating systems, not a host and a container on the same machine.
T3: Runtime registration comparison — is the toolkit installed, does daemon.json point at the runtime, and was the daemon restarted
Check three things in turn. First, run `docker info | grep -i runtime` and look for the `nvidia` runtime in the list. Second, read `/etc/docker/daemon.json` and check whether the runtime setting points at `nvidia`. Third, run `nvidia-container-cli -k -d info` and check whether the toolkit recognises the graphics card components. If any one of the three fails, the fault is in the installation or registration layer. If all three pass but the container still cannot see the card, the diagnosis moves to the flag layer in T4. One more point belongs here: after installing the toolkit, the Docker daemon itself must be restarted. Restarting only the container does not make the runtime registration take effect.
This test is new because no other guide in this series mentions the daemon configuration file, the `docker info` runtime list, or the container toolkit command line tool. None of them teaches these three checks.
T4: Flag comparison — add the GPU request and see whether it works at once
Take the same image and the same command, and run it twice: once without any GPU flag, which is expected to fail, and once with `--gpus all`, or with the older `--runtime nvidia -e NVIDIA_VISIBLE_DEVICES=all`, and see whether it works at once. For Compose, compare a file without a device reservation under `deploy.resources.reservations.devices` with `capabilities: [gpu]`, against the same file with that section added. If adding the flag makes it work at once, the flag layer is confirmed: the problem was that the container was started without asking for the GPU, not that the toolkit was missing. If it still fails with the flag added, return to the runtime layer in T3.
This test is new because no other guide in this series mentions the `--gpus` flag, the `NVIDIA_VISIBLE_DEVICES` variable, or the Compose device reservation setting. The application guides deal with settings inside programs such as Blender or Premiere, not with container startup flags.
T5: Version comparison — host driver version against container CUDA version
Note the driver version and the highest CUDA version it supports from the top of the host `nvidia-smi` output. Then note the container CUDA version, from the container `nvidia-smi` output if the device is visible, or from the image tag. If the container CUDA version is newer than the host driver supports, the version mismatch layer is confirmed: change to an older CUDA image, or upgrade the host driver. If the two versions match and the container still fails, the fault is not a version problem, and the diagnosis returns to T3 and T4.
This test is new because the CUDA detection guide states the rule that the driver-provided CUDA version is the ceiling, but only at the application layer for local AI tools. No other guide compares the host driver version with the container image CUDA version. The published decision tree makes the same split: a container that sees the device but reports no device detected from CUDA points to a driver and CUDA version mismatch.
T6: WSL2 inside and outside comparison — only on Windows, Windows works and WSL2 does not
On Windows, run `nvidia-smi.exe`. If it works, the Windows driver layer is confirmed. Then run `nvidia-smi` inside the WSL2 distribution. If it fails there, the fault is in the WSL2 passthrough layer. Then check whether anyone installed a Linux GPU driver inside WSL: if so, that is what broke the chain, because the driver belongs on Windows only, and the CUDA toolkit belongs inside WSL. Two more facts belong here. Inside WSL2, `nvidia-smi` offers only a limited set of functions, so it should not be used to judge the full driver. And the WSL virtual machine by default takes only half of the Windows system memory, which is a system memory budget for large models running inside WSL2, not a VRAM limit, and the two should not be confused.
This test is new because no other guide in this series mentions WSL2 at all. The only appearance of WSL in the whole library is a single mention of a recording repair tool fetching a prebuilt version through WSL, which has nothing to do with GPU passthrough. The Linux live USB comparison in the cross-system guide does not touch WSL2 either.
Seven-step diagnosis flow
- Define the shape. Confirm that the host can see the card and the container cannot, or that the host cannot see it either, in which case the host detection path applies instead.
- Run the host comparison. Run the host `nvidia-smi` first, as in T1.
- Run the inside and outside comparison. Run `docker run --rm --gpus all nvidia/cuda:... nvidia-smi`, as in T2.
- Check the runtime registration. Check `docker info`, `daemon.json`, and `nvidia-container-cli`, and restart the Docker daemon after installing the toolkit, as in T3.
- Run the flag comparison. Add `--gpus all`, or the older runtime flag, or the Compose device reservation, and try again, as in T4.
- Run the version comparison. Compare the host driver version with the container CUDA version, as in T5.
- Run the WSL2 comparison, on Windows only. Compare Windows `nvidia-smi.exe` with WSL2 `nvidia-smi`, and check whether a Linux driver was wrongly installed inside WSL, as in T6.
Two ways to start a container, old and new
Two container startup methods appear in the guides, and they are not interchangeable. The modern method is the device request API: `docker run --gpus all`, which asks Docker for GPU devices directly. The older method is the runtime path: `--runtime nvidia -e NVIDIA_VISIBLE_DEVICES=all`, which starts the container with the NVIDIA runtime and tells it which devices are visible. Compose files use neither flag directly; they use a device reservation under `deploy.resources.reservations.devices`, with `capabilities: [gpu]`.
The older `nvidia-docker2` package belongs to the past and should not be confused with the current toolkit. It has no device reservation API, so it cannot be used with Compose version 3 or newer. The current tool is the NVIDIA Container Toolkit, and a guide that still tells a reader to install `nvidia-docker2` is out of date. Both startup methods should be described, with the new and old clearly separated, rather than presenting one of them as the only correct way.
What this is not: boundary cases
| Situation | Which path applies instead | Why it is not this guide |
|---|---|---|
| `nvidia-smi` fails on the host as well | CUDA device detection and host driver guides | The host detection layer, not the container layer |
| The container can see the card but PyTorch reports out of memory | PyTorch caching allocator guide | The PyTorch allocator layer; the container has already handed the card over |
| The container can see the card but vLLM fails to start or keeps preempting | vLLM KV cache budget guide | The vLLM engine budget layer; the container has already handed the card over |
| A virtual machine reports Code 43 during device passthrough | Virtual machine passthrough guide | Passthrough gives exclusive use of the hardware; a container shares the host driver |
| Windows fails but a Linux live USB works | Cross-system comparison guide | A cross-system comparison, not a host-versus-container comparison |
| Intel integrated graphics, AMD ROCm, LXC or Proxmox, rootless Podman | Dedicated guides for those runtimes | Out of scope: this guide covers NVIDIA discrete cards through Docker only |
| A program inside the container reports that the model is too large to fit | Capacity planning and vLLM budget guides | Planning and engine budget layers, not container visibility |
Five common misconceptions
- "nvidia-smi works on the host, so the container must work too." Wrong. A container has no access to host devices by default. The toolkit, the runtime registration, and the startup flag must all three be present before the card is handed to the container.
- "Installing a Linux driver inside the container or inside WSL will fix it." Wrong. The driver belongs on the host, on a Linux host, or on Windows for the WSL2 backend. Installing a Linux GPU driver inside WSL is forbidden by NVIDIA's own guide and breaks the whole chain.
- "Adding --gpus all guarantees the GPU will be used." Wrong. The image itself must also be a CUDA image. A CPU-only PyTorch image will still use the CPU even with the flag added. The image has to be checked as well as the flag.
- "After installing the toolkit, restarting the container is enough." Wrong. The Docker daemon itself must be restarted for the runtime registration to take effect. Restarting only the container does not register the runtime.
- "The newest CUDA version inside the container is always best." Wrong. If the container CUDA version is newer than the host driver supports, the container will report that no device was found. The version must match the host driver, not chase the newest release.
What to do next, and what not to do
If the six tests point to a missing runtime, the practical step is to record the three registration checks from T3, the exact command that was run, the image tag, the host driver version, and the container CUDA version, and then change one link at a time. Install the toolkit, restart the daemon, then try the flag comparison. Changing the image version, the flag, and the toolkit all at once destroys the diagnosis, because it becomes impossible to tell which change mattered.
Do not reinstall the driver inside the container or inside WSL in the hope that a fresh driver will fix a runtime problem. The driver does not belong there, and installing it there is the single most common way to break a chain that was otherwise close to working. Do not take the newest CUDA image by default; choose the image version that the host driver supports, and upgrade the host driver first if a newer image is genuinely needed. Do not treat a single percentage estimate from one guide as a fact about how often each cause occurs. Published estimates of how often the toolkit is the cause come from single sources without independent verification, so this guide describes the toolkit layer as the most common place to look, without quoting a number for it.
The honest limits of this guide should be stated plainly. Docker with a GPU was not run locally for this article, so the commands, the checking methods, and the error message wording come from NVIDIA's official documentation and three published practical guides, written between January and June 2026. Wording and defaults change between toolkit, Docker, and CUDA versions, so a reader should always trust the output of the version actually installed. The Windows Docker Desktop WSL2 backend settings, including the Docker Desktop version and the choice of WSL2 distribution, have not been independently verified here; only the broad principles confirmed by NVIDIA's documentation are stated, namely that the driver sits on Windows, the toolkit sits inside WSL, and no Linux driver should be installed inside WSL. The example image tag `nvidia/cuda:12.x-base` is a writing example, not a recommended version; a reader should choose the version that matches the host driver.
Repair pricing on this site follows the published three-tier fee structure of HK$400–2,800, with the final quote after inspection. A workshop inspection is what determines whether a fault sits in the card, the cooling, or the power delivery, and no fee can be fixed before that inspection.
HK GPU Fix is located at Dali Plaza, Room 1209, Shek Mun. The phone number is 2186 8010 and WhatsApp is 6558 6806. There is no Mong Kok shop and no on-site service; inspection and repair are carried out at the workshop.
FAQ
Q1: nvidia-smi works on the host, but the container says there is no device. Where do I start?
Start with the host comparison in T1, then run the inside-and-outside comparison in T2 with a known CUDA test image. If the host works and the container fails, the fault is locked to the container runtime layer. Then check the three registration items in T3: the `nvidia` runtime in `docker info`, the runtime setting in `/etc/docker/daemon.json`, and the toolkit check with `nvidia-container-cli`.
Q2: I installed the toolkit and restarted the container, but nothing changed. What did I miss?
Restarting the container is not enough. The Docker daemon itself must be restarted after the toolkit is installed, because only then does the runtime registration take effect. Restart the daemon, then run the T3 checks again, and then try the flag comparison in T4.
Q3: I added --gpus all, but the program still uses the CPU. Is the flag broken?
Not necessarily. The image itself must be a CUDA image. A CPU-only PyTorch image will still use the CPU even with the flag added, because the image has no CUDA libraries to use. Check the image tag and the program's own device report, and try the same flag with the `nvidia/cuda` test image from T2 to separate an image problem from a runtime problem.
Q4: The container can see the device, but CUDA reports no device detected. What does that mean?
That shape points to the version mismatch layer in T5, not to a missing runtime. Compare the host driver version and the highest CUDA version it supports with the CUDA version inside the container. If the container CUDA version is newer than the host driver supports, change to an older CUDA image or upgrade the host driver. If the versions match, return to T3 and T4.
Q5: On Windows, nvidia-smi.exe works but nvidia-smi inside WSL2 does not. What should I check?
Run the WSL2 comparison in T6. The driver belongs on Windows, and the CUDA toolkit belongs inside WSL. Check whether a Linux GPU driver was installed inside WSL: if it was, that is what broke the chain, and it must be removed. Also remember that `nvidia-smi` inside WSL2 offers only a limited set of functions, so a limited output there does not by itself prove the driver is broken.
Q6: Does this guide cover my Intel integrated graphics card, or AMD, or Podman?
No. This guide covers NVIDIA discrete graphics cards used through Docker only. Intel integrated graphics, AMD ROCm, LXC and Proxmox containers, and rootless Podman are out of scope, and each has its own setup path. Applying the NVIDIA Docker steps to those setups directly will not work, so readers using them should follow the dedicated guide for their own runtime.