fix: conditionally force Mesa GLX to avoid breaking NVIDIA GPU passthrough#14
Open
NathanS-Git wants to merge 1 commit into
Open
fix: conditionally force Mesa GLX to avoid breaking NVIDIA GPU passthrough#14NathanS-Git wants to merge 1 commit into
NathanS-Git wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit
dd662d8("rendering fix") addedexport __GLX_VENDOR_LIBRARY_NAME=mesaalongside the X11 auth fixes indocker.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 sopuffer evaldoesn't crash immediately.This breaks normal linux runs (at least on my machine)

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=mesatells 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 thenvidia-drmDRI driver — which isn't shipped inside the container. It falls back to Zink (Vulkan), which fails withVK_ERROR_NATIVE_WINDOW_IN_USE_KHR, and you get theGLXBadCurrentWindowcrash.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.