Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL cannot load NVIDIA OpenGL. #1312

Open
haoran215 opened this issue Mar 15, 2025 · 1 comment
Open

WSL cannot load NVIDIA OpenGL. #1312

haoran215 opened this issue Mar 15, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@haoran215
Copy link

Windows build number:

10.0.26100.3476

Your Distribution version:

24.04

Your WSL versions:

1.When I try to use hardware acceleration, my WSL can't find file libnvidia-gl.so

~$ ls /usr/lib/wsl/lib | grep nvidia
libnvidia-encode.so
libnvidia-encode.so.1
libnvidia-ml.so.1
libnvidia-opticalflow.so
libnvidia-opticalflow.so.1
nvidia-smi

2.WSL is not using your NVIDIA GPU for OpenGL/Vulkan.
glxinfo | grep "OpenGL renderer" → Shows D3D12 (Intel UHD Graphics) instead of RTX 4060 and I can't change it manuly.
vulkaninfo | grep "GPU id" → Shows LLVM software renderer, meaning hardware acceleration is missing.

3.WSL does not have full NVIDIA library support:
nvidia-smi works, but only sees CUDA, not OpenGL.

4.Segmentation fault (core dumped) when running OpenGL apps:
glxgears crashes, meaning MESA+NVIDIA are not working together.

5.WSL may be using an outdated or incompatible driver:
WSL reports NVIDIA-SMI 570.124.03, but Windows reports 572.60.
Possible mismatch between Windows and WSL driver versions.

6.Vulkan driver is broken:
vulkaninfo | grep "GPU id" → "ERROR_INCOMPATIBLE_DRIVER"
Likely due to missing /usr/share/vulkan/icd.d/nvidia_icd.json.

Steps to reproduce:

  1. nvidia-smi in WSL

WSL logs:

wlog.log

WSL dumps:

No response

Expected behavior:

No response

Actual behavior:

WSL installation does not have the full NVIDIA driver stack for OpenGL and Vulkan.
missing libnvidia-gl.so, which is needed for OpenGL rendering.

NVIDIA GPU is detected (nvidia-smi works), but OpenGL is still using Intel GPU (D3D12).

Vulkan also fails with ERROR_INCOMPATIBLE_DRIVER, meaning WSL is not correctly using the NVIDIA driver.

@haoran215 haoran215 added the bug Something isn't working label Mar 15, 2025
@lzlrd
Copy link

lzlrd commented Mar 21, 2025

EDIT: See https://gist.github.com/lzlrd/0d9b757d2122f551794fd00c7f0752d6 as there are a few updates there (inc. fixing Wayland). I won't be updating the message below going forward.

So I got this working on both Ubuntu, and Arch. First, start with a fresh install (of archlinux from https://gitlab.archlinux.org/archlinux/archlinux-wsl or Ubuntu from wsl --install Ubuntu or https://apps.microsoft.com/detail/9pdxgncfsczv).

For Arch:

  1. Clone https://aur.archlinux.org/packages/directx-headers-git and https://aur.archlinux.org/packages/mesa-wsl2-git.
  2. Build directx-headers-git using makepkg -rsi. You may need to set up as per https://wiki.archlinux.org/title/Makepkg.
  3. cd into mesa-wsl2-git.
  4. Edit PKGBUILD to remove all instances of =18.1.8.
  5. Build mesa-wsl2-git using makepkg -rsi.
  6. Run echo "export GALLIUM_DRIVER=d3d12" | sudo tee /etc/profile.d/wslg.sh.
  7. Run echo "L+ /tmp/.X11-unix - - - - /mnt/wslg/.X11-unix" | sudo tee /etc/tmpfiles.d/wslg.conf. (Thanks to Init /tmp/.X11-unix is overwritten by mounts #43 (comment) for this.)
  8. Restart WSL with wsl --shutdown from CMD/PowerShell and you should see the following (given you install the relevant packages):
$ glxinfo | grep Device
    Device: D3D12 (NVIDIA GeForce RTX 4080 SUPER) (0xffffffff)

$ vulkaninfo | grep "GPU id"
WARNING: dzn is not a conformant Vulkan implementation, testing use only.
                GPU id = 0 (Microsoft Direct3D12 (NVIDIA GeForce RTX 4080 SUPER))
                GPU id = 1 (llvmpipe (LLVM 19.1.7, 256 bits))
                GPU id = 0 (Microsoft Direct3D12 (NVIDIA GeForce RTX 4080 SUPER))
                GPU id = 1 (llvmpipe (LLVM 19.1.7, 256 bits))
                GPU id = 0 (Microsoft Direct3D12 (NVIDIA GeForce RTX 4080 SUPER))
                GPU id = 1 (llvmpipe (LLVM 19.1.7, 256 bits))
GPU id : 0 (Microsoft Direct3D12 (NVIDIA GeForce RTX 4080 SUPER)):
GPU id : 1 (llvmpipe (LLVM 19.1.7, 256 bits)):

For Ubuntu:

  1. OpenGL should already be working. We'll add Vulkan support.
  2. Go to https://ppa.launchpadcontent.net/kisak/kisak-mesa/ubuntu/pool/main/m/mesa/.
  3. Look for mesa-vulkan-drivers_*.deb.
  4. You'll see ...<LETTER>_<ARCH>.deb. The letter corresponds to your Ubuntu version codename. In your case, "n" for Noble.
  5. Copy the link for the right package, https://ppa.launchpadcontent.net/kisak/kisak-mesa/ubuntu/pool/main/m/mesa/mesa-vulkan-drivers_25.0.1~kisak1~n_amd64.deb in your case.
  6. Run wget https://ppa.launchpadcontent.net/kisak/kisak-mesa/ubuntu/pool/main/m/mesa/mesa-vulkan-drivers_25.0.1~kisak1~n_amd64.deb anywhere you have write access to on the Ubuntu WSL instance.
  7. Run sudo apt install <PACKAGE> (in your case, sudo apt install mesa-vulkan-drivers_25.0.1~kisak1~n_amd64.deb.
  8. You should see the following (given you install mesa-utils and vulkan-tools):
$ glxinfo | grep Device
WARNING: dzn is not a conformant Vulkan implementation, testing use only.
WARNING: Some incorrect rendering might occur because the selected Vulkan device (Microsoft Direct3D12 (NVIDIA GeForce RTX 4080 SUPER)) doesn't support base Zink requirements: feats.features.logicOp have_EXT_custom_border_color have_EXT_line_rasterization
    Device: D3D12 (NVIDIA GeForce RTX 4080 SUPER) (0xffffffff)

$ vulkaninfo | grep "GPU id"
WARNING: dzn is not a conformant Vulkan implementation, testing use only.
                GPU id = 0 (Microsoft Direct3D12 (NVIDIA GeForce RTX 4080 SUPER))
                GPU id = 1 (llvmpipe (LLVM 19.1.7, 256 bits))
                GPU id = 0 (Microsoft Direct3D12 (NVIDIA GeForce RTX 4080 SUPER))
                GPU id = 1 (llvmpipe (LLVM 19.1.7, 256 bits))
                GPU id = 0 (Microsoft Direct3D12 (NVIDIA GeForce RTX 4080 SUPER))
                GPU id = 1 (llvmpipe (LLVM 19.1.7, 256 bits))
GPU id : 0 (Microsoft Direct3D12 (NVIDIA GeForce RTX 4080 SUPER)):
GPU id : 1 (llvmpipe (LLVM 19.1.7, 256 bits)):

The reason we're using just the Vulkan driver from Kisak's repo. is that the mesa package causes llvmpipe to be used instead of D3D12. Maybe overring GALLIUM_DRIVER would work - I didn't try.

Update: Documented at https://gist.github.com/lzlrd/0d9b757d2122f551794fd00c7f0752d6, as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants