We are trying to run a Python script that imports VTK and uses pyvirtualdisplay (Xvfb) to render images while running in a Kubernetes pod.
We installed VTK through
pip install vtk (making sure we had the required
libopenmpi-dev and other required packages installed from
deb https://apt.kitware.com/ubuntu/ bionic main repository) using Python 3.7 on Ubuntu 18.04, as a Docker image.
The following error happens randomly (more frequently while running in the k8s pod, however we were able to reproduce it running in a local Docker image as well):
Because of IP restrictions, I’m trying to share pieces of the script that seems relevant for the discussion:
import vtk from pyvirtualdisplay import Display def render(i, x, y, z): transform = vtk.vtkTransform() ... ren = vtk.vtkRenderer() ren_win = vtk.vtkRenderWindow() ren_win.SetOffScreenRendering(1) ren_win.AddRenderer(ren) ren_win.Render() window_to_image_filter = vtk.vtkWindowToImageFilter() window_to_image_filter.SetInput(ren_win) window_to_image_filter.Update() ... writer.Write() def capture(): with Display(): file = "input.obj" reader = vtk.vtkOBJReader() ... rotate_models(i, 1, 0, 0) rotate_models(i, 0, 1, 0) rotate_models(i, 0, 0, 1) for i in range(30): capture()
We opened the generated core dump file in
gdb and drilled down as much as possible, and it seems the issues is related with rendering window not being able to render:
While searching for solutions, we found some options like using Paraview’s VTK (built with OSMESA) and also building VTK ourselves with OSMESA support (Offscreen Rendering In Linux // patricksnape // Computer Vision and Machine Learning Engineer).
Should we build a software rendering VTK ourselves or is there any other possible solution? We would be more than happy to share any other supporting information and collaborate on fixing this issue.
Thank you in advance.