Skip to content

0023: NVIDIA GPUs through the container toolkit and NVENC

Status: Proposed (my call, 2026-11-16)

Context

Only AMD and Intel GPUs work today: every container gets the GPU's /dev/dri nodes, and the server encodes with VAAPI. NVIDIA's proprietary driver has no VAAPI encoder, and its user-space libraries (Vulkan ICD, GBM, NVENC) must match the host's kernel module, so they cannot be baked into our images. Options: bake a driver into each image (breaks on every host driver update); the NVIDIA Container Toolkit, which injects the host's matching libraries and /dev/nvidia* when a container asks for the GPU (Docker DeviceRequests, compose deploy.resources.reservations.devices); nouveau (no reclocking on most cards, no encoder).

Decision

The toolkit. ./couchdogs setup reads the TV card's PCI vendor (0x10de is NVIDIA) and writes GPU_VENDOR to .env; for NVIDIA it also writes COMPOSE_FILE=compose.yml:compose.nvidia.yml, an override that asks for every NVIDIA GPU with the capabilities a screen, an app and an encoder need. The runner adds the same request to every container it starts with the GPU (apps with devices: [gpu], device screens, device shells). The /dev/dri nodes stay: Gamescope still opens the DRM card. The server picks hevc_nvenc / h264_nvenc when GPU_VENDOR=nvidia: the colour conversion runs on the CPU (libswscale, with the client's matrix and range) and NVENC takes NV12 from system memory, because Debian's FFmpeg has no CUDA scaler and the CPU path is the same in every build.

Consequences

The host needs NVIDIA's driver with nvidia-drm.modeset=1 (Gamescope's DRM backend) and the container toolkit; setup checks the modeset parameter and says what is missing, it installs nothing. The CPU conversion costs part of a core per 1080p60 stream. Nothing here was run on an NVIDIA GPU: tests cover the settings, the compose override and the runner's requests only. AMD and Intel installs are unchanged (no GPU_VENDOR, or amd / intel).