mirror of
https://github.com/games-on-whales/LXC2Docker.git
synced 2026-10-16 05:12:04 +00:00
[PR #76] [MERGED] feat(gpu): inject NVIDIA driver userspace into GPU containers #75
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
games-on-whales/LXC2Docker#75
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/games-on-whales/LXC2Docker/pull/76
Author: @JBailes
Created: 6/8/2026
Status: ✅ Merged
Merged: 6/14/2026
Merged by: @JBailes
Base:
main← Head:feat/nvidia-gpu-toolkit📝 Commits (2)
d5a3fccfeat(gpu): inject NVIDIA driver userspace into GPU containerse68a4eafix(gpu): tolerate nvidia-container-cli ldcache EPERM in the mount hook📊 Changes
4 files changed (+216 additions, -9 deletions)
View changed files
📝
Makefile(+3 -0)📝
internal/lxc/config.go(+53 -0)📝
internal/lxc/config_test.go(+53 -9)➕
packaging/nvidia-hook.sh(+107 -0)📄 Description
Problem
A container that requests the GPU the games-on-whales /
--gpusway — by settingNVIDIA_VISIBLE_DEVICES(which--gpus/composedeploy.devices[driver:nvidia]set alongside the libnvidia env) — only got the bound device nodes (/dev/dri,/dev/nvidia*). LXC2Docker has no notion of a GPU request:HostConfig.Runtimeis accepted but ignored, and there's noDeviceRequests, so the NVIDIA driver userspace (libcuda,libnvidia-encode,libEGL_nvidia,libGLX_nvidia, GLVND/EGL configs) was never injected.Result: the kernel render node opens, but CUDA/EGL init fails and GPU apps black-screen. Concretely with Wolf, the Wayland compositor panics:
Fix
When a container opts in (
NVIDIA_VISIBLE_DEVICESset, notvoid/empty), emit a singlelxc.hook.mountthat runsnvidia-container-cli configureagainst the freshly-mounted rootfs — the same mechanism Docker'snvidia-container-runtimeuses. Rather than hardcode a driver-version-specific file list, this defers to the NVIDIA container toolkit, which:ldconfigto create the SONAME symlinks,all matched to the running host driver, so it keeps working across driver upgrades with no daemon change.
The hook reads the device/capability selection back from the container's LXC config (defaulting to
all), mapsNVIDIA_DRIVER_CAPABILITIESto toolkit flags, and self-skips when the toolkit is absent or the selection isvoid— so it's a no-op on non-NVIDIA hosts and for containers that didn't ask for a GPU.Changes
internal/lxc/config.go:nvidiaGPUItems/nvidiaGPURequestedhelpers; emit the hook from bothbuildItems(raw LXC) andbuildPVEItems(Proxmox CT), right after the env block.packaging/nvidia-hook.sh: the mount hook (POSIXsh).Makefile: ship the hook at/usr/libexec/docker-lxc-daemon/nvidia-hook.shviainstallanddeb(+uninstallcleanup).internal/lxc/config_test.go: tests for opt-in (both builders) and no-hook-without-opt-in (incl. empty/void).Notes / scope
NVIDIA_VISIBLE_DEVICESbecause that env is present in every GOW NVIDIA form (docker run -e … --gpus, compose env, composedeploy.devices). Parsing DockerDeviceRequests/--gpusdirectly could be a follow-up for callers that set only--gpuswith no env.lxc.cgroup2.devices.allow: a); the hook passes--no-cgroupsand only touches the rootfs. An unprivileged path (emitting per-major cgroup allows) could be a follow-up.go test ./internal/...passes; hook validated withsh -n.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.