Can't select GPU for EGL headless rendering

See original GitHub issue

TL;DR - how can I select the GPU that the EGL headless rendering runs on? I want to use /dev/nvidia2 but it seems only /dev/nvidia0 is supported.

===

I have two machines in the cloud that are Docker containers of the same image (Ubuntu). When I run the code from the EGL offscreen rendering colab notebook as a Python script, one renders the bottle well, while the other gives me the error below. The working machine has its GPU mounted on /dev/nvidia0 while on the faulty machine it is on /dev/nvidia2.

It seems that egl_display = egl.eglGetDisplay(egl.EGL_DEFAULT_DISPLAY) tries picking on /dev/nvidia0 and fails if it is not available. Since I can’t control where will the GPU get mounted on my machine, is there a way to make OpenGL/EGL pick the other device? I tried multiple solutions found around the web, from different environment variables to creating a symlink, but to no avail.

The error:

Traceback (most recent call last):
  File "colab", line 30, in <module>
    r = pyrender.OffscreenRenderer(640, 480)
  File "/miniconda/envs/foo/lib/python3.6/site-packages/pyrender/offscreen.py", line 31, in __init__
    self._create()
  File "/miniconda/envs/foo/lib/python3.6/site-packages/pyrender/offscreen.py", line 134, in _create
    self._platform.init_context()
  File "/miniconda/envs/foo/lib/python3.6/site-packages/pyrender/platforms/egl.py", line 177, in init_context
    assert eglInitialize(self._egl_display, major, minor)
  File "/miniconda/envs/foo/lib/python3.6/site-packages/OpenGL/platform/baseplatform.py", line 402, in __call__
    return self( *args, **named )
  File "/miniconda/envs/foo/lib/python3.6/site-packages/OpenGL/error.py", line 232, in glCheckError
    baseOperation = baseOperation,
OpenGL.error.GLError: GLError(
	err = 12290,
	baseOperation = eglInitialize,
	cArguments = (
		<OpenGL._opaque.EGLDisplay_pointer object at 0x7f7c9f107400>,
		c_long(0),
		c_long(0),
	),
	result = 0
)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
keunhongcommented, Jan 15, 2020

I submitted a PR (https://github.com/mmatl/pyrender/pull/60) a couple months ago that does this.

Just set the environment variable EGL_DEVICE_ID e.g.

export EGL_DEVICE_ID=1
python run.py
1reaction
oarriagacommented, Feb 21, 2020

I also had the following issue:

OpenGL.error.GLError: GLError( err = 12290,

It was related to incompatible versions of pyrender and PyOpenGL.

However, is not working for me using headless rendering with EGL. I now have the following error

Read more comments on GitHub >

github_iconTop Results From Across the Web

EGL Eye: OpenGL Visualization without an X Server
The reason is that it's not sufficient to enable OpenGL rendering on the GPUs (See my previous blog post for more details), but...
Read more >
Offscreen Rendering — pyrender 0.1.45 documentation
If you're using a headless server, you'll need to use either EGL (for GPU-accelerated rendering) or OSMesa (for CPU-only software rendering).
Read more >
765284 - Support GPU hardware in headless mode - Monorail
I'm running instances on Amazon EC2 which seem to support Nvidia GPUs, so I'd be over the moon with anything that allowed headless...
Read more >
Ovito headless OpenGL rendering on G4dn AWS instance
I am trying to render images with Ovito on an amazon EC2 instance with ... libary: ImportError: libEGL.so.1: cannot open shared object file: ......
Read more >
[Linux/EGL] Use correct rendering device in multi-GPU setup
For instance, if Mesa is rendering on a different GPU than the compositor is using for its rendering, then it must make sure...
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