# pvpython offscreen rendering segfault

**URL:** https://discourse.paraview.org/t/pvpython-offscreen-rendering-segfault/246
**Category:** ParaView Support
**Created:** [June 28, 2018, 9:46am UTC](https://discourse.paraview.org/t/pvpython-offscreen-rendering-segfault/246 "2018-06-28T09:46:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Lukas](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lukas/32/114_2.png) [@Lukas](https://discourse.paraview.org/u/Lukas)
#### Post date: [June 28, 2018, 9:46am UTC](https://discourse.paraview.org/t/pvpython-offscreen-rendering-segfault/246/1 "2018-06-28T09:46:38Z")

</div>

Hi all,

I am trying to run `pvpython` in headless mode (`--force-offscreen-rendering`).  
I followed [this guide](https://www.paraview.org/ParaView/Doc/Nightly/www/cxx-doc/Offscreen.html) and configured ParaView with `VTK_USE_X=ON` and `VTK_OPENGL_HAS_OSMESA=ON`.  
Unfortunately, it segfaults on ubuntu 16.04:

```auto
#0 0x00007fffe5844ab8 in typeinfo for vtkXRenderWindowInteractor () from /home/lukas/.bdm/third_party/paraview/lib/libvtkRenderingOpenGL2-pv5.5.so.1
#1 0x00007fffe55dd205 in vtkXRenderWindowInteractor::Initialize() () from /home/lukas/.bdm/third_party/paraview/lib/libvtkRenderingOpenGL2-pv5.5.so.1
#2 0x00007fffe5188f42 in vtkRenderWindow::Render() () from /home/lukas/.bdm/third_party/paraview/lib/libvtkRenderingCore-pv5.5.so.1
#3 0x00007ffff024a917 in vtkPVRenderView::Render(bool, bool) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVClientServerCoreRendering-pv5.5.so.1
#4 0x00007ffff0242a0a in vtkPVRenderView::StillRender() () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVClientServerCoreRendering-pv5.5.so.1
#5 0x00007ffff76700c0 in vtkPVRenderViewCommand(vtkClientServerInterpreter*, vtkObjectBase*, char const*, vtkClientServerStream const&, vtkClientServerStream&, void*) ()
   from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerManagerApplication-pv5.5.so.1
#6 0x00007fffec8812b9 in vtkClientServerInterpreter::CallCommandFunction(char const*, vtkObjectBase*, char const*, vtkClientServerStream const&, vtkClientServerStream&) ()
   from /home/lukas/.bdm/third_party/paraview/lib/libvtkClientServer-pv5.5.so.1
#7 0x00007fffec881662 in vtkClientServerInterpreter::ProcessCommandInvoke(vtkClientServerStream const&, int) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkClientServer-pv5.5.so.1
#8 0x00007fffec8821ee in vtkClientServerInterpreter::ProcessOneMessage(vtkClientServerStream const&, int) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkClientServer-pv5.5.so.1
#9 0x00007fffec88244d in vtkClientServerInterpreter::ProcessStream(vtkClientServerStream const&) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkClientServer-pv5.5.so.1
#10 0x00007ffff0811505 in vtkPVSessionCore::ExecuteStreamInternal(vtkClientServerStream const&, bool) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerImplementationCore-pv5.5.so.1
#11 0x00007ffff081132b in vtkPVSessionCore::ExecuteStream(unsigned int, vtkClientServerStream const&, bool) ()
   from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerImplementationCore-pv5.5.so.1
#12 0x00007ffff080fed5 in vtkPVSessionBase::ExecuteStream(unsigned int, vtkClientServerStream const&, bool) [clone .localalias.5] ()
   from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerImplementationCore-pv5.5.so.1
#13 0x00007ffff0d4ac8b in vtkSMViewProxy::StillRender() () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerManagerRendering-pv5.5.so.1
#14 0x00007ffff2692ec0 in vtkSMAnimationScene::TickInternal(double, double, double) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVAnimation-pv5.5.so.1
#15 0x00007ffff56101ef in vtkAnimationCue::Tick(double, double, double) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkCommonCore-pv5.5.so.1
#16 0x00007ffff76dbe0d in vtkSMAnimationSceneCommand(vtkClientServerInterpreter*, vtkObjectBase*, char const*, vtkClientServerStream const&, vtkClientServerStream&, void*) ()
   from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerManagerApplication-pv5.5.so.1
#17 0x00007fffec8812b9 in vtkClientServerInterpreter::CallCommandFunction(char const*, vtkObjectBase*, char const*, vtkClientServerStream const&, vtkClientServerStream&) ()
   from /home/lukas/.bdm/third_party/paraview/lib/libvtkClientServer-pv5.5.so.1
#18 0x00007fffec881662 in vtkClientServerInterpreter::ProcessCommandInvoke(vtkClientServerStream const&, int) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkClientServer-pv5.5.so.1
#19 0x00007fffec8821ee in vtkClientServerInterpreter::ProcessOneMessage(vtkClientServerStream const&, int) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkClientServer-pv5.5.so.1
#20 0x00007fffec88244d in vtkClientServerInterpreter::ProcessStream(vtkClientServerStream const&) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkClientServer-pv5.5.so.1
#21 0x00007ffff08317d6 in vtkSIProperty::ProcessMessage(vtkClientServerStream&) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerImplementationCore-pv5.5.so.1
#22 0x00007ffff082917c in vtkSIVectorPropertyTemplate<double, int>::Push(double*, int) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerImplementationCore-pv5.5.so.1
#23 0x00007ffff0829429 in vtkSIVectorPropertyTemplate<double, int>::Push(paraview_protobuf::Message*, int) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerImplementationCore-pv5.5.so.1
#24 0x00007ffff0836800 in vtkSIProxy::Push(paraview_protobuf::Message*) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerImplementationCore-pv5.5.so.1
#25 0x00007ffff0814a8d in vtkPVSessionCore::PushStateInternal(paraview_protobuf::Message*) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerImplementationCore-pv5.5.so.1
#26 0x00007ffff0810f4f in vtkPVSessionCore::PushState(paraview_protobuf::Message*) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerImplementationCore-pv5.5.so.1
#27 0x00007ffff080fe45 in vtkPVSessionBase::PushState(paraview_protobuf::Message*) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerImplementationCore-pv5.5.so.1
#28 0x00007ffff65aa53f in vtkSMProxy::UpdateVTKObjects() () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVServerManagerCore-pv5.5.so.1
#29 0x00007ffff2694c4e in vtkSMAnimationSceneProxy::UpdateAnimationUsingDataTimeSteps() () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVAnimation-pv5.5.so.1
#30 0x00007fffcf3897c9 in PyvtkSMAnimationSceneProxy_UpdateAnimationUsingDataTimeSteps(_object*, _object*) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPVAnimationPython27D-pv5.5.so.1
#31 0x00007fffe1fd3772 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#32 0x00007fffe210a05c in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#33 0x00007fffe1fd2f1d in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#34 0x00007fffe1fd3044 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#35 0x00007fffe1fd3044 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#36 0x00007fffe210a05c in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#37 0x00007fffe1fcbda9 in PyEval_EvalCode () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#38 0x00007fffe204609e in PyRun_FileExFlags () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#39 0x00007fffe20476e7 in PyRun_SimpleFileExFlags () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#40 0x00007fffe1ffced9 in Py_Main () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#41 0x00007ffff5b30d0d in vtkPythonInterpreter::PyMain(int, char**) () from /home/lukas/.bdm/third_party/paraview/lib/libvtkPythonInterpreter-pv5.5.so.1
#42 0x0000000000402380 in ParaViewPython::Run(int, int, char**) ()
#43 0x00007ffff4989830 in __libc_start_main (main=0x401ed0 <main>, argc=4, argv=0x7fffffffddd8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffddc8)
    at ../csu/libc-start.c:291
#44 0x0000000000401f39 in _start ()

```

I checked out ParaView `v5.5.2` and cherry picked `931c779d` to fix a Qt 5.11 compilation issue.

```auto
$>cmake \
  -DVTK_USE_X=ON \
  -DVTK_OPENGL_HAS_OSMESA=ON \
  -DCMAKE_INSTALL_PREFIX="../paraview-install" \
  -DCMAKE_BUILD_TYPE:STRING="Release" \
  -DPARAVIEW_ENABLE_PYTHON:BOOL=ON \
  -DPARAVIEW_ENABLE_MPI:BOOL=OFF \
  -DPARAVIEW_INSTALL_DEVELOPMENT_FILES:BOOL=ON \
   ../paraview

```

```auto
$>grep OSMESA CMakeCache.txt
OSMESA_INCLUDE_DIR:PATH=/usr/include
OSMESA_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libOSMesa.so
VTK_OPENGL_HAS_OSMESA:BOOL=ON
VTKm_ENABLE_OSMESA:BOOL=ON
//ADVANCED property for variable: OSMESA_INCLUDE_DIR
OSMESA_INCLUDE_DIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: OSMESA_LIBRARY
OSMESA_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: VTK_OPENGL_HAS_OSMESA
VTK_OPENGL_HAS_OSMESA-ADVANCED:INTERNAL=1
//MODIFIED property for variable: VTK_OPENGL_HAS_OSMESA
VTK_OPENGL_HAS_OSMESA-MODIFIED:INTERNAL=ON
//MODIFIED property for variable: VTKm_ENABLE_OSMESA
VTKm_ENABLE_OSMESA-MODIFIED:INTERNAL=ON

```

Many thanks for your help!

Lukas

---

<div class="post-metadata">

### Author: ![Scott\_Wittenburg](https://discourse.paraview.org/user_avatar/discourse.paraview.org/scott_wittenburg/32/16472_2.png) [@Scott\_Wittenburg](https://discourse.paraview.org/u/Scott_Wittenburg)
#### Post date: [June 28, 2018, 3:21pm UTC](https://discourse.paraview.org/t/pvpython-offscreen-rendering-segfault/246/2 "2018-06-28T15:21:03Z")

</div>

The documentation you linked has the following line:

- If `VTK_OPENGL_HAS_EGL` or `VTK_OPENGL_HAS_OSMESA` is ON, the build supports headless rendering, otherwise `VTK_USE_X` must be ON and the build does not support headless, but can still support offscreen rendering.  
According to that you can do offscreen rendering with VTK\_USE\_X=ON, but it won’t be “headless” (i.e. you’ll need a display). For headless rendering you can use either EGL or OSMESA, but then VTK\_USE\_X must be OFF. EGL allows headless rendering with an NVidia GPU (assuming recent enough drivers), while OSMESA provides software rendering (in several flavors: llvm, swr).

Hope this helps,

Scott

---

<div class="post-metadata">

### Author: ![Lukas](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lukas/32/114_2.png) [@Lukas](https://discourse.paraview.org/u/Lukas)
#### Post date: [June 28, 2018, 3:56pm UTC](https://discourse.paraview.org/t/pvpython-offscreen-rendering-segfault/246/3 "2018-06-28T15:56:37Z")

</div>

Hey Scott,

Many thanks for your quick reply!  
I interpreted the documentation differently:

> If `VTK_OPENGL_HAS_EGL` or `VTK_OPENGL_HAS_OSMESA` is ON, the build supports headless rendering, otherwise VTK\_USE\_X must be ON and the build does not support headless, but can still support offscreen rendering.

If `VTK_OPENGL_HAS_EGL=ON` or `VTK_OPENGL_HAS_OSMESA=ON` → headless support  
otherwise (`VTK_OPENGL_HAS_EGL=OFF` and `VTK_OPENGL_HAS_OSMESA=OFF`) → no headless support and `VTK_USE_X` must be turned on.

However, it does not exclude the case where `VTK_OPENGL_HAS_OSMESA=ON` and `VTK_USE_X=ON`.

Further down it is mentioned that:

> it’s possible to build ParaView with onscreen and headless support simultaneously

Is this a fault in the documentation?

Thanks again,  
Lukas

---

<div class="post-metadata">

### Author: ![Scott\_Wittenburg](https://discourse.paraview.org/user_avatar/discourse.paraview.org/scott_wittenburg/32/16472_2.png) [@Scott\_Wittenburg](https://discourse.paraview.org/u/Scott_Wittenburg)
#### Post date: [June 28, 2018, 4:19pm UTC](https://discourse.paraview.org/t/pvpython-offscreen-rendering-segfault/246/4 "2018-06-28T16:19:46Z")

</div>

> Lukas [https://discourse.paraview.org/u/lukas](https://discourse.paraview.org/u/lukas)  
> [https://discourse.paraview.org/u/lukas](https://discourse.paraview.org/u/lukas)  
> June 28
> 
> Hey Scott,
> 
> Many thanks for your quick reply!  
> I interpreted the documentation differently:
> 
> If VTK\_OPENGL\_HAS\_EGL or VTK\_OPENGL\_HAS\_OSMESA is ON, the build supports  
> headless rendering, otherwise VTK\_USE\_X must be ON and the build does not  
> support headless, but can still support offscreen rendering.
> 
> If VTK\_OPENGL\_HAS\_EGL=ON or VTK\_OPENGL\_HAS\_OSMESA=ON → headless support  
> otherwise (VTK\_OPENGL\_HAS\_EGL=OFF and VTK\_OPENGL\_HAS\_OSMESA=OFF) → no  
> headless support and VTK\_USE\_X must be turned on.
> 
> However, it does not exclude the case where VTK\_OPENGL\_HAS\_OSMESA=ON and  
> VTK\_USE\_X=ON.

I guess that’s true, and according to the documentation, that specific  
combination is possible, though I don’t have any experience building that  
way. In that case it says that “all the OpenGL and OSMesa variables should  
point to the Mesa libraries”. I think it would help if that were more  
explicit, but maybe it’s enough to get you pointed in the right direction.

FWIW: If you have an NVidia GPU with at least driver version 384, I  
recommend the EGL approach to headless rendering, Here are my build  
options from a recent EGL build:

cmake   
-DCMAKE\_INSTALL\_PREFIX:PATH=/home/ubuntu/paraview   
-DBUILD\_TESTING:BOOL=OFF   
-DPARAVIEW\_BUILD\_QT\_GUI:BOOL=OFF   
-DPARAVIEW\_ENABLE\_PYTHON:BOOL=ON   
-DVTK\_USE\_X:BOOL=OFF   
-DVTK\_OPENGL\_HAS\_EGL:BOOL=ON   
-DEGL\_INCLUDE\_DIR:PATH=/tmp/egl   
-DEGL\_LIBRARY:FILEPATH=/usr/lib/nvidia-384/libEGL.so   
-DEGL\_opengl\_LIBRARY:FILEPATH=/usr/lib/nvidia-384/libOpenGL.so   
…/src/

You have to download the EGL headers yourself probably, as described in  
this older blog post about EGL:

[https://blog.kitware.com/off-screen-rendering-through-the-native-platform-interface-egl/](https://blog.kitware.com/off-screen-rendering-through-the-native-platform-interface-egl/)

Further down it is mentioned that:

> it’s possible to build ParaView with onscreen and headless support  
> simultaneously
> 
> Is this a fault in the documentation?

Perhaps it could be more clear, as there are lots of combinations of  
options. However, I’ll leave it to someone else to chime in on that aspect.

Cheers,  
Scott

---

<div class="post-metadata">

### Author: ![Lukas](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lukas/32/114_2.png) [@Lukas](https://discourse.paraview.org/u/Lukas)
#### Post date: [July 6, 2018, 1:02pm UTC](https://discourse.paraview.org/t/pvpython-offscreen-rendering-segfault/246/5 "2018-07-06T13:02:36Z")

</div>

Hi Scott,

Thanks for your suggestion to use EGL. Unfortunately though, I don’t have a Nvidia GPU.

I need headless support to run tests on Travis-CI. I got it working using `xvfb`.  
For those who are interested; before running `pvpython` execute:

```auto
export DISPLAY=:99.0
util/xvfb-initd.sh start

```

[Here](https://github.com/BioDynaMo/biodynamo/blob/a6b19860daa0c7adee5b58df3b19d8e35dfbedcc/util/xvfb-initd.sh) the script to start the xvfb server.

Also check out [Travis’ documentation](https://docs.travis-ci.com/user/gui-and-headless-browsers/)

Thanks and all the best,  
Lukas
