Status of VTK 9.0 with respect to off screen rendering under Ubuntu with pip install

Hello All,

I have been experimenting with off screen rendering under Ubuntu 20.04 LTS and VTK 9.0.1 installed on Python 3.8 using pip3 install. I have simply set SetOffScreenRendering(1) on a rendering window on a small example. When the example is run it causes a core dump.

I am wondering, does the PYPi distribution of VTK support off screen at all? Should I recompile VTK with appropriate settings for having off screen working?

Thanks for any advise,

Best Regards,


I’ve been doing offscreen rendering using VTK 9.0.1 from PyPI in one of our applications, also under Ubuntu 20.04 / Python 3.8.

Would help to see your small example.

E.g. this example works on my system:

#!/usr/bin/env python

import vtk

def main():
    coneSource = vtk.vtkConeSource()

    mapper = vtk.vtkPolyDataMapper()

    actor = vtk.vtkActor()

    renderer = vtk.vtkRenderer()

    renderWindow = vtk.vtkRenderWindow()

    windowToImage = vtk.vtkWindowToImageFilter()

    writer = vtk.vtkPNGWriter()

if __name__ == '__main__':

And produces the following PNG:


(studioenv) estan@edison:~$ pip list --local | grep vtk
vtk                  9.0.1  
(studioenv) estan@edison:~$ cat /etc/lsb-release 
(studioenv) estan@edison:~$

Hi Elvis,

Thanks so much for providing the example code. When I tried the code you have provided it causes a core dump. The system I am testing it on is a vSphere virtual machine with attached 4 GPUs (used for DeepLearning, not for display). I will try this on a VM with not GPU (and nvidia drivers attached) to see if that changes things. If it does I am still not sure how to fix the problem, but at least I would know it is related to the presence of certain drivers.

Do you have any graphic adapter on your server?

Thanks and Best Regards,


This was on my laptop with Intel drivers. I don’t have access to an NVIDIA machine with a running X server at the moment, or a vSphere VM.

It may be worth running your Python process under GDB and try to get backtrace.

Can it simply be that you have no running X server on your vSphere VM? I believe an X server must still be running for rendering to work. E.g. if I run with DISPLAY unset:

(studioenv) estan@edison:~$ python3 
2021-04-24 13:33:39.712 (   0.137s) [        D10BE740]vtkXOpenGLRenderWindow.:449    ERR| vtkXOpenGLRenderWindow (0x1329f60): bad X server connection. DISPLAY=
Aborted (core dumped)
(studioenv) estan@edison:~$

And I believe this is to be expected (someone correct me if I’m wrong).

1 Like

In that case, what you could do is run under Xvfb with xvfb-run, e.g:

xvfb-run python3

But you would not get hardware accelerated rendering using your GPU that way.

1 Like

Hi Elvis,

Thanks so much for the appreciated tip. Xvfb works perfectly and I can use now off screen rendering.

Have a great day and thanks for providing this useful information,

Best Regards,


1 Like