How to build VTK on a supercomputer without X-Server and no root previliges

Hi. With all the great help from this forum, I have managed to write a usable VTK volume rendering C++ code. I want to use this code on a supercomputer with no X display server or root privileges. The main thing that I want to do is render without opening a window. Upon googling a lot, I found that I need to build VTK with OSMESA. I have tried a lot but I am having hard time building VTK on our cluster with OSMESA support. I keep running into some variation of “library not found” errors. I tried the instructions on the following paraview wiki page as well

https://www.paraview.org/Wiki/ParaView/ParaView_And_Mesa_3D

The problem with these instructions is that I couldn’t execute the make install command (permission denied) for llvm driver. Because of this, I think, when I configure mesa, I get the llvm-config not found error. Also, apparently mesa swrast doesn’t support the latest VTK (as discussed in the paraview wiki page).

I have also tried running the OffScreenRendering example on VTK Examples website but it doesn’t work for the current version of VTK.

It would be very helpful if someone here could show a self-contained way of building VTK on a system without X and what code I should add to my VTK volume rendering code to render without opening a window. I am also wondering if we even need OSMESA.

I am a physics student and so please forgive my ignorance.

Thank you and best regards.

I cannot help with regard to building VTK but I can help with off screen rendering…

On your vtk.vtkRenderWindow you’ll need to call .SetOffScreenRendering(1) and definitely do not use a vtk.vtkRenderWindowInteractor

Thanks a lot, Bane. This solved the problem of rendering without window on my laptop. I guess this means we do not need OSMESA as I had built VTK on my laptop without OSMESA. On the supercomputer, I am still getting the following error.

ERROR: In ~/VTK-8.2.0/Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx, line 452
vtkXOpenGLRenderWindow (0x23543f0): bad X server connection. DISPLAY=Aborted

Also, I am a bit confused about off screen rendering. I had tried SetOffScreenRendering(1) earlier but the VTK was still producing a window. It seems the problem was that even though I had commented out windowInteractor->Start(), I had left vtkNew<vtkRenderWindowInteractor> windowInteractor statement uncommented. Following your suggestion this time, I commented all the statements involving window interactor and no window is created on my laptop. The confusing part for me is that a window is created even if we do not “Start” the interactor.

If you have no X server, you will indeed need to build against osmesa. Setting the OffScreenRendering option in vtkRenderWindow is not sufficient - that option still relies on X being present.

I recommend a couple options:

  1. Download and install ParaView 5.6.0 for linux built against osmesa. If you want to run Python scripts that use VTK, you can run pvpython and run
>>> import paraview.vtk as vtk
>>> from vtk import *

It isn’t the ideal way to import VTK, but it will get you running.

  1. Follow how ParaView’s superbuild process builds osmesa. You can start here and get clues as to which configuration flags are needed in the files that script includes, which are located here.
1 Like

I know this is an old topic, but we just had a similar issue tryin to run VTK in containers on Kubernetes. A good workaround is to use the xvfb utility. It emulates an X server in-memory and doesn’t require rebuilding VTK. For anyone using python, there is a simple wrapper library, too.

3 Likes