You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(cuda.bindings): run the headless-EGL GL interop test on CUDA 12 and require cudaSuccess - #3653
cuda_bindings_12's test_graphics_api_smoketest needed DISPLAY or WAYLAND_DISPLAY, so it skipped on every Linux runner. cuda_bindings_13 already has a headless-EGL replacement, test_cuda_gl_register_image_smoketest (#3276). This PR shares that test's GL setup and uses it in both roots:
cuda_python_test_helpers/graphics.py
+ configure_pyglet_headless() # headless EGL on the device behind CUDA device 0+ allocate_gl_texture()+ gl_context() # TCC skip, headless setup, NVIDIA-GL check, cleanup
cuda_bindings_13/tests/test_graphics_apis.py
- _configure_pyglet_headless / _allocate_gl_texture / _gl_context+ from cuda_python_test_helpers.graphics import gl_context
cuda_bindings_12/tests/test_graphics_apis.py # now identical to the CUDA 13 file
- test_graphics_api_smoketest # DISPLAY only+ test_cuda_gl_register_image_smoketest[None, WriteDiscard]
Both roots now require success:
- acceptable = {"cudaSuccess", "cudaErrorOperatingSystem"}- assert name in acceptable- if name == "cudaSuccess":- assert int(resource) != 0- cudart.cudaGraphicsUnregisterResource(resource)+ assert name == "cudaSuccess"+ assert int(resource) != 0+ (err,) = cudart.cudaGraphicsUnregisterResource(resource)+ assert cudaGetErrorName(err) == "cudaSuccess"
The helpers import pytest and pyglet inside the functions, because the cuda.core GL samples import graphics outside pytest and the module must not import pyglet at load time.
The "not currently run in any CI job" comment goes away with the old test.
Evidence
CI coverage:
CUDA 12: on main, test_graphics_api_smoketest skips in all 20 configurations. After this change the GL test should pass on the 12 Linux CUDA 12 rows (x86-64 and aarch64; T4, V100, L4, A100, RTX PRO 6000). The WSL row should skip with "GL context is not on an NVIDIA GPU", and the 7 Windows rows skip (TCC, or no opengl32), as on CUDA 13.
CUDA 13: the test already passes on 20 Linux rows; requiring cudaSuccess tightens only those rows.
.github/workflows/test-wheel-linux.yml installs libegl1 for every Linux row.
Locally (headless, DISPLAY and WAYLAND_DISPLAY unset): all three tests in each file pass, the CUDA 13 file against cuda-bindings 13.5 and the CUDA 12 file against cuda-bindings 12.9.11.
Confirming in CI: in this PR's CI run, the Linux CUDA 12 cuda.bindings jobs should report test_cuda_gl_register_image_smoketest PASSED for both flags. For example:
gh run view <CI run id> --repo NVIDIA/cuda-python --log | grep -F "test_graphics_apis.py::test_cuda_gl_register_image_smoketest"
Merge Danger
Door: two-way. Test-only change.
Blast Radius: the GL interop tests in both bindings roots and cuda_python_test_helpers.graphics (existing functions unchanged; three added). If a CUDA 13 row has been passing on cudaErrorOperatingSystem, it now fails, which would expose a real interop problem.
Reviewers: please feel free to push commits directly to this PR to improve it.
…and require cudaSuccess
cuda_bindings_12's test_graphics_api_smoketest needed DISPLAY or
WAYLAND_DISPLAY, so it skipped on every Linux runner. cuda_bindings_13
already has a headless-EGL test (test_cuda_gl_register_image_smoketest).
Move that test's GL setup into cuda_python_test_helpers.graphics as public
helpers (configure_pyglet_headless, allocate_gl_texture, gl_context), and
use them from an identical test file in both roots, replacing the old CUDA
12 test.
In both roots, require cudaGraphicsGLRegisterImage and
cudaGraphicsUnregisterResource to return cudaSuccess. The
cudaErrorOperatingSystem allowance (NVIDIA#1210) predates the check that the GL
context is on an NVIDIA GPU (NVIDIA#3276); gl_context() now skips that case
before registering.
ClosesNVIDIA#3575.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Graphics API checks now verify successful CUDA/OpenGL resource registration and unregistration with multiple registration options.
Graphics test setup is shared across supported CUDA versions, with handling for headless environments and unavailable or unsupported graphics contexts.
The pull request adds shared OpenGL context and texture helpers. Tests in both CUDA bindings roots use those helpers and require successful image registration, a nonzero resource, and successful unregistration.
The helper configures headless pyglet on supported Linux systems, allocates a texture, and manages context and texture cleanup.
Registration checks in both bindings roots cuda_bindings_12/tests/test_graphics_apis.py, cuda_bindings_13/tests/test_graphics_apis.py
Both tests use the shared context. They require cudaSuccess, a nonzero resource, and successful unregistration. CUDA 12 also tests both registration flag values.
Assessment against linked issues
Objective
Addressed
Explanation
Port the headless-EGL GL interop test to CUDA 12 and require successful registration in both bindings roots [#3575]
✅
Require a nonzero resource and successful unregistration in both roots [#3575]
✅
Possibly related issues
NVIDIA/cuda-python#3576: This PR adds shared headless EGL helpers used by the bindings tests, but does not update the cuda.core GL samples described in the issue.
Test setup can error instead of skipping when libEGL is present but cannot load its dependencies. Moving the configuration call inside the existing try fixes this. Production code is unaffected, so the risk of merging is low.
Security architecture risk: Minimal · up to 5c1a1
The change shares graphics setup between the CUDA 12 and CUDA 13 smoke tests and makes those tests stricter without changing the CUDA bindings interface.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Finishing TouchesFix failing CI checks
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 8 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
important: Move configure_pyglet_headless() into the try in gl_context.
When libEGL is found but one of its dependencies fails to load, the EGL import in select_headless_egl_device_for_cuda raises ImportError('Library "EGL" not found.'). That import (lines 62-63) runs before the helper's own try, so the error propagates through configure_pyglet_headless() and out of gl_context(). is_gl_context_unavailable() handles this error only inside the try that wraps open_gl_window(). The test therefore errors instead of skipping. Before this change, the CUDA 12 test skipped in this headless environment. Both CUDA roots use gl_context(), so both are affected.
Move the call inside the existing try. The classifier then skips on this error, and other exceptions still propagate.
Suggested fix
--- "a/cuda_python_test_helpers/cuda_python_test_helpers/graphics.py"+++ "b/cuda_python_test_helpers/cuda_python_test_helpers/graphics.py"@@ -288,10 +288,9 @@
if reason := tcc_skip_reason():
pytest.skip(reason)
- configure_pyglet_headless()-
try:
+ configure_pyglet_headless()
win = open_gl_window()
except Exception as e:
if is_gl_context_unavailable(e):
pytest.skip(f"Could not create GL context: {type(e).__name__}: {e}")
P2 · The smoke test can pair OpenGL with the wrong CUDA device. An X11 display can render on NVIDIA GPU A while CUDA_VISIBLE_DEVICES exposes only GPU B. The NVIDIA vendor check still passes, so the strict registration assertion can fail because of the device pairing. Headless setup also assumes CUDA device 0 without selecting it. Match EGL to the active CUDA device and use cudaGLGetDevices() to check the association before requiring registration success. This is a source-level finding. EGL setup · CUDA API
P3 · A discoverable but unloadable EGL library fails setup. Headless configuration runs outside the handler that recognizes pyglet’s EGL ImportError. I reproduced the failure with the pinned pyglet and a mocked loader error. Moving configuration inside the existing setup try produced the expected skip. Setup handler
P3 · Mark the duplicated smoke test as synchronized. The CUDA 12 and CUDA 13 test files match byte-for-byte. Add matching SYNCED markers around the shared test so future edits preserve that parity. The existing PYTEST PLUGIN BOOTSTRAP blocks match across both bindings roots and Core. CUDA 12 test · CUDA 13 test
After asking which are existing problems:
The first two findings are inherited CUDA 13 setup issues. The PR changes where they can surface.
Wrong GPU pairing — existing setup issue, stricter assertion. CUDA 13 already selected EGL for CUDA device 0 and checked only the GL vendor. The PR preserves that setup and removes the allowance for cudaErrorOperatingSystem, so a mismatch that returns that status can now fail. CUDA 12 newly uses the same headless setup. Previous CUDA 13 test
Unloadable EGL — existing on CUDA 13, newly reachable on CUDA 12. The configuration call was already outside the try in CUDA 13. CUDA 12 previously skipped without a display, so porting the test exposes that failure path there. CodeRabbit’s fix would address the inherited issue in both roots. Previous CUDA 12 test
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cuda.bindingsEverything related to the cuda.bindings moduletestImprovements or additions to tests
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3575. Part of #2077.
Summary
cuda_bindings_12'stest_graphics_api_smoketestneededDISPLAYorWAYLAND_DISPLAY, so it skipped on every Linux runner.cuda_bindings_13already has a headless-EGL replacement,test_cuda_gl_register_image_smoketest(#3276). This PR shares that test's GL setup and uses it in both roots:Both roots now require success:
cudaErrorOperatingSystemallowance came from Maketest_cuda_gl_register_image_smoketest()more robust. #1210 ("typical when the driver/runtime refuses interop, e.g. no GPU/driver in CI container"). It predates the check that the GL context is on an NVIDIA GPU (test(cuda.bindings): select the matching EGL device for headless GL interop #3276), andgl_context()now skips that case before registering.pytestandpygletinside the functions, because the cuda.core GL samples importgraphicsoutside pytest and the module must not importpygletat load time.Evidence
CI coverage:
main,test_graphics_api_smoketestskips in all 20 configurations. After this change the GL test should pass on the 12 Linux CUDA 12 rows (x86-64 and aarch64; T4, V100, L4, A100, RTX PRO 6000). The WSL row should skip with "GL context is not on an NVIDIA GPU", and the 7 Windows rows skip (TCC, or noopengl32), as on CUDA 13.cudaSuccesstightens only those rows..github/workflows/test-wheel-linux.ymlinstallslibegl1for every Linux row.Locally (headless,
DISPLAYandWAYLAND_DISPLAYunset): all three tests in each file pass, the CUDA 13 file against cuda-bindings 13.5 and the CUDA 12 file against cuda-bindings 12.9.11.Confirming in CI: in this PR's CI run, the Linux CUDA 12 cuda.bindings jobs should report
test_cuda_gl_register_image_smoketestPASSED for both flags. For example:Merge Danger
Door: two-way. Test-only change.
Blast Radius: the GL interop tests in both bindings roots and
cuda_python_test_helpers.graphics(existing functions unchanged; three added). If a CUDA 13 row has been passing oncudaErrorOperatingSystem, it now fails, which would expose a real interop problem.Reviewers: please feel free to push commits directly to this PR to improve it.
🤖 Generated with Claude Code