Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

eduble/gl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

May 31 2021: I wrote this repository in hope it could be useful for anyone else, but this was a very temporary project for me. I am no longer working on this subject and have no time to maintain it. So this repository is now archived.

OpenGL headless on linux (EGL): sample program

This repository contains a sample python program which runs GPU computations (OpenGL) in headless mode (no display).

The program initializes an OpenGL context using EGL (and, optionally, GBM). It will connect to kernel DRM interface file at /dev/dri/<something>.

Then, to test if it works, it calls very basic OpenGL drawing functions to draw a blue rectangle, and writes a ppm image file.

Requirements

OS libs

In any case, you need appropriate GPU drivers, with libGL and libEGL. If you use a recent Nvidia driver, this will probably be enough. Otherwise (intel integrated GPU for example), the program will try load libgbm.

For example on an ubuntu OS with a mesa-compatible GPU, the following should work:

$ apt install libgl1-mesa-dri libegl1-mesa libgbm1

python libs

You need PyOpenGL and numpy:

$ pip install wheel
$ pip install pyopengl numpy

On my machine, I also had to fix file [python_dir]/site-packages/OpenGL/raw/EGL/_types.py, by applying this modification. It may be already fixed in your pyopengl distribution when you read this.

For more optimized transfers between PyOpenGL and numpy, do:

$ pip install Cython
$ pip install PyOpenGL_accelerate

How to run

To run the program, just type

$ ./main.py

Links

The code is mostly based on the following sample codes and documentation: