Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't select GPU for EGL headless rendering #92

Open
guy4261 opened this issue Dec 9, 2019 · 10 comments
Open

Can't select GPU for EGL headless rendering #92

guy4261 opened this issue Dec 9, 2019 · 10 comments

Comments

@guy4261
Copy link

guy4261 commented Dec 9, 2019

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
)
@guy4261
Copy link
Author

guy4261 commented Dec 12, 2019

Does it make sense that if my nvidia device is /dev/nvidia1 or /dev/nvidia2 then it doesn't get picked up as the egl.EGL_DEFAULT_DISPLAY? Is there an environment variable I should set for this case? (Like I'm setting PYOPENGL_PLATFORM=egl before import pyrender?)

@guy4261 guy4261 changed the title EGL headless rendering sometimes works, sometimes not EGL headless rendering does not if GPU is mounted on /dev/nvidia2 Dec 12, 2019
@guy4261 guy4261 changed the title EGL headless rendering does not if GPU is mounted on /dev/nvidia2 EGL headless rendering on /dev/nvidia2 Dec 12, 2019
@guy4261 guy4261 changed the title EGL headless rendering on /dev/nvidia2 Can't select GPU for EGL headless rendering Dec 12, 2019
@Guptajakala
Copy link

@guy4261 Hi, I'm meeting the same issue. Have you resolve it?
On my machine I indeed have /dev/nvidia0 but still get that error. Are you sure your two machines have the only difference in that /dev/nvidia id?

@guy4261
Copy link
Author

guy4261 commented Jan 8, 2020

@Guptajakala sorry - 1. I didn't solve this, 2. I do believe that on my machine it's the /dev/nvidiaN issue, perhaps you are experiencing something else I can't help with :(

@keunhong
Copy link

I submitted a PR (#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

@guy4261
Copy link
Author

guy4261 commented Jan 15, 2020

Great @keunhong !!! Thanks!!!
Does this mean I should for now build from master rather then install with pip?

@Guptajakala
Copy link

@guy4261 I dont think you need. Just run export EGL_DEVICE_ID=1 before you run your python file.
However, it still doesn't work in my case, maybe my server has some wierd things. Please let me know if it works for you.

@keunhong
Copy link

Great @keunhong !!! Thanks!!!
Does this mean I should for now build from master rather then install with pip?

Looks like the commit should be in 0.1.33 so shouldn't be necessary.

@oarriaga
Copy link

oarriaga commented 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

@grgkopanas
Copy link

@oarriaga What was the incompatibility issue and what was eventually the compatible versions that you used?

@vstadnytskyi-FDA
Copy link

I submitted a PR (#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

How do I do this on Windows 11?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants