[PR #142] [MERGED] fix(nvidia): resolve driver libs in non-Debian GPU containers (LD_LIBRARY_PATH) #142

Closed
opened 2026-10-15 12:52:18 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/games-on-whales/LXC2Docker/pull/142
Author: @JBailes
Created: 7/5/2026
Status: ✅ Merged
Merged: 7/5/2026
Merged by: @JBailes

Base: main ← Head: fix/nvidia-ldcache-cross-distro


📝 Commits (3)

  • a4f4adf fix(nvidia): register driver lib dir in ldcache for non-Debian containers
  • 4895522 fix(nvidia): run the container's ldconfig (Fedora has no /sbin/ldconfig)
  • 6abe590 fix(nvidia): put the CDI lib dir on LD_LIBRARY_PATH for GPU containers

📊 Changes

3 files changed (+70 additions, -2 deletions)

View changed files

📝 internal/api/containers.go (+34 -0)
📝 internal/lxc/nvidia.go (+33 -2)
📝 internal/lxc/nvidia_test.go (+3 -0)

📄 Description

Symptom

GPU session containers on a Fedora/Arch base (e.g. GOW steam:fedora) crash to a black screen: libEGL warning: driver (null) / DRI2: failed to load driver, libnvidia-ml.so.1: cannot open shared object file, Could not initialize renderer → sway/Steam die. Ubuntu-based containers (Wolf itself) are unaffected — NVENC works — so only the game sessions break.

Cause

The CDI injects the driver libs into the host's multiarch dir /usr/lib/x86_64-linux-gnu. Debian/Ubuntu images search it; Fedora only searches /usr/lib64, so the mounted libs are invisible to its linker. And the daemon's ldcache-update runs as an lxc.hook.mount — before the lib bind-mounts land (and it would race the app anyway), so the cache never picks them up. Verified live: nvidia-smi in a steam:fedora GPU container fails without help and succeeds with LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu.

Fix

Three layers, most-reliable last:

  1. Register the driver-lib dirs via an /etc/ld.so.conf.d drop-in (so ldconfig indexes them on any distro).
  2. Run the container's own ldconfig via a distro-agnostic PATH (Fedora has /usr/bin/ldconfig, not /sbin/ldconfig).
  3. Prepend the CDI lib dir to LD_LIBRARY_PATH for GPU containers — checked before the cache, present from process start, timing- and distro-independent. This is what actually fixes it.

Verified live (pve .253, RTX 5080)

Steam:fedora sessions went from instant black-screen crash to launching with EGL/Vulkan initialized and the GPU passed through. go test ./... passes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/games-on-whales/LXC2Docker/pull/142 **Author:** [@JBailes](https://github.com/JBailes) **Created:** 7/5/2026 **Status:** ✅ Merged **Merged:** 7/5/2026 **Merged by:** [@JBailes](https://github.com/JBailes) **Base:** `main` ← **Head:** `fix/nvidia-ldcache-cross-distro` --- ### 📝 Commits (3) - [`a4f4adf`](https://github.com/games-on-whales/LXC2Docker/commit/a4f4adf10d331d1f9b93ab8e1e8f687c0c229ab6) fix(nvidia): register driver lib dir in ldcache for non-Debian containers - [`4895522`](https://github.com/games-on-whales/LXC2Docker/commit/4895522d97f852b25b982ff9082213e2b018aceb) fix(nvidia): run the container's ldconfig (Fedora has no /sbin/ldconfig) - [`6abe590`](https://github.com/games-on-whales/LXC2Docker/commit/6abe590be31dcda8a5a5fea17128b65ee0ff59b4) fix(nvidia): put the CDI lib dir on LD_LIBRARY_PATH for GPU containers ### 📊 Changes **3 files changed** (+70 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `internal/api/containers.go` (+34 -0) 📝 `internal/lxc/nvidia.go` (+33 -2) 📝 `internal/lxc/nvidia_test.go` (+3 -0) </details> ### 📄 Description ## Symptom GPU **session** containers on a Fedora/Arch base (e.g. GOW `steam:fedora`) crash to a black screen: `libEGL warning: driver (null)` / `DRI2: failed to load driver`, `libnvidia-ml.so.1: cannot open shared object file`, `Could not initialize renderer` → sway/Steam die. Ubuntu-based containers (Wolf itself) are unaffected — NVENC works — so only the game sessions break. ## Cause The CDI injects the driver libs into the host's multiarch dir `/usr/lib/x86_64-linux-gnu`. Debian/Ubuntu images search it; **Fedora only searches `/usr/lib64`**, so the mounted libs are invisible to its linker. And the daemon's ldcache-update runs as an `lxc.hook.mount` — **before** the lib bind-mounts land (and it would race the app anyway), so the cache never picks them up. Verified live: `nvidia-smi` in a `steam:fedora` GPU container fails without help and succeeds with `LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu`. ## Fix Three layers, most-reliable last: 1. Register the driver-lib dirs via an `/etc/ld.so.conf.d` drop-in (so `ldconfig` indexes them on any distro). 2. Run the container's own `ldconfig` via a distro-agnostic PATH (Fedora has `/usr/bin/ldconfig`, not `/sbin/ldconfig`). 3. **Prepend the CDI lib dir to `LD_LIBRARY_PATH` for GPU containers** — checked before the cache, present from process start, timing- and distro-independent. This is what actually fixes it. ## Verified live (pve .253, RTX 5080) Steam:fedora sessions went from instant black-screen crash to launching with EGL/Vulkan initialized and the GPU passed through. `go test ./...` passes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-15 12:52:18 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
games-on-whales/LXC2Docker#142
No description provided.