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

enable EGL backend #42

Merged
merged 3 commits into from
Aug 19, 2019
Merged

enable EGL backend #42

merged 3 commits into from
Aug 19, 2019

Conversation

wangg12
Copy link
Contributor

@wangg12 wangg12 commented Aug 13, 2019

@MartinSmeyer
Copy link
Member

MartinSmeyer commented Aug 14, 2019

glInitBindlessTextureNV() returns False when running test_egl_meshrenderer_phong.py, i.e. the egl context in my environment. Also I get a memory leak that quickly kills the ae_train script at line 126 queue.start(sess) even when using glfw. I'm not sure why, yet.

@wangg12
Copy link
Contributor Author

wangg12 commented Aug 14, 2019

Could you check this. This is the only problem for me to get egl work.

@MartinSmeyer
Copy link
Member

thanks! After changing egl.py, the egl rendering was working with a connected display. However, headless rendering still gave eglinitialize errors .
Then, I changed to a newer OpenSuse Version (42.3->15.1) and hardware accelerated headless rendering just worked, independent of linking against libGL.so or libOpenGL.so. :-)
I checked with pyrender and our meshrenderer, both works in display and headless mode, so I will make egl the default.
Could you please check whether you also get a memory leak when running ae_train with your added code? It does not depend on the context.. After pinning it down, I will merge it.

@wangg12
Copy link
Contributor Author

wangg12 commented Aug 17, 2019

@MartinSmeyer Now I can train with the egl backend. What do you mean by memory leak? GPU memory leak or RAM memory leak?

@MartinSmeyer
Copy link
Member

The RAM was filling up. The problem was the python2 -> python3 port. I was running the code in python2 in debug mode, i.e.

ae_train test/me -d

You changed all xrange to range which in python2 does an explicit memory allocation.

for i in range(ae.global_step.eval(), num_iter):

In debug mode only, num_iter was set to

np.iinfo(np.int32).max 
Out[2]: 2147483647

Setting num_iter in debug mode to a lower number solved the problem.

@MartinSmeyer
Copy link
Member

Concerning the PyOpenGL hacks, I had to do this to make headless rendering work in osl42 but not in osl15. Thanks again for the pointer.

@MartinSmeyer MartinSmeyer merged commit 386049b into DLR-RM:master Aug 19, 2019
@wangg12
Copy link
Contributor Author

wangg12 commented Aug 19, 2019

Sorry, I didn't test python2. Glad that you have catched the problem. BTW, what are "osl42" and "osl15"?

@MartinSmeyer
Copy link
Member

OpenSuse42 and the successor OpenSuse15 are both linux distributions. There might have been some updates in the libraries.

@wangg12
Copy link
Contributor Author

wangg12 commented Aug 19, 2019

So the hack of egl.py is not needed in OpenSuse15? I had to hack it for both Ubuntu 14.04 and 16.04.

@MartinSmeyer
Copy link
Member

Yes, it seems like. Looking at the referenced

/usr/lib/python2.7/site-packages/OpenGL/platform/egl.py
def GL(self):
    try:
        return ctypesloader.loadLibrary(
            ctypes.cdll,
            'GL', 
            mode=ctypes.RTLD_GLOBAL 
        )

It still references GL. Might be that OpenGL.so is loaded elsewhere?

@MartinSmeyer
Copy link
Member

hmm, if this is an issue for both Ubuntu 14.04 and 16.04. I will make EGL a prominent option but not default. We can not assume every user to be allowed / know how to change PyOpenGL. Hope you are fine with that. A simple

export PYOPENGL_PLATFORM='egl'

will switch to egl mode.

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

Successfully merging this pull request may close these issues.

2 participants