jaaq
jaaq

Reputation: 1256

rViz in nvidia-docker container

I have set up a bunch of ros nodes that each run inside a docker container and are started via docker-compose. I had no problems running it on my laptop, besides rviz being slow since it was running on the cpu only. Now I am moving the project onto a machine that has an nVidia RTX2080 on ubuntu18.04LTS and the same setup produces these errors. I have already installed nvidia-docker2 and the daemon.json is setting the default runtime as nvidia. I don't really know where to start looking at errors. Posts I found were closed without a solution to my problem.

How to get rViz running in nVidia-docker2?

rviz_1           | libGL error: No matching fbConfigs or visuals found
rviz_1           | libGL error: failed to load driver: swrast
rviz_1           | libGL error: No matching fbConfigs or visuals found
rviz_1           | libGL error: failed to load driver: swrast
rviz_1           | libGL error: No matching fbConfigs or visuals found
rviz_1           | libGL error: failed to load driver: swrast
rviz_1           | [ INFO] [1576658065.533954900]: rviz version 1.13.6
rviz_1           | [ INFO] [1576658065.534009692]: compiled against Qt version 5.9.5
rviz_1           | [ INFO] [1576658065.534021481]: compiled against OGRE version 1.9.0 (Ghadamon)
rviz_1           | [ INFO] [1576658065.548489531]: Forcing OpenGl version 0.
rviz_1           | [ WARN] [1576658065.859692866]: OGRE EXCEPTION(3:RenderingAPIException): Unable to create a suitable GLXContext in GLXContext::GLXContext at /build/ogre-1.9-B6QkmW/ogre-1.9-1.9.0+dfsg1/RenderSystems/GL/src/GLX/OgreGLXContext.cpp (line 61)
rviz_1           | rviz::RenderSystem: error creating render window: OGRE EXCEPTION(3:RenderingAPIException): Unable to create a suitable GLXContext in GLXContext::GLXContext at /build/ogre-1.9-B6QkmW/ogre-1.9-1.9.0+dfsg1/RenderSystems/GL/src/GLX/OgreGLXContext.cpp (line 61)
rviz_1           | rviz::RenderSystem: error creating render window: OGRE EXCEPTION(3:RenderingAPIException): Unable to create a suitable GLXContext in GLXContext::GLXContext at /build/ogre-1.9-B6QkmW/ogre-1.9-1.9.0+dfsg1/RenderSystems/GL/src/GLX/OgreGLXContext.cpp (line 61)

Upvotes: 4

Views: 7208

Answers (3)

Harry_Verman
Harry_Verman

Reputation: 21

Had the same issue in docker compose that I recently solved. Added the following into my dockerfile and rebuild:

ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics

And also make sure in compose.yaml, you have set the following:

volume:

-"/tmp/.X11-unix:/tmp/.X11-unix:rw"
-"/var/run/dbus:/var/run/dbus"  

enivironment:

-"/usr/local/nvidia/bin:${PATH}"
-"NVIDIA_VISIBLE_DEVICES: all"
-"NVIDIA_DRIVER_CAPABILITIES:compute,compat32,utility,graphics,video,display"
- "DISPLAY=unix$DISPLAY"
- "QT_X11_NO_MITSHM=1"
- "XDG_RUNTIME_DIR= /run/user/1000"

Upvotes: 1

Obinata Hiroyuki
Obinata Hiroyuki

Reputation: 56

See http://wiki.ros.org/docker/Tutorials/Hardware%20Acceleration.
Nvidia docker images need to be built by your own.

$ cd path/to/dir
$ cat Dockerfile
FROM your-repo/your-image:your-tag
# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES \
    ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
    ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
$ docker build -t your-nvidia-image .
$ xhost +local:
$ docker run --gpus all -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY your-nvidia-image /bin/bash

Upvotes: 3

Fabian Küppers
Fabian Küppers

Reputation: 1

I really faced the same problem today. I tested rviz in docker on my CPU laptop and everything worked fine until I tested the setup on a GPU accelerated hardware. I have been able to solve it by using the solution proposed in http://wiki.ros.org/docker/Tutorials/Hardware%20Acceleration under "nvidia-docker2".

Obviously, you need to build your image with the environment variables "NVIDIA_VISIBLE_DEVICES" and "NVIDIA_DRIVER_CAPABILITIES" and run your container with runtime=nvidia. Hope this helps.

Upvotes: 0

Related Questions