在 VNC 上使用 Mayavi mlab 会引发 OpenGL 错误

Using Mayavi mlab over VNC Throws OpenGL error

我在 python 中使用 Mayavi mlab 在 MNE-Python 环境中使用 PyCharm IDE 时遇到了一些困难。我使用 xvnc 服务器从我的本地 MacOS 到 Linux 集群机器,通过 VNC 会话使用 Mayavi 和 VTK 访问 Conda 环境。

打开 mlab window 时出现的错误是:

ERROR: In ../Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 754 
vtkXOpenGLRenderWindow (0x556e13b32670): Unable to find a valid OpenGL 3.2 or later implementation. Please update your video card driver to the latest version. If you are using Mesa please make sure you have version 11.2 or later and make sure your driver in Mesa supports OpenGL 3.2 such as llvmpipe or openswr. If you are on windows and using Microsoft remote desktop note that it only supports OpenGL 3.2 with nvidia quadro cards. You can use other remoting software such as nomachine to avoid this issue.

看来使用VirtualGL拦截PyCharmVTK对OpenGL的调用是一种可能的解决方案。有没有人成功克服了通过 VNC 会话使用 Mayavi mlab 的问题?你的解决方案是什么?

我无法重现。您是否确定您正在访问的机器可用并加载了最新的图形驱动程序 and/or Mesa 软件?例如,我使用 TurboVNC to access a remote Ubuntu 18.04 machine, and I am able to produce the Spherical Harmonics Gallery Example both through the regular and envisage Mayavi backends. However, using the default settings of TurboVNC, the rendered scene has artefacts and saving the scene as png yields a black image, which I guess is a consequence of Mesa being used (llvmpipe). If I either start TurboVNC with -extension GLX or if I simply prepend vglrun to the python3 command, which calls VirtualGL,然后使用 OpenGL,渲染的场景完美无缺。我在下面附上屏幕截图和保存的数字。

几天前我遇到了同样的问题,在与 HPC 人员交换电子邮件后,我们的解决方案很简单:

出口MESA_GL_VERSION_OVERRIDE=3.2

我正在使用 RealVNC Viewer 访问 HPC,我 运行 Mayavi API 通过 VSCode。

我还推荐PyVista,它在很多方面看起来更像pythonic。我能够在 PyVista 中保存所有绘图,而且绘图很棒。

新问题是我无法使用 API 或交互式场景保存 mlab 图。到目前为止,我只得到一个黑色的数字。

一些与保存相关的回答:mayavi mlab.savefig() gives an empty image 目前在 VNC 中运行不佳。