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

no backend in latest colab #2469

Closed
aduchon opened this issue Apr 12, 2023 · 9 comments
Closed

no backend in latest colab #2469

aduchon opened this issue Apr 12, 2023 · 9 comments

Comments

@aduchon
Copy link

aduchon commented Apr 12, 2023

Opening a brand new google colab (GPU or TPU) with simply:

!pip install vispy
import vispy
vispy.test()

It errors on every backend, ending with

Testing failed (['nobackend'] failed, ['pyqt4', 'pyqt5', 'pyqt6', 'pyside', 'pyside2', 'pyside6', 'pyglet', 'glfw', 'sdl2', 'wx', 'egl', 'osmesa', 'jupyter_rfb', '_test', 'examples'] skipped) in 4.874 seconds
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
[<ipython-input-1-2164daa7587a>](https://localhost:8080/#) in <cell line: 4>()
      2 
      3 import vispy
----> 4 vispy.test()

1 frames
[/usr/local/lib/python3.9/dist-packages/vispy/testing/_runners.py](https://localhost:8080/#) in test(label, extra_arg_string, coverage)
    444     sys.stdout.flush()
    445     if len(fail) > 0:
--> 446         raise RuntimeError('FAILURE')

RuntimeError: FAILURE

I hadn't tried using vispy before this week, so I don't know if this ever worked in a colab. I know other AI-related colabs have recently broken though. Is there a way to ensure a backend in a colab?

@djhoese
Copy link
Member

djhoese commented Apr 12, 2023

As stated in the install instructions, vispy does not install any backend by default. It is up to the user to install tye necessary dependencies. I don't know what platform colab runs on but you could try installing pyqt and see how that goes. Let us know how it goes.

@djhoese
Copy link
Member

djhoese commented Apr 15, 2023

Feel free to continue to comment here, but I'm not sure this is anything wrong or changed in vispy. Closing now. We can reopen if it turns out to be something needing fixing in vispy.

@djhoese djhoese closed this as completed Apr 15, 2023
@danilw
Copy link

danilw commented Apr 18, 2023

Well this is problem of Vispy it seems, or Google banned single Vispy package from accessing EGL.
I mean Vispy was working before with EGL on Colab, I have scripts I used so I know, and does not work anymore.
Only what changed on Colab as I know - they updated Nvidia driver to 525.85.12 version.
Nvidia driver update or Google block Vispy somehow, this is two cases I can see.

!pip install vispy

import vispy
vispy.use('EGL')
print(vispy.sys_info())

image

When on same Colab running moderngl EGL backend - works.

!pip install moderngl
and copy example from Wrong link look below for correct link

I tried few old versions of Vispy - same result.
Also tried other backends on Vispy - I have not found any working with OpenGL acceleration working.

@djhoese
Copy link
Member

djhoese commented Apr 18, 2023

Looks like EGL is available but can't be initialized:

image

This says to me that something has changed about the EGL installation or that colab used to create a virtual display but doesn't anymore:

https://stackoverflow.com/a/66952101/433202

I'll see if I can learn anything else. I know very little about EGL and no absolutely nothing about moderngl.

@djhoese
Copy link
Member

djhoese commented Apr 18, 2023

How exactly are you running moderngl examples? Did you download moderngl source? The example you linked to imports the relatively available ported package in the same directory which accesses a data directory in the examples folder.

@djhoese
Copy link
Member

djhoese commented Apr 18, 2023

Looking through moderngl source and its glcontext library I see custom EGL and X11 backends. The X11 default backend doesn't seem to initialize on colab, but EGL does. I'd have to compare their EGL C++ backend to our ctypes EGL backend.

@djhoese
Copy link
Member

djhoese commented Apr 18, 2023

As best I can tell the EGL functions called by glcontext are available from a "newer" extension to EGL: https://registry.khronos.org/EGL/extensions/EXT/EGL_EXT_platform_base.txt

And are used here: https://github.com/moderngl/glcontext/blob/8a6918336869296565a0cb4a6c7c510f26443762/glcontext/egl.cpp#L208-L237

Vispy's EGL usage does not use (or assume) that this extension is available, but apparently it should as it would make it work in more instances. Here's where Vispy uses these EGL functions:

vispy/vispy/ext/egl.py

Lines 235 to 250 in d776344

def eglGetDisplay(display=EGL_DEFAULT_DISPLAY):
"""Connect to the EGL display server."""
res = _lib.eglGetDisplay(display)
if not res or res == EGL_NO_DISPLAY:
raise RuntimeError('Could not create display')
return c_void_p(res)
def eglInitialize(display):
"""Initialize EGL and return EGL version tuple."""
majorVersion = (_c_int*1)()
minorVersion = (_c_int*1)()
res = _lib.eglInitialize(display, majorVersion, minorVersion)
if res == EGL_FALSE:
raise RuntimeError('Could not initialize')
return majorVersion[0], minorVersion[0]

CC @almarklein @rougier who I think have more experience with this type of stuff.

@danilw
Copy link

danilw commented Apr 18, 2023

How exactly are you running moderngl examples?

  1. !pip install moderngl
  2. I linked wrong example before, correct is https://github.com/moderngl/moderngl/blob/master/examples/headless_egl.py
  3. press Runtime-Run all

to display rendered image on Colab

from IPython.display import Image
Image('triangle.png')

image
image

@danilw
Copy link

danilw commented Apr 18, 2023

The example you linked to imports the relatively available ported package in the same directory which accesses a data directory in the examples folder.

I linked wrong example. sorry.

Correct example is https://github.com/moderngl/moderngl/blob/master/examples/headless_egl.py

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

3 participants