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

Off-screen Volume Rendering on macos 14.7 #148

Open
HealthyPear opened this issue Oct 17, 2024 · 3 comments
Open

Off-screen Volume Rendering on macos 14.7 #148

HealthyPear opened this issue Oct 17, 2024 · 3 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@HealthyPear
Copy link

  • interactive volume rendering for yt version:
  • Python version:
  • Operating System:

Description

Off-screen Volume Rendering example on macos 14.7

What I Did

just ran the example then got

Traceback (most recent call last):
  File "/Users/michele/Software/3D_rendering_radio_data/yt-idv_examples/two.py", line 8, in <module>
    rc = yt_idv.render_context("egl", width=1024, height=1024)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/michele/Software/miniforge3/envs/radio_3d_renderer/lib/python3.12/site-packages/yt_idv/rendering_contexts/__init__.py", line 44, in render_context
    from .egl_context import EGLRenderingContext
  File "/Users/michele/Software/miniforge3/envs/radio_3d_renderer/lib/python3.12/site-packages/yt_idv/rendering_contexts/egl_context.py", line 4, in <module>
    from OpenGL import EGL, GL
  File "/Users/michele/Software/miniforge3/envs/radio_3d_renderer/lib/python3.12/site-packages/OpenGL/EGL/__init__.py", line 2, in <module>
    from OpenGL.raw.EGL._types import *
  File "/Users/michele/Software/miniforge3/envs/radio_3d_renderer/lib/python3.12/site-packages/OpenGL/raw/EGL/_types.py", line 77, in <module>
    CALLBACK_TYPE = _p.PLATFORM.functionTypeFor( _p.PLATFORM.EGL )
                                                 ^^^^^^^^^^^^^^^
AttributeError: 'DarwinPlatform' object has no attribute 'EGL'. Did you mean: 'CGL'?

same with "cgl"

@chrishavlin
Copy link
Contributor

Thanks for the report, @HealthyPear . It's possible that some extra setup is required off screen rendering on a mac -- I'll check it out later today on my laptop, will let you know what I find!

@chrishavlin chrishavlin self-assigned this Oct 18, 2024
@chrishavlin chrishavlin added bug Something isn't working documentation Improvements or additions to documentation labels Oct 18, 2024
@chrishavlin
Copy link
Contributor

Ok, so on the yt_idv side, I do think there's an issue with how environment variables are being set (this issue actually). Before importing yt_idv, you'll need to set PYOPENGL_PLATFORM='egl'. You can do this as an environment variable from your shell (e.g., export PYOPENGL_PLATFORM='egl') before starting your python session or from within your python session/script, just make sure it happens before all other imports:

import os
os.environ['PYOPENGL_PLATFORM'] = 'egl'

import yt_idv 
# etc.. 

If you've not separately installed any EGL-related libraries, you'll get a new error related to EGL not being found. For headless rendering, you'll need to separately install EGL or osmesa. We do need some improved documentation for this in yt_idv (at a minimum describing the requirements for headless rendering that yt_idv does not install for you). Unfortunately I don't yet have good instructions for you on a mac (working on it.... hopefully soon...). On my linux machines, I usually install the required packages as system level installs: for osmesa on ubuntu it's just sudo apt-get install libosmesa6-dev, for egl I follow these instructions. On a mac things don't seem quite as straightforward so far. There is a brew recipe for the mesa libraries that installed OK for me but i haven't yet got it working with yt_idv. I also just noticed the mesalib conda package that may also work but I haven't tested it yet. In any case, I'll update here if I actually get the headless rendering working on a mac.

@chrishavlin
Copy link
Contributor

Well one update! With the mesalib conda package it's very easy to setup osmesa headless rendering:

conda create --name yt_idv_mac python=3.10
conda activate yt_idv_mac
conda install mesalib
pip install yt_idv yt[enzo] pooch h5py 

export PYOPENGL_PLATFORM='osmesa'
python amr_osmesa.py

no luck with egl yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants