ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

Run rviz in a docker with hardware acceleration (no gui)

asked 2022-01-06 12:09:53 -0600

We would like to run rviz in a docker without a screen or gui. Reason for this is that we have camera's in rviz outputting on an image topic. We can visualize this outside of the docker on another computer.

So running rviz in a docker can be done:

FROM ros:noetic
RUN sudo apt-get update && sudo apt-get install -qqy xvfb ros-noetic-rviz
ENV DISPLAY :99
CMD /bin/bash -c "xvfb-run rviz"

This does not use the GPU however, and is therefor 10x slower than running rviz with a screen attached.

Is there a way to still use the GPU?

edit retag flag offensive close merge delete

Comments

For Nvidia GPUs it’s possible: https://github.com/NVIDIA/nvidia-docker. I am not sure about others.

osilva gravatar image osilva  ( 2022-01-06 16:21:52 -0600 )edit

This is not the most updated info but can help for other type of GPUs: http://wiki.ros.org/docker/Tutorials/...

osilva gravatar image osilva  ( 2022-01-06 16:26:06 -0600 )edit

Thanks for thinking along. We have an Intel graphics card. I already discovered the wiki you linked, but that one assumes you want to display rviz (and actually have a display).

Timple86 gravatar image Timple86  ( 2022-01-07 01:15:57 -0600 )edit

If you search for xvfb hardware acceleration (using Google), it's clear xvfb does not support it. It was expressly created to avoid needing actual hw to run an X server (and apparently that also means it can't actually use any hw, even if it's available).

I've not done it myself for this use-case specifically, but perhaps looking into setting up a VNC server with hw-accelerated OpenGL could provide some ideas. VirtualGL comes to mind, as well as xpra.


Edit: it could be xpra actually supports this. See usage/OpenGL.

gvdhoorn gravatar image gvdhoorn  ( 2022-01-07 02:40:27 -0600 )edit

xpra works! If you can enter that as an answer, I can mark it as solution.

Timple86 gravatar image Timple86  ( 2022-01-10 02:21:48 -0600 )edit

I'd suggest to post an answer detailing what you did exactly. That would be infinitely more valuable than a single-line answer by me suggesting "maybe xpra can do this".

gvdhoorn gravatar image gvdhoorn  ( 2022-01-10 02:26:38 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2022-01-10 06:00:40 -0600

MCFurry gravatar image

Full general example here: https://mybyways.com/blog/running-lin...

But in general this works on ROS-noetic for example:

FROM ros:noetic
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -qqy xpra ros-noetic-rviz
CMD /bin/bash -c 'xpra start --exec-wrapper="vglrun" --no-daemon --start="rosrun rviz rviz"'

FROM ros:noetic
VOLUME /tmp/.X11-unix
RUN apt update \
 && DEBIAN_FRONTEND=noninteractive apt install -y wget x11-xserver-utils ca-certificates ros-noetic-rviz mesa-utils libegl1-mesa\
 && echo "deb [arch=amd64] https://xpra.org/ focal main" > /etc/apt/sources.list.d/xpra.list \
 && wget -q https://xpra.org/gpg.asc -O- | apt-key add - \
 && apt update \
 && DEBIAN_FRONTEND=noninteractive apt install -y xpra \
 && wget https://sourceforge.net/projects/virtualgl/files/3.0/virtualgl_3.0_amd64.deb/download -O VirtualGL.deb \
 && dpkg -i VirtualGL.deb \
 && mkdir -p /run/user/0/xpra
ENTRYPOINT ["/bin/bash", "-c", "source /opt/ros/noetic/setup.bash && xpra start --mdns=no --webcam=no --no-daemon --exec-wrapper='vglrun' --start='rosrun rviz rviz'"]

Note that this docker image will use mesa-drivers and thus use Intel discrete graphics. For further information about using a GPU within a docker container: http://wiki.ros.org/docker/Tutorials/.... So slight adjustments will be needed in case of Nvidia or ATI GPU.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2022-01-06 12:09:53 -0600

Seen: 486 times

Last updated: Jan 10