Skip to content

fix(samples): waive CUDA-GL interop on non-NVIDIA GL contexts - #3077

Merged
lijinf2 merged 2 commits into
NVIDIA:mainfrom
yimoj:fix/gl-interop-context-waiver
Oct 14, 2026
Merged

lijinf2 merged 2 commits into
NVIDIA:mainfrom
yimoj:fix/gl-interop-context-waiver

Conversation

@yimoj

@yimoj yimoj commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Description

Follow-up to the sample migration in #2959; related OpenGL availability handling is tracked in #2767 (this PR does not close that issue).

The migration replaced the old example wrapper's unconditional GL-sample skip with actual sample execution. A window can now open successfully on a non-NVIDIA GL context, such as Microsoft/D3D12, but these samples still attempt CUDA resource registration. The existing graphics tests already reject such contexts.

Reuse gl_context_not_on_nvidia_gpu_reason() in glInteropFluid, glInteropMipmapLod, and glInteropPlasma after creating the GL window and before registering CUDA resources. Ineligible contexts report the reason, close the window, and exit with the negotiated sample-waiver code. NVIDIA GL contexts continue normally, and genuine CUDA errors remain failures.

Only these three samples change. No new tests are added: the existing GL-helper tests cover vendor eligibility, and the sample harness already runs all three examples for three frames.

Validation

  • Ruff checks and formatting checks pass for the three changed samples.
  • python -m compileall -q passes for the three changed samples.
  • git diff --check passes.
  • Targeted existing sample tests could not collect locally because the environment has no importable CUDA package. WSL and native NVIDIA GL runtime validation remain outstanding; no hardware-backed success is claimed.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes (no documentation changes are required).

@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Oct 12, 2026
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/cuda-python/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 7a51acf4-4eb9-4bd5-9bc4-c8b733f1efbc
📥 Commits

Reviewing files that changed from the base of the PR and between 28b188f and 03fe8b8.

📒 Files selected for processing: 3
  • samples/cuda_core/glInteropFluid/glInteropFluid.py
  • samples/cuda_core/glInteropMipmapLod/glInteropMipmapLod.py
  • samples/cuda_core/glInteropPlasma/glInteropPlasma.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • The fluid, mipmap LOD, and plasma graphics interop samples now check whether the active OpenGL context is running on an NVIDIA GPU. If the context is unsupported, the sample displays the reason, closes its window, and exits as waived rather than attempting to run. With a supported context, the samples continue to run as usual.

The Fluid, MipmapLod, and Plasma samples now check whether their OpenGL context is on an NVIDIA GPU. If the helper reports an unsupported context, each sample prints the reason, closes the window, and exits with EXIT_WAIVED.

Changes: OpenGL context waivers

Layer / File(s) Summary
Load the helper and check the GL context
samples/cuda_core/glInteropFluid/glInteropFluid.py, samples/cuda_core/glInteropMipmapLod/glInteropMipmapLod.py, samples/cuda_core/glInteropPlasma/glInteropPlasma.py
Each sample imports the shared context-check helper. After window creation, each sample checks the context and exits with EXIT_WAIVED when the helper returns a reason.

Suggested reviewers: danielfrg

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 03fe8

These samples now waive before CUDA registration when GL reports a non-NVIDIA vendor, avoiding the unsupported interop path. No concrete source-level merge blocker is established; hardware-backed validation can remain a follow-up.

✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

@juenglin
juenglin requested a review from lijinf2 October 12, 2026 18:55

@lijinf2 lijinf2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@lijinf2
lijinf2 enabled auto-merge (squash) October 14, 2026 05:47
@lijinf2 lijinf2 added the bug Something isn't working label Oct 14, 2026
@lijinf2

lijinf2 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

The PR needs an additional label "Bug" besides cuda.core to get CI green. I just added the label.

Thank you for the PR @yimoj !

@yimoj

yimoj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

@lijinf2 while you're here, please help set assignee too, which seems to be required by CI as well.

@lijinf2 lijinf2 added this to the cuda.core 1.2.x milestone Oct 14, 2026
@lijinf2
lijinf2 merged commit 3f58a7b into NVIDIA:main Oct 14, 2026
110 of 113 checks passed
@yimoj
yimoj deleted the fix/gl-interop-context-waiver branch October 14, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.core Everything related to the cuda.core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants