Which command quickly proves that GPUs work in Docker?
Why D is the answer
docker run --rm --gpus all <image> nvidia-smi
The container should list the host's GPUs.
In detail
- The container should list the host's GPUs.
- The toolkit mounts nvidia-smi from the host, so even a plain ubuntu image works.
Use case
An illustrative scenario, not a real incident.
A quick run of nvidia-smi inside a container lists the host's GPUs, which proves that it works.
See it in different ways
flowchart TD A["NVIDIA driver on the host"] --> B["NVIDIA Container Toolkit"] B --> C["Docker runtime configured"] C --> D["docker run with --gpus"]
sequenceDiagram participant D as Host driver participant T as Container Toolkit participant C as Docker D->>T: Exposes the GPUs T->>C: Configures the runtime C->>C: docker run with --gpus all
sequenceDiagram participant P0 as Docker participant P1 as Container participant P2 as Host GPUs P0->>P1: Run with all GPUs P1->>P2: nvidia-smi P2-->>P1: GPU list
Key point: Run nvidia-smi inside a container.
Why the other options are wrong
- A. docker ps --filter status=exited
- That lists stopped containers.
- B. docker network ls
- That lists networks.
- C. docker system prune --all
- That deletes data.

