Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cuda_bindings_13/tests/test_graphics_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
gl_context_not_on_nvidia_gpu_reason,
is_gl_context_unavailable,
open_gl_window,
select_headless_egl_device_for_cuda,
tcc_skip_reason,
)

Expand All @@ -22,12 +23,20 @@


def _configure_pyglet_headless():
"""On headless Linux: enable EGL mode or skip if EGL is absent."""
"""On headless Linux: enable EGL mode, matched to CUDA device 0, or skip if EGL is absent."""
if sys.platform.startswith("linux") and not (os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY")):
if ctypes.util.find_library("EGL") is None:
pytest.skip("No DISPLAY and no EGL runtime available for headless context.")
pyglet.options["headless"] = True

# CUDA_VISIBLE_DEVICES does not reorder EGL's device enumeration, so on
# headless multi-GPU systems EGL device 0 may not be the physical GPU
# behind CUDA device 0, which these tests register against. Pick the
# EGL device that the driver reports as corresponding to it.
egl_device = select_headless_egl_device_for_cuda(0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Stability & Availability · Quick win

important: Preserve GL-unavailable skips during the probe.

If find_library("EGL") finds a library that cannot be loaded, the selector raises ImportError before the existing is_gl_context_unavailable handler. The tests now fail instead of skipping. Include _configure_pyglet_headless() in that handler’s try block. (raw.githubusercontent.com)

if egl_device is not None:
pyglet.options["headless_device"] = egl_device


def _allocate_gl_texture(win):
"""Allocate a 2-D RGBA8 texture. Caller must have a current GL context.
Expand Down
Loading