Westranger
Westranger

Reputation: 1367

GLXGears not working inside of Docker

I'm trying to get the nvidia hardware acceleration running inside of a Docker container. So far I hat no success. When running glxgears I get the following error.

root@fea7a51ac757:/# glxgears
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  35
  Current serial number in output stream:  37

My docker file looks like this

FROM osrf/ros:lunar-desktop-full
# nvidia-docker hooks
LABEL com.nvidia.volumes.needed="nvidia_driver"
ENV PATH /usr/local/nvidia/bin:${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:${LD_LIBRARY_PATH}

EXPOSE 11311
EXPOSE 11345

And I started the container with

nvidia-docker run -it  --volume=/tmp/.X11-unix:/tmp/.X11-unix   --device=/dev/dri:/dev/dri   --env="DISPLAY"   my-custom-image

I currently I don't know that the nvidia-driver inside of the container needs to have the same version. but I don't know how to check this of if this is even the problem.

nvidia-smi says

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.90                 Driver Version: 384.90                    |
|-------------------------------+----------------------+----------------------+

I used this as an guide to solve the problem without any success

Upvotes: 7

Views: 9104

Answers (1)

Corey
Corey

Reputation: 96

Which NVIDIA docker version are you using?

I ask because up until a month ago, there was no OpenGL support in the newer 2.0 version. Last month they made a dockerfile that has OpenGL on it as a base image.

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

GLX gears should work out of the ubuntu repository (mesa utils) in the container assuming you have the NVIDIA drivers installed on your host and you you pass the x11 display arguments/bindmounts when your run the image. This is what I had in my dockerfile.

https://github.com/coreyryanhanson/dockerfiles/blob/master/glxgears/ubuntu16%20opengl/Dockerfile

And the x11 arguments that you can add to the docker run command when starting the container are:

-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY

Upvotes: 8

Related Questions