Skip to content

fix: conditionally force Mesa GLX to avoid breaking NVIDIA GPU passthrough#14

Open
NathanS-Git wants to merge 1 commit into
PufferAI:4.0from
NathanS-Git:mesa-fix
Open

fix: conditionally force Mesa GLX to avoid breaking NVIDIA GPU passthrough#14
NathanS-Git wants to merge 1 commit into
PufferAI:4.0from
NathanS-Git:mesa-fix

Conversation

@NathanS-Git
Copy link
Copy Markdown

@NathanS-Git NathanS-Git commented May 30, 2026

Commit dd662d8 ("rendering fix") added export __GLX_VENDOR_LIBRARY_NAME=mesa alongside the X11 auth fixes in docker.sh. I assume this commit was done, so on setups without NVIDIA GLX passthrough (CPU-only containers, or WSL2 where graphics bindings weren't fully working), it would fix the issue of GLFW/PufferLib not being able to create a window because libglvnd couldn't find a usable GLX vendor. Forcing Mesa makes those setups fall back to llvmpipe/Zink software rendering so puffer eval doesn't crash immediately.

This breaks normal linux runs (at least on my machine)
2026-05-29-223025_635x567_scrot
Yes, I know my emoji fonts are broken. No I'm not going to fix it.

When you run with --gpus all, the NVIDIA Container Runtime injects the proprietary NVIDIA OpenGL libraries into the container. Hard-coding __GLX_VENDOR_LIBRARY_NAME=mesa tells libglvnd to ignore those libraries and use Mesa instead. Mesa then probes the PCI device (10de:2783), realizes the GPU is NVIDIA, and tries to load the nvidia-drm DRI driver — which isn't shipped inside the container. It falls back to Zink (Vulkan), which fails with VK_ERROR_NATIVE_WINDOW_IN_USE_KHR, and you get the GLXBadCurrentWindow crash.

The conditional fix
Instead of forcing Mesa unconditionally, I'm suggesting we now only set it when the NVIDIA GLX library (libGLX_nvidia.so.0) is actually absent from the container. If it's present, we leave libglvnd alone so it can select the native NVIDIA vendor. We also respect an explicit user override (if you manually set __GLX_VENDOR_LIBRARY_NAME, we won't touch it).

This was a whole load of yapping, just to essentially say: don't always force Mesa for GLX, as this can cause breakages in situations where the system doesn't need/use Mesa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant