nvidia-docker 容器中的 rViz

rViz in nvidia-docker container

我设置了一堆 ros 节点,每个节点 运行 在一个 docker 容器中,并通过 docker-compose 启动。我在我的笔记本电脑上 运行 没有遇到任何问题,除了 rviz 很慢,因为它 运行 只在 cpu 上。现在我将项目移动到一台在 ubuntu18.04LTS 上有 nVidia RTX2080 的机器上,同样的设置会产生这些错误。我已经安装了 nvidia-docker2 并且 daemon.json 将默认的 运行time 设置为 nvidia。我真的不知道从哪里开始查看错误。我发现的帖子在没有解决我的问题的情况下被关闭。

如何在 nVidia-docker2 中获取 rViz 运行ning?

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)

我今天真的遇到了同样的问题。我在我的 CPU 笔记本电脑上 docker 中测试了 rviz,一切正常,直到我在 GPU 加速硬件上测试了设置。我已经能够使用 "nvidia-docker2" 下的 http://wiki.ros.org/docker/Tutorials/Hardware%20Acceleration 中提出的解决方案来解决它。

显然,您需要使用环境变量 "NVIDIA_VISIBLE_DEVICES" 和 "NVIDIA_DRIVER_CAPABILITIES" 以及 运行 使用 运行time=nvidia 构建您的容器。希望这有帮助。

参见http://wiki.ros.org/docker/Tutorials/Hardware%20Acceleration
Nvidiadocker镜像需要自己构建

$ 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

我最近在 docker compose 中遇到了同样的问题。将以下内容添加到我的 docker 文件中并重建:

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

还要确保在 compose.yaml 中设置了以下内容:

成交量:

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

环境:

-"/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"