Glxgears error, Docker, CUDA, VirtualGL

Hello,

when I run glxgears, I get following error.

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Error: couldn't get an RGB, Double-buffered visual

My system is ubuntu 16.04 as docker image - nvidia/cuda:8.0-runtime-ubuntu16.04.

The image contains VirtualGL and TurboVNC and its is started with the following parameters:

docker run --runtime=nvidia --privileged -d -v /tmp/.X11-unix/X0:/tmp/.X11-unix/X0 -e USE_DISPLAY="7" my_image

There is no problem if I change the base image to nvidia/cuda:10.2-runtime-ubuntu18.04. But an application for which this container is, needs CUDA 8.

I found some advice to remove library: sudo rm /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1. But it does not work.

Ubuntu 16.04, CUDA 8:

user@host:/opt/noVNC$ sudo ldconfig -p | grep -i libGL.so
    libGL.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
    libGL.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libGL.so
    libGL.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/mesa/libGL.so
user@host:/usr/lib/x86_64-linux-gnu$ ll libGL*
    lrwxrwxrwx 1 root root      13 Jun 14  2018 libGL.so -> mesa/libGL.so
    lrwxrwxrwx 1 root root      32 May 25 14:14 libGLESv1_CM_nvidia.so.1 -> libGLESv1_CM_nvidia.so.440.33.01
    -rw-r--r-- 1 root root   63696 Nov 12  2019 libGLESv1_CM_nvidia.so.440.33.01
    lrwxrwxrwx 1 root root      29 May 25 14:14 libGLESv2_nvidia.so.2 -> libGLESv2_nvidia.so.440.33.01
    -rw-r--r-- 1 root root  111416 Nov 12  2019 libGLESv2_nvidia.so.440.33.01
    -rw-r--r-- 1 root root  911218 Oct 23  2015 libGLU.a
    lrwxrwxrwx 1 root root      15 Oct 23  2015 libGLU.so -> libGLU.so.1.3.1
    lrwxrwxrwx 1 root root      15 Oct 23  2015 libGLU.so.1 -> libGLU.so.1.3.1
    -rw-r--r-- 1 root root  453352 Oct 23  2015 libGLU.so.1.3.1
    lrwxrwxrwx 1 root root      26 May 25 14:14 libGLX_indirect.so.0 -> libGLX_nvidia.so.440.33.01
    lrwxrwxrwx 1 root root      26 May 25 14:14 libGLX_nvidia.so.0 -> libGLX_nvidia.so.440.33.01
    -rw-r--r-- 1 root root 1114496 Nov 12  2019 libGLX_nvidia.so.440.33.01
user@host:/usr/lib/x86_64-linux-gnu$ ll mesa
    -rw-r--r-- 1 root root     31 Jun 14  2018 ld.so.conf
    lrwxrwxrwx 1 root root     14 Jun 14  2018 libGL.so -> libGL.so.1.2.0
    lrwxrwxrwx 1 root root     14 Jun 14  2018 libGL.so.1 -> libGL.so.1.2.0
    -rw-r--r-- 1 root root 471680 Jun 14  2018 libGL.so.1.2.0

Ubuntu 18.04, CUDA 10:

user@host:/opt/noVNC$ sudo ldconfig -p | grep -i libGL.so
    libGL.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libGL.so.1
user@host:/usr/lib/x86_64-linux-gnu$ ll libGL*
    lrwxrwxrwx 1 root root      14 May 10  2019 libGL.so.1 -> libGL.so.1.0.0
    -rw-r--r-- 1 root root  567624 May 10  2019 libGL.so.1.0.0
    lrwxrwxrwx 1 root root      32 May 20 16:43 libGLESv1_CM_nvidia.so.1 -> libGLESv1_CM_nvidia.so.440.33.01
    -rw-r--r-- 1 root root   63696 Nov 12  2019 libGLESv1_CM_nvidia.so.440.33.01
    lrwxrwxrwx 1 root root      29 May 20 16:43 libGLESv2_nvidia.so.2 -> libGLESv2_nvidia.so.440.33.01
    -rw-r--r-- 1 root root  111416 Nov 12  2019 libGLESv2_nvidia.so.440.33.01
    lrwxrwxrwx 1 root root      15 May 21  2016 libGLU.so.1 -> libGLU.so.1.3.1
    -rw-r--r-- 1 root root  453352 May 21  2016 libGLU.so.1.3.1
    lrwxrwxrwx 1 root root      15 May 10  2019 libGLX.so.0 -> libGLX.so.0.0.0
    -rw-r--r-- 1 root root   68144 May 10  2019 libGLX.so.0.0.0
    lrwxrwxrwx 1 root root      16 Feb 19 05:09 libGLX_indirect.so.0 -> libGLX_mesa.so.0
    lrwxrwxrwx 1 root root      20 Feb 19 05:09 libGLX_mesa.so.0 -> libGLX_mesa.so.0.0.0
    -rw-r--r-- 1 root root  488344 Feb 19 05:09 libGLX_mesa.so.0.0.0
    lrwxrwxrwx 1 root root      26 May 20 16:43 libGLX_nvidia.so.0 -> libGLX_nvidia.so.440.33.01
    -rw-r--r-- 1 root root 1114496 Nov 12  2019 libGLX_nvidia.so.440.33.01
    lrwxrwxrwx 1 root root      22 May 10  2019 libGLdispatch.so.0 -> libGLdispatch.so.0.0.0
    -rw-r--r-- 1 root root  612792 May 10  2019 libGLdispatch.so.0.0.0
user@host:/usr/lib/x86_64-linux-gnu$ ll mesa
    ls: cannot access 'mesa': No such file or directory

The host has CUDA 10.2 but I do not know if it is required and can cause a problem.

I have no idea how to solve this problem.

Thank you for any advice.

The solution is to replace nvidia/cuda:8.0-runtime-ubuntu16.04 image with nvidia/opengl:1.0-glvnd-runtime-ubuntu16.04 and install CUDA 8 manually.

CUDA 8 installation:

Do not forget to add display to nvidia capabilities var:

ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,display

https://hub.docker.com/r/nvidia/opengl