-1

I'm having some difficulty using Mayavi mlab in python with PyCharm IDE from the MNE-Python environment. I access the Conda environment with Mayavi and VTK over a VNC session using a xvnc server from my local MacOS to a Linux cluster machine.

The error I get when opening a mlab window is:

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.

It seems that using VirtualGL to intercept PyCharm for VTK's call of OpenGL is one possible solution. Have anyone successfully overcome this issue of using Mayavi mlab over VNC session? What are your solutions?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Alex He
  • 9
  • 3

2 Answers2

1

I am unable to reproduce. Have you made sure that the machine you are accessing has available and loaded up-to-date graphics drivers and/or Mesa software? As an example, I am using 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, then OpenGL is used and the rendered scene is flawless. I attach the screenshot and saved figures below.

enter image description here enter image description here enter image description here

Patol75
  • 4,342
  • 1
  • 17
  • 28
  • Thanks for the test. Indeed, using virtualGL by prepend python execution with vglrun seems to be the most elegant solution and avoids the artifacts of rendering encountered using purely Software GL with Mesa. I would recommend future viewers of this problem to try set up virtual GL and run it as suggested by this answer. – Alex He Apr 29 '20 at 19:23
  • When I tried to use virtualGL, I ran into the problem of ***ERROR: In ../Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 741 vtkXOpenGLRenderWindow (0x55b9664aad70): GLEW could not be initialized: Missing GL version Segmentation fault (core dumped)*** documenting here in case others want to give this option and try and have the same problem. – Alex He Apr 30 '20 at 17:56
  • Have you read properly the [documentation](https://cdn.rawgit.com/VirtualGL/virtualgl/2.6.3/doc/index.html)? It took me some time to figure it out, but I do not remember running in such an error. What GPU is installed on the machine you intend to run Mayavi on? – Patol75 May 01 '20 at 01:45
  • Yeah your comment is on point. I suspect the issue comes from not configuring virtualGL properly. I don't own the linux machine which is running CentOS7 and with virtualGL 2.4 installed. The cluster maintenance team doesn't have the bandwidth to configure this out. – Alex He May 01 '20 at 02:58
  • Is there any nVidia package you would have to load? Did you request a node with GPU on it? – Patol75 May 01 '20 at 03:39
0

I had the same problem days ago, after exchanging emails with HPC staff, our solution is quite simple:

export MESA_GL_VERSION_OVERRIDE=3.2

I am using RealVNC Viewer to access HPC and I ran Mayavi API through VSCode.

enter image description here

I also recommend PyVista, which seems to more pythonic in many aspects. I was able to save all the plot in PyVista and the plots are great.

The new problem is that I cannot save the mlab plot using either API or the interactive scene. I only got a black figure so far.

Some answer related to saving: mayavi mlab.savefig() gives an empty image is not working well in VNC so far.

Chang
  • 396
  • 4
  • 17
  • Please see my answer below. Not only your saved figure is black, but the render is not correct either. Consider using GPU-based rendering instead of Mesa which is CPU-based. – Patol75 Apr 29 '20 at 05:58
  • Yes, I eventually moved to PyeVTK to export the VTK file and then visualize it directly within VisIt. PyVista has done a better job in terms of render but the API features provided are not powerful enough. Not all HPC cluster has access to GPU so maybe pure VTK might be more flexible if you only need to produce a few 3D plots. – Chang May 07 '20 at 16:12