Run RViz from remote docker using X11
Original post is on StackOverflow.
I'm planning to run ROS Rviz in a docker on a remote server, expecting the Rviz GUI to display on my local computer. But I cannot get it done. I know Rviz uses Ogre so I thought maybe this is the place where I can get help.
My ROS docker image on the remote server is based on ros-melodic-desktop-full image (According to ROS Using Hardware Acceleration with Docker, ros-melodic-desktop-full already contains nvidia-docker2). Below is my Dockerfile:
FROM osrf/ros:melodic-desktop-full
# strace, xterm, mesa-utils are all for debugging X display. Especially, mesa-utils has glxinfo and glxgear
RUN apt-get update && apt-get install -y xauth strace xterm mesa-utils
# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
# QT_X11_NO_MITSHM is for running X server and X client on different machines.
ENV QT_X11_NO_MITSHM 1
ENTRYPOINT ["/bin/bash"]
And my workflow is from this blog: Running a graphical app in a Docker container, on a remote server. Basically, I use socat as a pipe to connect Unix domain sockat and TCP port 60xx (xx is the current $DISPLAY value). Below is my workflow. I first login the remote server using ssh -X user@address
. Then on the server, I execute these commands (docker image name is ros-nvidia-gui:1.0):
DISPLAY_NUMBER=$(echo $DISPLAY | cut -d. -f1 | cut -d: -f2)
socat TCP4:localhost:60${DISPLAY_NUMBER} UNIX-LISTEN:/tmp/.X11-unix/X${DISPLAY_NUMBER} &
export DISPLAY=:$(echo $DISPLAY | cut -d. -f1 | cut -d: -f2)
docker run -it --rm \
-e DISPLAY=${DISPLAY} \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /home/deq/.Xauthority:/root/.Xauthority \
--hostname $(hostname) \
-e QT_X11_NO_MITSHM=1 \
-e QT_QPA_PLATFORM='offscreen' \
--runtime=nvidia \
--gpus all \
ros-nvidia-gui:1.0
Then I get into the docker container. When I run roscore & rviz
in the container, the following exception is thrown:
root@node3:/# rviz
[ INFO] [1587175060.603895335]: rviz version 1.13.7
[ INFO] [1587175060.603985593]: compiled against Qt version 5.9.5
[ INFO] [1587175060.604014712]: compiled against OGRE version 1.9.0 (Ghadamon)
[ INFO] [1587175060.620394536]: Forcing OpenGl version 0.
[ WARN] [1587175068.907551767]: OGRE EXCEPTION(3:RenderingAPIException): Couldn`t open X display :11 in GLXGLSupport::getXDisplay at /build/ogre-1.9-B6QkmW/ogre-1.9-1.9.0+dfsg1/RenderSystems/GL/src/GLX/OgreGLXGLSupport.cpp (line 832)
terminate called after throwing an instance of 'Ogre::RenderingAPIException'
what(): OGRE EXCEPTION(3:RenderingAPIException): Couldn`t open X display :11 in GLXGLSupport::getXDisplay at /build/ogre-1.9-B6QkmW/ogre-1.9-1.9.0+dfsg1/RenderSystems/GL/src/GLX/OgreGLXGLSupport.cpp (line 832)
Aborted (core dumped)
Then I narrowed the question down to Ogre. I followed the exception to the source code of OgreGLXGLSupport.cpp. According to RViz output, the line mXDisplay = XOpenDisplay(displayString);
is buggy. Then I searched the manual of XOpenDisplay, and the ":11" display value seems also fine.
On the other hand, X11 forwarding works well, because when I run glxgears
in the docker on the remote server, the three gears are displayed on my local computer.
So in a nutshell, the X11 forwarding seems fine. I'm not sure what else should I do to get this thing done. Please help me!
The full ogre log output:
root@node3:/# rviz -l
[ INFO] [1587347751.258891748]: rviz version 1.13.7
[ INFO] [1587347751.258989828]: compiled against Qt version 5.9.5
[ INFO] [1587347751.259017887]: compiled against OGRE version 1.9.0 (Ghadamon)
[ INFO] [1587347751.275505230]: Forcing OpenGl version 0.
[ INFO] [1587347759.275606785]: Creating resource group General
[ INFO] [1587347759.275772220]: Creating resource group Internal
[ INFO] [1587347759.275827057]: Creating resource group Autodetect
[ INFO] [1587347759.276008321]: SceneManagerFactory for type 'DefaultSceneManager' registered.
[ INFO] [1587347759.276363754]: Registering ResourceManager for type Material
[ INFO] [1587347759.276450744]: Registering ResourceManager for type Mesh
[ INFO] [1587347759.276496732]: Registering ResourceManager for type Skeleton
[ INFO] [1587347759.276568910]: MovableObjectFactory for type 'ParticleSystem' registered.
[ INFO] [1587347759.276710912]: ArchiveFactory for archive type FileSystem registered.
[ INFO] [1587347759.276763885]: ArchiveFactory for archive type Zip registered.
[ INFO] [1587347759.276804855]: ArchiveFactory for archive type EmbeddedZip registered.
[ INFO] [1587347759.276845754]: DDS codec registering
[ INFO] [1587347759.276907600]: FreeImage version: 3.17.0
[ INFO] [1587347759.276976277]: This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
[ INFO] [1587347759.277227300]: Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,xbm,xpm,gif,hdr,g3,sgi,rgb,rgba,bw,exr,j2k,j2c,jp2,pfm,pct,pict,pic,3fr,arw,bay,bmq,cap,cine,cr2,crw,cs1,dc2,dcr,drf,dsc,dng,erf,fff,ia,iiq,k25,kc2,kdc,mdc,mef,mos,mrw,nef,nrw,orf,pef,ptx,pxn,qtk,raf,raw,rdc,rw2,rwl,rwz,sr2,srf,srw,sti,x3f,webp,jxr,wdp,hdp
[ INFO] [1587347759.277281552]: PVRTC codec registering
[ INFO] [1587347759.277328249]: ETC codec registering
[ INFO] [1587347759.277375109]: Registering ResourceManager for type HighLevelGpuProgram
[ INFO] [1587347759.277431131]: Registering ResourceManager for type Compositor
[ INFO] [1587347759.277751329]: MovableObjectFactory for type 'Entity' registered.
[ INFO] [1587347759.277809988]: MovableObjectFactory for type 'Light' registered.
[ INFO] [1587347759.277851605]: MovableObjectFactory for type 'BillboardSet' registered.
[ INFO] [1587347759.277889137]: MovableObjectFactory for type 'ManualObject' registered.
[ INFO] [1587347759.278534513]: MovableObjectFactory for type 'BillboardChain' registered.
[ INFO] [1587347759.278601740]: MovableObjectFactory for type 'RibbonTrail' registered.
[ INFO] [1587347759.278805687]: *-*-* OGRE Initialising
[ INFO] [1587347759.278855134]: *-*-* Version 1.9.0 (Ghadamon)
[ INFO] [1587347759.278941999]: OverlayElementFactory for type Panel registered.
[ INFO] [1587347759.278988559]: OverlayElementFactory for type BorderPanel registered.
[ INFO] [1587347759.279029257]: OverlayElementFactory for type TextArea registered.
[ INFO] [1587347759.279081768]: Registering ResourceManager for type Font
[ INFO] [1587347759.279140706]: Loading library /usr/lib/x86_64-linux-gnu/OGRE-1.9.0/RenderSystem_GL
[ INFO] [1587347759.283308157]: Installing plugin: GL RenderSystem
[ INFO] [1587347759.283418942]: OpenGL Rendering Subsystem created.
[ WARN] [1587347759.566593524]: OGRE EXCEPTION(3:RenderingAPIException): Couldn`t open X display :11 in GLXGLSupport::getXDisplay at /build/ogre-1.9-B6QkmW/ogre-1.9-1.9.0+dfsg1/RenderSystems/GL/src/GLX/OgreGLXGLSupport.cpp (line 832)
terminate called after throwing an instance of 'Ogre::RenderingAPIException'
what(): OGRE EXCEPTION(3:RenderingAPIException): Couldn`t open X display :11 in GLXGLSupport::getXDisplay at /build/ogre-1.9-B6QkmW/ogre-1.9-1.9.0+dfsg1/RenderSystems/GL/src/GLX/OgreGLXGLSupport.cpp (line 832)
Aborted (core dumped)
My Environment
OS Version: Remote server is CentOS 7. The docker base image is osrf/ros:melodic-desktop-full.
ROS Distro: Melodic
RViz, Qt, OGRE, OpenGl version as printed by rviz: RViz 1.13.7, Qt 5.9.5, OGRE 1.9.0 (Ghadamon)
OpenGL info is output by glxinfo
in the docker:
name of display: :11
display: :11 screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
GLX version: 1.4
Extended renderer info (GLX_MESA_query_renderer):
Vendor: VMware, Inc. (0xffffffff)
Device: llvmpipe (LLVM 9.0, 256 bits) (0xffffffff)
Version: 19.2.8
Accelerated: no
Video memory: 257669MB
Unified memory: no
Preferred profile: core (0x1)
Max core profile version: 3.3
Max compat profile version: 3.1
Max GLES1 profile version: 1.1
Max GLES[23] profile version: 3.0
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: llvmpipe (LLVM 9.0, 256 bits)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 19.2.8
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL version string: 3.1 Mesa 19.2.8
OpenGL shading language version string: 1.40
OpenGL context flags: (none)
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 19.2.8
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
GPU-related environment:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.33.01 Driver Version: 440.33.01 CUDA Version: 10.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce RTX 208... Off | 00000000:04:00.0 Off | N/A |
| 25% 30C P8 14W / 260W | 6471MiB / 11019MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 TITAN V Off | 00000000:84:00.0 Off | N/A |
| 28% 41C P0 36W / 250W | 0MiB / 12066MiB | 7% Default |
+-------------------------------+----------------------+----------------------+
Asked by Elgin.D on 2020-04-19 21:19:53 UTC
Answers
https://medium.com/@viirya/setting-up-linux-gui-container-on-mac-728194b20e78
This medium post might be giving some clue...
Asked by dannylhong on 2022-11-13 09:12:05 UTC
Comments