Skip to content

Instantly share code, notes, and snippets.

@tstellanova
Last active August 9, 2019 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tstellanova/399b46352711dc3b75b5462e6ba6bc30 to your computer and use it in GitHub Desktop.
Save tstellanova/399b46352711dc3b75b5462e6ba6bc30 to your computer and use it in GitHub Desktop.
Create a framebuffer for headless GPU operations

If you attempt to run GPU rendering code (such as OpenGL code) while ssh'd to a server, you'll get errors such as:

    Running `/home/rockpi/proj/glutin/target/debug/examples/headless`
thread 'main' panicked at 'Failed to initialize any backend! Wayland status: NoCompositorListening X11 status: XOpenDisplayFailed', /home/rockpi/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.20.0-alpha2/src/platform_impl/linux/mod.rs:480:9

If you check echo $DISPLAY you'll see that no display is set.

To remedy this, install xvfb: sudo apt install xvfb

Then you can run eg:

Xvfb :1 -screen 1 1600x1200x16&
export DISPLAY=:1

Followed by whatever OpenGL code you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment