WSL: Mesa won't use dedicated GPU after WSL pre-release update

Windows Version

Microsoft Windows [Version 10.0.19045.3448]

WSL Version

2.0.0.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.123.1-1

Distro Version

Ubuntu 20.04

Other Software

~$ nvidia-smi
Wed Sep 20 12:09:03 2023
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.98.01              Driver Version: 536.99       CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 3070        On  | 00000000:01:00.0  On |                  N/A |
| 32%   41C    P0              47W / 240W |    756MiB /  8192MiB |      1%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+

Repro Steps

I updated to the WSL pre-release and it promptly stopped using my GPU in WSL apps, The GPU is still recognized by nvidia-smi as shown above, but not by glxinfo. I didn’t make this issue in the WSLg repo since this affects both WSLg and WSL + X server (I use a windows X server, VcXsrv).

Fixes tried (and failed):

Various environment variable permutations

None seemed to help. Here is the previously working configuration.

export DISPLAY="$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0"
export MESA_D3D12_DEFAULT_ADAPTER_NAME="NVIDIA"
export LIBGL_ALWAYS_INDIRECT=0
export LIBGL_ALWAYS_SOFTWARE=0

Disabling autoMemoryReclaim

I noticed in recent issues that autoMemoryReclaim seems to cause some issues, so I tried the dropcache and disable options to no avail. My current .wslconfig:

[wsl2]
memory=8GB
guiApplications=false

[experimental]
#autoMemoryReclaim=gradual
sparseVhd=true

Using WSLg

Setting guiApplications=true in .wslconfig had no affect on the issue.

Upgrading and downgrading Nvidia graphics drivers

I don’t recall my original driver version, but I both updated to the newest version (537.34) and rolled back to 536.99 (Aug 8, GPU was working for me last month).

Upgrading to Ubuntu 22.04

This + switching to the mesa packages from the oibaf/graphics-drivers ppa, no dice.

Trying a different computer

I updated two separate computers to the WSL pre-release (unfortunately, before I found this bug) and both have exhibited it in identical fashion. One of the computers has both an integrated Intel GPU and a dedicated Nvidia GPU, neither of which I could get Mesa to use. I understand that I may be able to use nvidia-prime to select a preferred device, but it seems that people for whom this solves their issue already have Mesa using one of their hardware devices, rather than being stuck on llvmpipe.

Expected Behavior

glxinfo -B shows an NVIDIA or Intel device under Extended renderer info and OpenGL renderer string rather than llvmpipe.

The dedicated GPU is used for GUI programs (WSLg or simply via X server).

Actual Behavior

~$ glxinfo -B
name of display: 172.19.16.1:0
display: 172.19.16.1:0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Mesa (0xffffffff)
    Device: llvmpipe (LLVM 15.0.7, 256 bits) (0xffffffff)
    Version: 23.1.7
    Accelerated: no
    Video memory: 7944MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.5
    Max compat profile version: 4.5
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
Memory info (GL_ATI_meminfo):
    VBO free memory - total: 0 MB, largest block: 0 MB
    VBO free aux. memory - total: 7542 MB, largest block: 7542 MB
    Texture free memory - total: 0 MB, largest block: 0 MB
    Texture free aux. memory - total: 7542 MB, largest block: 7542 MB
    Renderbuffer free memory - total: 0 MB, largest block: 0 MB
    Renderbuffer free aux. memory - total: 7542 MB, largest block: 7542 MB
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 0 MB
    Total available memory: 7944 MB
    Currently available dedicated video memory: 0 MB
OpenGL vendor string: Mesa
OpenGL renderer string: llvmpipe (LLVM 15.0.7, 256 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 23.1.7 - kisak-mesa PPA
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.5 (Compatibility Profile) Mesa 23.1.7 - kisak-mesa PPA
OpenGL shading language version string: 4.50
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 23.1.7 - kisak-mesa PPA
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

Diagnostic Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (7 by maintainers)

Most upvoted comments

@hideyukn88 I can only get my GPU to work correctly if I disable the MS packaged libraries by setting the (undocumented) wsl2.packagedGpuLibs = false option in my .wslconfig.