Skip to content

GPU Support

Hansehart edited this page Nov 11, 2026 · 2 revisions

NVIDIA GPU access requires the NVIDIA Container Toolkit on the Docker host.

(Host) Let the toolkit generate and refresh the CDI spec:

sudo systemctl enable --now nvidia-cdi-refresh.path nvidia-cdi-refresh.service

(Host) Confirm Docker sees the GPU, e.g. as nvidia.com/gpu=all:

docker info --format '{{json .DiscoveredDevices}}'

(Host) Add the cage's GPU reservation block, under deploy.resources:

nano .devcontainer/compose.yaml
reservations:
  devices:
    - driver: cdi
      device_ids:
        - nvidia.com/gpu=all
      capabilities: [gpu]

(VSCode) Then rebuild:

Dev Containers: Rebuild and Reopen in Container

See also: NVIDIA Container Toolkit, CDI support

WSL2
  1. (Windows) Install the NVIDIA GPU driver, which carries WSL2 support.

  2. (WSL) Install the Container Toolkit in the Linux guest.

  3. (WSL) Generate the CDI spec. With systemd enabled in the distro, the refresh units above handle this. Otherwise, generate it by hand, and again after each driver update:

    sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml
  4. Confirm the GPU shows up on each layer:

    nvidia-smi

Clone this wiki locally