[codex] Fix EGL CUDA device selection
Summary
- map EGL devices to CUDA device IDs when the NVIDIA EGL CUDA device extension is available
- respect simple integer CUDA_VISIBLE_DEVICES mappings when selecting MUJOCO_EGL_DEVICE_ID
- add mocked EGL selection tests for raw EGL order, CUDA order, and CUDA_VISIBLE_DEVICES cases
Fixes #3245
Testing
- python -m pytest -q python/mujoco/egl_test.py
- python -m compileall -q python/mujoco/egl python/mujoco/egl_test.py
- git diff --check
Notes
I do not have access to a multi-GPU NVIDIA/EGL host in this environment, so the hardware-specific behavior is covered by mocked EGL tests rather than an end-to-end nvidia-smi validation.
@haroonq @yuvaltassa this is now marked ready for review. Would one of you, or another active maintainer/contributor, be able to take a look when you have bandwidth? Happy to follow up on any requested changes or adjust the approach if there is a better direction.
Sorry for the late response. TBH, I'm not super familiar with what you're trying to do so it's taken me a while to wrap my head around it.
@haroonq thanks for the careful pass here. I pushed follow-ups in d70f9497 and 2736609a to address the EGL selection threads:
- the CUDA-to-EGL map is now built once and passed through the selection helpers
- the parsed CUDA device list is passed as an argument instead of being re-read inside the helper
- renamed the map to
cuda_to_egl_device - centralized the logical-vs-physical device candidate logic
- moved the
OpenGL.EGLwildcard import before the custom extension wrappers, while keeping theeglQueryDeviceAttribEXTwrapper because PyOpenGL may not expose that extension entry point directly and this path resolves it viaeglGetProcAddress
I re-ran Python syntax checks and the local manual EGL-selection scenarios covering the egl_test.py cases.
Small ping: this is approved and still mergeable, with the last matrix green. Happy to rebase for a fresh run if you’d prefer that before submit.
@haroonq this one is still approved, mergeable, and green. I do not think another code change is needed here.
If you are good with it, could you submit when you have a minute? Happy to rebase/rerun if you want a super fresh matrix, but imo this is ready.