Repository navigation
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.yamlreservations:
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
-
(Windows) Install the NVIDIA GPU driver, which carries WSL2 support.
-
(WSL) Install the Container Toolkit in the Linux guest.
-
(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
-
Confirm the GPU shows up on each layer:
nvidia-smi