如题,ubuntu20.04安装NVIDIA驱动后docker中rviz,pcl_viewer等涉及到访问宿主机界面的程序不可用,NVIDIA驱动选择如下:
选择后启动docker,然后安装galactic ros2,会报错如下:
[ERROR] [1651885440.540169712] [rviz2]: rviz::RenderSystem: error creating render window: RenderingAPIException: Unable to create a suitable GLXContext in GLXContext::GLXContext at /tmp/binarydeb/ros-galactic-rviz-ogre-vendor-8.5.0/obj-x86_64-linux-gnu/ogre-v1.12.1-prefix/src/ogre-v1.12.1/RenderSystems/GLSupport/src/GLX/OgreGLXContext.cpp (line 60)
[ERROR] [1651885440.540186404] [rviz2]: Unable to create the rendering window after 100 tries
terminate called after throwing an instance of 'std::runtime_error'
what(): Unable to create the rendering window after 100 tries
Aborted (core dumped)
启动ros1 melodic版本的rviz时,会报错如下:
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)
[ERROR] [1651887091.851743854]: Unable to create the rendering window after 100 tries.
[ INFO] [1651887091.851755308]: Stereo is NOT SUPPORTED
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Aborted (core dumped)
启动pcl_viewer同样会报错
The viewer window provides interactive commands; for help, press 'h' or 'H' from within the window.
> Loading map.pcd libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request: GLXBadContext
Major opcode of failed request: 151 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request: 59
Current serial number in output stream: 58
问题原因为:
宿主机在升级nvidia驱动后,opengl升级版本,而在docker中仍旧使用旧的opengl版本,同样在docker中升级一遍nvidia驱动后问题解决,安装指令如下:
在宿主机下运行如下指令:
#!/bin/bash
version="$(glxinfo | grep "OpenGL version string" | rev | cut -d" " -f1 | rev)"
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/"$version"/NVIDIA-Linux-x86_64-"$version".run
mv NVIDIA-Linux-x86_64-"$version".run NVIDIA-DRIVER.run
在docker中运行如下指令安装
apt-get install module-init-tools kmod
sudo ./NVIDIA-DRIVER.run -a -N --ui=none --no-kernel-module
一定要在后面加入-a -N --ui=none --no-kernel-module,这样就不会影响到内核
祝好!