mujoco icon indicating copy to clipboard operation
mujoco copied to clipboard

[codex] Fix EGL CUDA device selection

Open devshahofficial opened this issue 7 months ago • 4 comments

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.

devshahofficial avatar Apr 27 '26 18:04 devshahofficial

@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.

devshahofficial avatar Apr 30 '26 15:04 devshahofficial

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 avatar Jun 02 '26 11:06 haroonq

@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.EGL wildcard import before the custom extension wrappers, while keeping the eglQueryDeviceAttribEXT wrapper because PyOpenGL may not expose that extension entry point directly and this path resolves it via eglGetProcAddress

I re-ran Python syntax checks and the local manual EGL-selection scenarios covering the egl_test.py cases.

devshahofficial avatar Jun 02 '26 17:06 devshahofficial

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.

devshahofficial avatar Jun 22 '26 16:06 devshahofficial

@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.

devshahofficial avatar Jul 07 '26 18:07 devshahofficial