MATLAB 2025b 如何启用硬件加速渲染

旧版本opengl命令已经被废弃,由rendererinfo替代。

在MATLAB 2025b中,执行rendererinfo后输出:

ans = 

  包含以下字段的 struct:

    GraphicsRenderer: 'WebGL'
              Vendor: 'Google Inc. (Google)'
             Version: 'WebGL 2.0 (OpenGL ES 3.0 Chromium)'
      RendererDevice: 'ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)'
             Details: [1×1 struct]

从MATLAB在线帮助来看,RendererDevice未显示GPU硬件表明处于CPU渲染,而details矩阵内容也说明这一点:

HardwareSupportLevel:None

系统硬件是AMD 8845hs,纯核显870M没有独显,可以确认系统依赖都是没错的,能够调用硬件加速:

❯ vulkaninfo | grep "GPU id"                     
                GPU id = 0 (AMD Radeon 780M Graphics (RADV PHOENIX))
GPU id : 0 (AMD Radeon 780M Graphics (RADV PHOENIX)) [VK_KHR_xcb_surface, VK_KHR_xlib_surface]:
GPU id : 0 (AMD Radeon 780M Graphics (RADV PHOENIX)) [VK_KHR_wayland_surface]:

❯ glxinfo | grep "OpenGL renderer"               
OpenGL renderer string: AMD Radeon 780M Graphics (radeonsi, phoenix, LLVM 21.1.4, DRM 3.64, 6.17.5-arch1-1)

不清楚新版本MATLAB如何启用硬件加速渲染

eglinfo | grep 'OpenGL ES'

除了开始的几行failed是因为不在video和render组,看上去都是正常的,像vaapi,vainfo,Firefox硬解都没问题

❯ eglinfo | grep 'OpenGL ES'
_amdgpu_device_initialize: amdgpu_query_info(ACCEL_WORKING) failed (-13)
amdgpu: amdgpu_device_initialize failed.
_amdgpu_device_initialize: amdgpu_query_info(ACCEL_WORKING) failed (-13)
amdgpu: amdgpu_device_initialize failed.
OpenGL ES profile vendor: Mesa
OpenGL ES profile renderer: llvmpipe (LLVM 21.1.4, 256 bits)
OpenGL ES profile version: OpenGL ES 3.2 Mesa 25.2.5-arch1.2
OpenGL ES profile shading language version: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:
OpenGL ES profile vendor: AMD
OpenGL ES profile renderer: AMD Radeon 780M Graphics (radeonsi, phoenix, LLVM 21.1.4, DRM 3.64, 6.17.5-arch1-1)
OpenGL ES profile version: OpenGL ES 3.2 Mesa 25.2.5-arch1.2
OpenGL ES profile shading language version: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

已解决,通过添加export LD_PRELOAD=/usr/lib/libstdc++.so.6参数即可

可惜来晚了,问题已经解决了。以前我想让matlab在arch linux上好好运行那简直是折磨,遇到过不少的坑,这里有我以前用的matlab [2022a](https://git.flylightning.xyz/public_archive_codes/tree/sh/matlab?id=701d168dde7de12c7aabef2e0cd1be9fe12af9c9)和[2024a](https://git.flylightning.xyz/config_local_arch/tree/home/xyz/.local/bin/matlab?id=4e2583307b550f7485bfc8dc7450facfe5bc9586)的wrapper script,你若遇到其他解决不了的坑,不妨来瞅瞅,苦笑。好吧,只是吐槽一下,从https://git.flylightning.xyz/config_local_arch/log/home/xyz/.local/bin/matlab git log 里我的四个"fuck matlab" commit message你就能感受到我曾经的心情。。。