Nvidia-docker: Cannot connect to external X

Created on 6 Nov 2017  Â·  5Comments  Â·  Source: NVIDIA/nvidia-docker

Host is running an X server on :10 using the nvidia 384.90 driver on Ubuntu 16.04.3, and runs DISPLAY=:10 glxinfo just fine.

We've got nvidia-docker2 2.0.1+docker1 installed.

nvidia-docker run -it -e DISPLAY=:10 -v /tmp/.X11-unix:/tmp/.X11-unix nvidia/cuda:8.0-runtime-ubuntu16.04 bash -c 'apt-get update && apt-get install -y mesa-utils && glxinfo'

gives

name of display: :10
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  48
  Current serial number in output stream:  47

nvidia-docker run -it -e DISPLAY=:10 -v /tmp/.X11-unix:/tmp/.X11-unix nvidia/cuda:8.0-runtime-ubuntu16.04 bash -c 'apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y mesa-utils nvidia-384 lightdm- libcuda1-384- nvidia-opencl-icd-384- ; glxinfo '

gives the error

mv: cannot move '/usr/bin/nvidia-smi.dpkg-tmp' to '/usr/bin/nvidia-smi': Device or resource busy
update-alternatives: error: unable to install '/usr/bin/nvidia-smi.dpkg-tmp' as '/usr/bin/nvidia-smi': Device or resource busy
dpkg: error processing package nvidia-384 (--configure):
 subprocess installed post-installation script returned error exit status 2

on the apt-get install, but the glxinfo actually succeeds.

If I build the image on a machine that doesn't have nvidia-docker, and then try and run the image inside nVidia docker, I get the error:

docker: Error response from daemon: oci runtime error: container_linux.go:265: starting container process caused "process_linux.go:368: container init caused \"process_linux.go:351: running prestart hook 1 caused \\\"error running hook: exit status 1, stdout: , stderr: exec command: [/usr/bin/nvidia-container-cli --load-kmods configure --ldconfig=@/sbin/ldconfig.real --device=all --compute --utility --require=cuda>=8.0 --pid=99326 /var/lib/docker/devicemapper/mnt/f7bd60a0284900c7732b6076e0486cd5de6be65f30555396cfd432e9b1723d74/rootfs]\\\\nnvidia-container-cli: mount error: file creation failed: /var/lib/docker/devicemapper/mnt/f7bd60a0284900c7732b6076e0486cd5de6be65f30555396cfd432e9b1723d74/rootfs/usr/bin/nvidia-smi: too many levels of symbolic links\\\\n\\\"\"".
unsupported

Most helpful comment

If you install the driver inside the image, it won't be portable.
With nvidia-docker v2, we don't mount the graphics libraries from the driver by default, see:
https://github.com/nvidia/nvidia-container-runtime#nvidia_driver_capabilities

Try nvidia-docker run -e NVIDIA_DRIVER_CAPABILITIES=compute,utility,graphics

All 5 comments

I do not think you need to install Nvidia driver/library (nvidia-384) inside a container since corresponding library will be mounted as a volume from the native system thanks to the nvidia-docker wrapper tool.

ps: you might also need to enable everyone to access your X11 server (e.g. via xhost + )

see also #327

"I do not think you need to install Nvidia driver/library (nvidia-384) inside a container since corresponding library will be mounted as a volume from the native system thanks to the nvidia-docker wrapper tool."

As my first example shows, that gives me the error libGL error: No matching fbConfigs or visuals found libGL error: failed to load driver: swrast

I have X configured correctly, this works:

docker run -it -e DISPLAY=:10 -v /tmp/.X11-unix:/tmp/.X11-unix --privileged ubuntu:16.04 bash -c 'apt-get update && apt-get install -y mesa-utils nvidia-384 lightdm- libcuda1-384- nvidia-opencl-icd-384- && glxinfo'

But of course my app is more than glxinfo, it also needs to use CUDA. And the need for privileged mode is annoying too, avoiding that is one of the major reasons to use nvidia-docker.

If you install the driver inside the image, it won't be portable.
With nvidia-docker v2, we don't mount the graphics libraries from the driver by default, see:
https://github.com/nvidia/nvidia-container-runtime#nvidia_driver_capabilities

Try nvidia-docker run -e NVIDIA_DRIVER_CAPABILITIES=compute,utility,graphics

GLX is unsupported, and there is no plan to support it atm

Was this page helpful?
0 / 5 - 0 ratings