question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document how to use VTK/vtki in Docker containers & Travis

See original GitHub issue

Trying to run any VTKI rendering within a Dockerized Jupyter notebook causes a kernel crash, with the message:

ERROR: In ../Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx, line 452
vtkXOpenGLRenderWindow (0x560a53bb7ce0): bad X server connection. DISPLAY=[I 00:12:28.476 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
kernel 0839b810-c699-472b-bd57-11c5cfed7fa5 restarted

I believe this is a more fundamental issue than VTKI (I have a VTK issue open here), but I am hoping that someone else using VTKI has experienced this and has a workaround, or that there is a way to run VTKI in ‘headless’ (virtual framebuffer) mode.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
daniellivingstoncommented, Apr 8, 2019

Thank you so much! You’ve been so helpful.

I was having trouble propagating environment var DISPLAY to the subshell that Python lives in (it turns out it’s a little tricky in Docker to do this…), but I settled on this as a working solution:

def activate_virtual_framebuffer():
    '''
    Activates a virtual (headless) framebuffer for rendering 3D
    scenes via VTK.

    Most critically, this function is useful when this code is being run
    in a Dockerized notebook, or over a server without X forwarding.

    * Requires the following packages:
      * `sudo apt-get install libgl1-mesa-dev xvfb`
    '''

    import subprocess
    import vtki

    vtki.OFFSCREEN = True
    os.environ['DISPLAY']=':99.0'

    commands = ['Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &',
                'sleep 3',
                'exec "$@"']

    for command in commands:
        subprocess.call(command,shell=True)

And then, on module import, I check if I’m in the Docker container (in a rather inelegant way…) and run the function from there:

if os.path.isdir('/home/jovyan'):
    activate_virtual_framebuffer()

Thank you again!

1reaction
banesullivancommented, Apr 7, 2019

It’s going to really bring it to the masses.

Hopefully, this gets it started:

Now all examples from the gallery are available on MyBinder 🎉 Binder 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Terms of Use - Viki
You agree that any notice, agreements, disclosure or other communications relating to your Account, the Rakuten Viki Service or any part thereof ...
Read more >
vimwiki/vimwiki: Personal Wiki for Vim - GitHub
Organize notes and ideas; Manage to-do lists; Write documentation; Maintain a diary; Export everything to HTML. To do a quick start, press <Leader> ......
Read more >
Rakuten Viki - Senior Software Engineer - NodeFlair
Apply for a Senior Software Engineer role at Rakuten Viki. Read about the role and find out if it's right for you. Discover...
Read more >
Untitled
#exitos Think critically and analytically, That acapulco gold, ... Santa clara vanguard 1999, Gor hakobyan erger, How can i use degradation in a...
Read more >
Untitled
Dom w 3 mce, Mabat 2000 israel, Link between project and prps, Amour pour 2 femmes, ... Preventivo edile doc, Olatunji yearwood twitter,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found