ubuntu20.04安装NVIDIA驱动后docker中rviz,pcl_viewer等涉及到访问宿主机界面的程序不可用

如题,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,这样就不会影响到内核

祝好!

  • 7
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值