# VTK 8.2 + EGL offscreen rendering, nvidia driver 440.33.01

**URL:** https://discourse.vtk.org/t/vtk-8-2-egl-offscreen-rendering-nvidia-driver-440-33-01/2607
**Category:** Support
**Created:** [February 13, 2020, 12:19pm UTC](https://discourse.vtk.org/t/vtk-8-2-egl-offscreen-rendering-nvidia-driver-440-33-01/2607 "2020-02-13T12:19:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Sophonet](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Sophonet](https://discourse.vtk.org/u/Sophonet)
#### Post date: [February 13, 2020, 12:19pm UTC](https://discourse.vtk.org/t/vtk-8-2-egl-offscreen-rendering-nvidia-driver-440-33-01/2607/1 "2020-02-13T12:19:30Z")

</div>

Hi there,

I am interested in EGL-accelerated offscreen rendering and have read [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/).

I have successfully built VTK 8.2.0 with using GCC 7 on a 1.1-glvnd-devel-centos7` container from docker hub. CMake flags include ‘’’-D VTK\_RENDERING\_BACKEND=“OpenGL2” -D VTK\_OPENGL\_HAS\_EGL=True -D VTK\_USE\_X=False’’’.

in the container, nvidia-smi shows graphics devices as expected, and rw = vtk.vtkRenderWindow(), rw.GetNumberOfDevices() matches that. However, when further running rendering-related code (windowToImageFilter), I see the error pasted below. An explicit rw.SetDeviceIndex() does not change this behavior.

Any ideas (also on how to efficiently continue debugging)?

Thanks,

```
 Sophonet

```

: 0x400c20 : ??? [(???) ???:-1]  
Generic Warning: In /build/VTK-8.2.0/Rendering/OpenGL2/vtkOpenGLState.cxx, line 617  
Error glEnable/Disable1 OpenGL errors detected  
0 : (1282) Invalid operation

with stack trace of  
0x7f41aeb2459b : vtksys::SystemInformationImplementation::GetProgramStack(int, int) [(libvtksys-8.2.so.1) ???:-1]  
0x7f41aeb1f6e6 : vtksys::SystemInformation::GetProgramStack(int, int) [(libvtksys-8.2.so.1) ???:-1]  
0x7f41b90d0a38 : ??? [(???) ???:-1]  
0x7f41b90d21b9 : vtkOpenGLState::SetEnumState(unsigned int, bool) [(libvtkRenderingOpenGL2-8.2.so.1) ???:-1]  
0x7f41b90d3027 : vtkOpenGLState::vtkglDisable(unsigned int) [(libvtkRenderingOpenGL2-8.2.so.1) ???:-1]  
0x7f41b90afcec : vtkOpenGLRenderWindow::ReadPixels(vtkRecti const&, int, int, int, void\*, int) [(libvtkRenderingOpenGL2-8.2.so.1) ???:-1]  
0x7f41b90af8b8 : vtkOpenGLRenderWindow::GetPixelData(int, int, int, int, int, int) [(libvtkRenderingOpenGL2-8.2.so.1) ???:-1]

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [February 13, 2020, 3:34pm UTC](https://discourse.vtk.org/t/vtk-8-2-egl-offscreen-rendering-nvidia-driver-440-33-01/2607/2 "2020-02-13T15:34:09Z")

</div>

I suggest first getting this to work directly, not inside a container. This way eliminate one possible source of problems.  
Your cmake parameters look right.

---

<div class="post-metadata">

### Author: ![Sophonet](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Sophonet](https://discourse.vtk.org/u/Sophonet)
#### Post date: [February 14, 2020, 8:57am UTC](https://discourse.vtk.org/t/vtk-8-2-egl-offscreen-rendering-nvidia-driver-440-33-01/2607/3 "2020-02-14T08:57:04Z")

</div>

Thanks for the hint. The container was not the problem and indeed, I found the problem, which was doing VTK rendering on the same render window from multiple threads, which should be avoided.

I have now implemented message passing etc. such that all VTK-related rendering code occurs in the same thread (which is not the main thread though), and I am seeing similar problems (“function is no/op” etc.)

Are there any special details to consider for EGL/multi-threading?

---

<div class="post-metadata">

### Author: ![Sophonet](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Sophonet](https://discourse.vtk.org/u/Sophonet)
#### Post date: [February 14, 2020, 10:07am UTC](https://discourse.vtk.org/t/vtk-8-2-egl-offscreen-rendering-nvidia-driver-440-33-01/2607/4 "2020-02-14T10:07:20Z")

</div>

Found another problem, now everything works inside a single thread. This topic can be closed now I guess…

---

<div class="post-metadata">

### Author: ![Sophonet](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Sophonet](https://discourse.vtk.org/u/Sophonet)
#### Post date: [February 22, 2020, 1:31pm UTC](https://discourse.vtk.org/t/vtk-8-2-egl-offscreen-rendering-nvidia-driver-440-33-01/2607/5 "2020-02-22T13:31:13Z")

</div>

Well, unfortunately the problem is not completely solved. My code now indeed runs on the native host (as written a few days ago), but still not inside the container. The problem is the same as in my original e-mail. Debugging now revealed that ```vtkglDisable(GL_SCISSOR_TEST)`` causes the crash inside the container.

I could reproduce the issue with a example [https://lorensen.github.io/VTKExamples/site/Python/Medical/MedicalDemo3](https://lorensen.github.io/VTKExamples/site/Python/Medical/MedicalDemo3), in which I have removed the lines

```auto
    # Interact with the data.
    renWin.Render()
    iren.Initialize()
    iren.Start()

```

and replaced with

```auto
    w2i = vtk.vtkWindowToImageFilter()
    w2i.SetInput(renWin)
    w2i.Update()

    wri = vtk.vtkPNGWriter()
    wri.SetInputConnection(w2i.GetOutputPort())
    wri.SetFileName('out.png')
    wri.Write()

```

(Pasted here since I cannot attach files).

Any idea? Does this occur elsewhere as well?

Thanks,

```
 Sophonet
```
