win11 wsl2 Ubuntu-18.04 ROS Gazebo调用NVIDIA显卡

win11 wsl2 Ubuntu-18.04 ROS Gazebo调用NVIDIA显卡

故障内容

调用ROS melodic gazebo的时候,WSL2没有调用独显,导致CPU经常100%,使用以下命令,可以发现可以识别到显卡,但是Gazebo并没有运行。

nvidia-smi
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 530.41.03              Driver Version: 546.56       CUDA Version: 12.3     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                  Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf            Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 4060 L...    On | 00000000:01:00.0  On |                  N/A |
| N/A   43C    P8                5W / 115W|   1719MiB /  8188MiB |      3%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+

调用以下命令,也显示 LLVM,说明不是独显。

glxinfo -B
Device: llvmpipe (LLVM 15.0.7, 256 bits) (0xffffffff)

解决方案

尝试了很多方法,都失败了,但是看到了另一位朋友的博客,非常感谢!这个问题折腾了我好久,差点以为是WSL2性能释放不出来,都要想装双系统了。

跳转链接

他是参照了github上的一个解决方案,解决了。
ppa:kisak/kisak-mesa这个不再提供ubuntu 18.04的支持了
更换为ppa:kisak/turtle即可

sudo add-apt-repository ppa:kisak/turtle
sudo update
sudo upgrade

github链接

但是,我的问题没有(完全?)解决,然后我在github评论区找到了另一个github链接解决的。添加以下指令,,运行gazebo的时候独显就可以正常工作了。

export MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA

github链接

name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Microsoft Corporation (0xffffffff)
    Device: D3D12 (NVIDIA GeForce RTX 4060 Laptop GPU) (0xffffffff)
    Version: 22.3.7
    Accelerated: yes
    Video memory: 16017MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 4.2
    Max compat profile version: 4.2
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.1
OpenGL vendor string: Microsoft Corporation
OpenGL renderer string: D3D12 (NVIDIA GeForce RTX 4060 Laptop GPU)
OpenGL core profile version string: 4.2 (Core Profile) Mesa 22.3.7 - kisak-mesa PPA
OpenGL core profile shading language version string: 4.20
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.2 (Compatibility Profile) Mesa 22.3.7 - kisak-mesa PPA
OpenGL shading language version string: 4.20
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.1 Mesa 22.3.7 - kisak-mesa PPA
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 530.41.03              Driver Version: 546.56       CUDA Version: 12.3     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                  Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf            Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 4060 L...    On | 00000000:01:00.0  On |                  N/A |
| N/A   45C    P4               11W / 115W|   1860MiB /  8188MiB |     26%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A     20667      G   /gzserver                                 N/A      |
|    0   N/A  N/A     20668      G   /gzclient                                 N/A      |
+---------------------------------------------------------------------------------------+

真是太开心了!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值