-
Notifications
You must be signed in to change notification settings - Fork 846
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
WSL2 + Docker + OpenGL + NVIDIA not working (uses llvmpipe) #7507
Comments
The team just posted some samples of containers with accelerated OpenGL. https://github.com/microsoft/wslg/tree/main/samples/container I think the most important was the env variable LD_LIBRARY_PATH=/usr/lib/wsl/lib |
@spronovo I've been testing accelerated OpenGL through containers in WSL2. I used your dockerfile's from commit ac6221b. These worked which is awesome! I also managed to get RViz and ROS (robotic operating system) working correctly minus one issue:
Any ideas why this may happen? |
Anyone tested RViz and meshes using accelerated OpenGL in WSL? |
This NVIDIA thread details others having the same issue whether inside a container or not |
Friendly ping to anyone who's had this problem and solved it? |
Similar problem here. Got WebGL to render with WSLg inside Firefox (not vcxsrv or x410). However, it seemed to use CPU rendering even when my GPU was detected as CPU load was high while FPS was low and laggy (tested with: https://webglsamples.org/aquarium/aquarium.html). I use multiple WSL2 distros on windows 11 (22000.348). Renderer string from Debian and Ubuntu: ❯ glxinfo | grep 'OpenGL renderer string'
OpenGL renderer string: D3D12 (NVIDIA GeForce GTX 1070) Renderer string from OpenSuse: ~> glxinfo | grep 'OpenGL renderer string'
OpenGL renderer string: Gallium 0.4 on llvmpipe (LLVM 3.8, 128 bits) Renderer string from Arch: ❯ glxinfo | grep 'OpenGL renderer string'
OpenGL renderer string: llvmpipe (LLVM 13.0.0, 256 bits) I have just tested again. Hardware accelerated worked for me but only if:
|
This is working the solution (for Ubuntu 22 the updated unofficial mesa-drivers are required). Also |
Referencing the OpenGL stuff from this NVIDIA OpenGL image and the Containers.md mentioned by other people here, I pieced this together. This is currently working on Windows 11 and Ubuntu 22.04 on WSL2. The last two lines on the Dockerfile was from WSLg GPU Selection Wiki. DockerfileFROM ubuntu:jammy
ARG DEBIAN_FRONTEND=noninteractive
SHELL ["/bin/bash", "-c"]
RUN apt-get update && apt-get -y upgrade && apt-get -y install \
libxext-dev \
libx11-dev \
libglvnd-dev \
libglx-dev \
libgl1-mesa-dev \
libgl1-mesa-glx \
libgl1-mesa-dri \
libegl1-mesa-dev \
libgles2-mesa-dev \
freeglut3-dev \
mesa-utils \
mesa-utils-extra \
&& apt-get -y autoremove \
&& apt-get clean
ENV LD_LIBRARY_PATH=/usr/lib/wsl/lib
ENV LIBVA_DRIVER_NAME=d3d12 Test Script#!/usr/bin/env bash
export MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA
docker run \
--device /dev/dxg \
--device /dev/dri/card0 \
--device /dev/dri/renderD128 \
--env DISPLAY=$DISPLAY \
--env WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
--env XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
--env PULSE_SERVER=$PULSE_SERVER \
--volume /tmp/.X11-unix:/tmp/.X11-unix \
--volume /mnt/wslg:/mnt/wslg \
--volume /usr/lib/wsl:/usr/lib/wsl \
wsl2-opengl:latest \
glxinfo | grep "OpenGL" Output
|
Hi, I've tried your dockerfile in wsl2: docker build --rm -t "wsl2-opengl:latest" . but I get an error: Error: unable to open display |
As it turns out I completely misunderstood the GPU selection. I have revised the answer. On the off chance that it still not work, there is a couple of things you can do: 1. Verify your WSL2 setup can actually spawn GUI appsuser@host:~$ sudo apt -y install mesa-utils
user@host:~$ glxgears You should see a window pops up with a set of colored gear spinning. 2. Verify that your NVIDIA GPU is being utilized for the correct
|
runing glxgears in wsl result on a windows pop-up with the gears, but the Intel GPU is used instead of Nvidia one. Is that right? |
Great! It means that the GPU is visible and should be able to be passed into the container, check internally from the container terminal that user@host:~$ glxinfo | grep "OpenGL"
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: Quadro P4000/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 535.113.01
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6.0 NVIDIA 535.113.01
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 535.113.01
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions: |
Windows Build Number
Microsoft Windows [Version 10.0.22000.194]
WSL Version
Kernel Version
5.10.60.1
Distro Version
Ubuntu 20.04
Other Software
Docker Desktop (Windows): 4.1.0 (69386)
Repro Steps
I am running ROS GUI applications like RViz and Gazebo through a docker container on WSL2. The OpenGL renderer is not selecting my NVIDIA GTX 1050 card and uses
llvmpipe
(CPU) instead.The OpenGL renderer does find my NVIDIA card outside of a docker container on WSL2 (on the host).
I have replicated the same issue after multiple reinstalls and using docker-ce instead of docker desktop.
On a native Ubuntu 20.04 boot, the containers OpenGL renderer is correctly set to my NVIDIA card.
ros-noetic
image.Ubuntu 20.04
installWSL2
glxgears
,glxinfo
andglmark2
NVIDIA_DRIVER_CAPABILITIES
is set toall
--gpus 'all,"capabilities=graphics"'
parametersExpected Behavior
RViz
,Gazebo
,glxgears
,glmark2
should all render with 3D hardware acceleration on the NVIDIA GPU.Actual Behavior
glxgears
,glxinfo
, orglmark2
work in "native" WSL2 using the NVIDIA cardglxgears
,glxinfo
, orglmark2
do NOT work (use the NVIDIA card) in a docker container when the host is WSL2Diagnostic Logs
No response
The text was updated successfully, but these errors were encountered: