microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.29k stars 814 forks source link

WSL2 cannot use Nvidia 3090 to run openGL #10245

Open sunshineharry opened 1 year ago

sunshineharry commented 1 year ago

Windows Version

Microsoft Windows [Version 10.0.22631.1906]

WSL Version

1.3.11.0

Are you using WSL 1 or WSL 2?

Kernel Version

5.15.90.2-microsoft-standard-WSL2

Distro Version

Ubuntu 18.04

Other Software

Repro Steps

I run the command

glxinfo | grep OpenGL

Expected Behavior

the renderer string and vendor string should be from Microsoft. Furthermore, Nvidia 3090 GPU should be used by Gezebo.

Actual Behavior

The output is as follows.

OpenGL vendor string: VMware, Inc. OpenGL renderer string: llvmpipe (LLVM 10.0.0, 256 bits) OpenGL core profile version string: 3.3 (Core Profile) Mesa 20.0.8 OpenGL core profile shading language version string: 3.30 OpenGL core profile context flags: (none) OpenGL core profile profile mask: core profile OpenGL core profile extensions: OpenGL version string: 3.1 Mesa 20.0.8 OpenGL shading language version string: 1.40 OpenGL context flags: (none) OpenGL extensions: OpenGL ES profile version string: OpenGL ES 3.1 Mesa 20.0.8 OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10 OpenGL ES profile extensions:

And the FPS in Gezebo is about 10. I can be seen that Gezebo does not use 3090 GPU

Diagnostic Logs

No response

sunshineharry commented 1 year ago

Further, I have run the command to updata OpenGL

sudo add-apt-repository ppa:kisak/kisak-mesa
sudo apt update && sudo apt upgrade
sunshineharry commented 1 year ago

Thank you for answering my question.

Well, I do the all things, but the vendor string is VMware, Inc.

The output of command glxinfo -B is as follows

name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: VMware, Inc. (0xffffffff)
    Device: llvmpipe (LLVM 10.0.0, 256 bits) (0xffffffff)
    Version: 20.0.8
    Accelerated: no
    Video memory: 47999MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 3.3
    Max compat profile version: 3.1
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.1
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: llvmpipe (LLVM 10.0.0, 256 bits)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 20.0.8
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 3.1 Mesa 20.0.8
OpenGL shading language version string: 1.40
OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.1 Mesa 20.0.8
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10

the output of nvidia-smi is as follows

Fri Jun 30 22:49:13 2023       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.54.06              Driver Version: 536.40       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 3090        On  | 00000000:73:00.0  On |                  N/A |
| 30%   41C    P8              27W / 350W |   1396MiB / 24576MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A        22      G   /Xwayland                                 N/A      |
+---------------------------------------------------------------------------------------+

What should I do to use 3090 GPU in WSL.

Thank you very much

Tele42 commented 1 year ago

The kisak-mesa "fresh" PPA doesn't provide packages for Ubuntu 18.04 anymore. Give https://launchpad.net/~kisak/+archive/ubuntu/turtle/ a try instead.

sunshineharry commented 1 year ago

I read this but i do not know what shou i do. Please note that i can only use ubuntu1804 owing to ROS melonic.

Thank you very much.

Tele42 commented 1 year ago

sudo add-apt-repository ppa:kisak/turtle is the key detail you probably skimmed past. That gets used instead of sudo add-apt-repository ppa:kisak/kisak-mesa in the troubleshooting steps you mentioned earlier. Then update/upgrade your system packages as usual and retest which mesa driver gets used with glxinfo.

elsaco commented 1 year ago

@sunshineharry on Bionic you need to upgrade your mesa packages from ppa:kisak/turtle. Sample output:

WSL Ubuntu-18.04 fresh install:

elsaco@bionic:~$ glxinfo -B | egrep 'Device|Mesa'
    Device: llvmpipe (LLVM 10.0.0, 128 bits) (0xffffffff)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 20.0.8
OpenGL version string: 3.1 Mesa 20.0.8
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 20.0.8

Notice how software rendering is used (llvmpipe).

And this is after mesa upgrade:

elsaco@bionic:~$ glxinfo -B | egrep 'Device|Mesa'
    Device: D3D12 (NVIDIA RTX A4000) (0xffffffff)
OpenGL core profile version string: 4.2 (Core Profile) Mesa 22.3.7 - kisak-mesa PPA
OpenGL version string: 4.2 (Compatibility Profile) Mesa 22.3.7 - kisak-mesa PPA
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 22.3.7 - kisak-mesa PPA

Now D3D12 GPU acceleration is correctly used. However, if you run glxinfo it will segfault. This is tracked already in other issue(s).

sunshineharry commented 1 year ago

Thank you all very much. The problem is solved perfercually!!!

wongsinglam commented 1 year ago

Hi,

My ubuntu is 22.04 I got 3090ti. But it seems D3d12 only uses intel core.

Device: D3D12 (Intel(R) UHD Graphics 770) (0xffffffff)

My question is how I can select my nvidia gpu?

wangtong0667 commented 7 months ago

Hi,

My ubuntu is 22.04 I got 3090ti. But it seems D3d12 only uses intel core.

Device: D3D12 (Intel(R) UHD Graphics 770) (0xffffffff)

My question is how I can select my nvidia gpu?

I have the same problem, do you have solved this?

carschandler commented 5 months ago

@wongsinglam @wangtong0667 Try MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA. See https://github.com/microsoft/wslg/wiki/GPU-selection-in-WSLg.