NVIDIA / nvidia-container-toolkit

Build and run containers leveraging NVIDIA GPUs
Apache License 2.0
2.3k stars 246 forks source link

OpenGL Docker NVidia Win10 - no OpenGL #262

Open j-p-e opened 2 years ago

j-p-e commented 2 years ago

1. Issue or feature description

Win10 docker - OpenGL container doesn't do OpenGL (but can run nvidia-smi and the cuda one can do cuda)

2. Steps to reproduce the issue

#have docker desktop 4.5.1 running on win10 10.0.19044 with WSL2 kernel 5.10.60.1 #on windows host : vcxsrv.exe -multiwindow -clipboard -ac -logfile "%TEMP%\log.txt" -logverbose 5 -screen 0 640x480@ docker run -it -e "DISPLAY=host.docker.internal:0" --privileged --gpus all -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all nvidia/cudagl:11.4.2-runtime-ubuntu20.04

# note same thing happens for opengl:1.2-glvnd-runtime-ubuntu20.04 (nominally built into the one above) # [some flags probably obsolete, I have been trying hundreds of combos from random internet pages] # [yes, I want to send display via a docker IP address - otherwise later on I can't get from gpu container to other containers on # same docker network due to docker host network limitations

# in the docker container created by docker run: nvidia-smi
# OK, can find NVidia-SMI 510.47.03 driver 511.65 Cuda 11.6 on Nvidia GeForce RTX 3080 Ti apt-get update && apt-get install mesa-utils glxinfo -B # Vendor is nvidia, but libGL is not working : libGL: MESA-LOADER: dlopen(/usr/lib/x86_64-linux-gnu/dri/swrast_dri.so) libGL: Can't open configuration file /etc/drirc: No such file or directory. libGL: Can't open configuration file /root/.drirc: No such file or directory. libGL: Can't open configuration file /etc/drirc: No such file or directory. libGL: Can't open configuration file /root/.drirc: No such file or directory. direct rendering: No libGL error: No matching fbConfigs or visuals found libGL error: failed to load driver: swrast OpenGL vendor string: NVIDIA Corporation OpenGL renderer string: NVIDIA GeForce RTX 3080 Ti/PCIe/SSE2 OpenGL version string: 1.4 (4.6.0 NVIDIA 511.65)

# If I run with LIBGL_ALWAYS_INDIRECT in the container I get even less (GPU continues to be visible to nvidia-smi but no # longer visible to glxinfo which defaults to llvmpipe), which sort of makes sense. If I run with -nowgl on the X server outside # the container I also lose visibility of the graphics card from glxinfo

# Expected result : # can use OpenGL from opengl:1.2-glvnd-runtime-ubuntu20.04 or nvidia/cudagl:11.4.2-runtime-ubuntu20.04

# What I actually want to do : # run unity within the container (all on the same actual machine as docker, vcxsrv, and the GPU itself), which I can do already # but only get CPU accel - but have GPU accel work, possibly using unity flags such as -force-opengl

# side note that might help ppl - an apt-get upgrade will kill even this setup so that glxinfo cannot find NVidia at all apt-get update && apt-get -qq upgrade glxinfo -B # Not OK Vendor is Mesa/X.org v12.2.6, Device llvmpipe, Accelerated: no

j-p-e commented 2 years ago

I appreciate this might not quite an nvidia-docker question as I'm using gpus -all - still not found the magic combo that works. Some other things I've tried :

If anyone from nvidia or anywhere else knows of a set of nvidia driver and X server combo that works with "docker run gpus -all" on a windows host to allow unity3D to accelerate within a linux docker container using a headless display (with or without coming up on the monitor connected to the windows host, it's a simulation so I don't care), please shout

j-p-e commented 2 years ago

Update - I have moved to docker-ce within WSL2, running a docker container via nvidia-docker-container with ocker run --gpus all -it --entrypoint /bin/bash --privileged --gpus all -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all

and

trying to get the nvidia driver rather than mesa in the docker container, here is an nvidia-container-toolkit.log from the WSL2 side

nvidia-container-toolkit.log

and glxinfo from inside the container (noting to get this I have to install mesa-utils) apt-get update && apt-get install mesa-utils && glxinfo -B

direct rendering: Yes Extended renderer info (GLX_MESA_query_renderer): Vendor: Mesa/X.org (0xffffffff) Device: llvmpipe (LLVM 13.0.0, 256 bits) (0xffffffff) Version: 22.0.0 Accelerated: no Video memory: 25601MB Unified memory: no 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 OpenGL vendor string: Mesa/X.org OpenGL renderer string: llvmpipe (LLVM 13.0.0, 256 bits) OpenGL core profile version string: 4.5 (Core Profile) Mesa 22.0.0 - 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 22.0.0 - 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 22.0.0 - kisak-mesa PPA OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

j-p-e commented 2 years ago

for completeness - glxinfo -B from WSL2 ubuntu

direct rendering: Yes Extended renderer info (GLX_MESA_query_renderer): Vendor: Microsoft Corporation (0xffffffff) Device: D3D12 (NVIDIA GeForce RTX 3080 Ti) (0xffffffff) Version: 21.2.6 Accelerated: yes Video memory: 28457MB 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.0 OpenGL vendor string: Microsoft Corporation OpenGL renderer string: D3D12 (NVIDIA GeForce RTX 3080 Ti) OpenGL core profile version string: 3.3 (Core Profile) Mesa 21.2.6 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 21.2.6 OpenGL shading language version string: 1.40 OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.0 Mesa 21.2.6 OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00

j-p-e commented 2 years ago

also nvidia-smi from inside container NVIDIA-SMI 510.60.02 Driver Version: 512.15 CUDA Version: 11.6

and in WSL2 NVIDIA-SMI 510.60.02 Driver Version: 512.15 CUDA Version: 11.6

j-p-e commented 2 years ago

and symlink setup

root@f6b9d21b568a:/# cd /usr/lib/x86_64-linux-gnu && ls -lA libGL* lrwxrwxrwx 1 root root 14 Nov 19 19:43 libGL.so.1 -> libGL.so.1.7.0 -rw-r--r-- 1 root root 538808 Nov 19 19:43 libGL.so.1.7.0 lrwxrwxrwx 1 root root 32 Mar 23 10:39 libGLESv1_CM_nvidia.so.1 -> libGLESv1_CM_nvidia.so.510.60.02 -rwxr-xr-x 1 root root 67880 Mar 22 21:53 libGLESv1_CM_nvidia.so.510.60.02 lrwxrwxrwx 1 root root 18 Nov 19 19:43 libGLESv2.so.2 -> libGLESv2.so.2.1.0 -rw-r--r-- 1 root root 63664 Nov 19 19:43 libGLESv2.so.2.1.0 lrwxrwxrwx 1 root root 29 Mar 23 10:39 libGLESv2_nvidia.so.2 -> libGLESv2_nvidia.so.510.60.02 -rwxr-xr-x 1 root root 117032 Mar 22 21:53 libGLESv2_nvidia.so.510.60.02 lrwxrwxrwx 1 root root 15 Nov 19 19:43 libGLX.so.0 -> libGLX.so.0.0.0 -rw-r--r-- 1 root root 133568 Nov 19 19:43 libGLX.so.0.0.0 lrwxrwxrwx 1 root root 16 Mar 10 20:56 libGLX_indirect.so.0 -> libGLX_mesa.so.0 lrwxrwxrwx 1 root root 20 Mar 10 20:56 libGLX_mesa.so.0 -> libGLX_mesa.so.0.0.0 -rw-r--r-- 1 root root 467608 Mar 10 20:56 libGLX_mesa.so.0.0.0 lrwxrwxrwx 1 root root 26 Mar 23 10:39 libGLX_nvidia.so.0 -> libGLX_nvidia.so.510.60.02 -rwxr-xr-x 1 root root 1293712 Mar 22 21:53 libGLX_nvidia.so.510.60.02 lrwxrwxrwx 1 root root 22 Nov 19 19:43 libGLdispatch.so.0 -> libGLdispatch.so.0.0.0 -rw-r--r-- 1 root root 710944 Nov 19 19:43 libGLdispatch.so.0.0.0

j-p-e commented 2 years ago

and am now launching vcsrv from WSL2 with

/mnt/c/program\ files/vcxsrv/vcxsrv.exe :1974 -listen tcp -retro -lesspointer -nowgl +iglx -multiwindow -clipboard -screen 0 '640x480' -ac +extension RANDR +extension RENDER +extension GLX +extension DOUBLE-BUFFER +extension DAMAGE +extension COMPOSITE -extension X-Resource -extension XTEST

j-p-e commented 2 years ago

and on WSL dpkg -l | grep libnvidia ii libnvidia-common-510 510.54-0ubuntu0.20.04.1 all Shared files used by the NVIDIA libraries ii libnvidia-compute-510:amd64 510.47.03-0ubuntu0.20.04.1 amd64 NVIDIA libcompute package ii libnvidia-container-tools 1.9.0-1 amd64 NVIDIA container runtime library (command-line tools) ii libnvidia-container1:amd64 1.9.0-1 amd64 NVIDIA container runtime library ii libnvidia-gl-510:amd64 510.54-0ubuntu0.20.04.1 amd64 NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD

lovesuiyue commented 2 years ago

Hello, have you installed The entire emulator yet?