Skip to content

Commit c77b358

Browse files
committed
samples/cuda_core: skip all glInterop samples if OpenGL unavailable
Catch OSError (FileNotFoundError is a subclass) when pyglet tries to load opengl32.dll on headless Windows CI runners (TCC/MCDM mode or missing display driver). Exit with EXIT_WAIVED so the test is skipped rather than failing. Applies the same fix to glInteropFluid, glInteropPlasma, and glInteropFluidNumbaCudaMlir (same root cause as glInteropMipmapLod). See: #2767
1 parent 20b84aa commit c77b358

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎samples/cuda_core/glInteropFluid/glInteropFluid.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ def create_window():
248248
file=sys.stderr,
249249
)
250250
sys.exit(1)
251+
except OSError as e:
252+
# OpenGL runtime not available (e.g. headless CI runner without opengl32.dll).
253+
print(f"OpenGL unavailable on this system ({e}); waiving this sample.")
254+
sys.exit(EXIT_WAIVED)
251255

252256
window = pyglet.window.Window(
253257
WIDTH,

‎samples/cuda_core/glInteropFluidNumbaCudaMlir/glInteropFluidNumbaCudaMlir.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@
3838
import colorsys
3939
import ctypes
4040
import math
41+
import os
4142
import random
4243
import sys
4344
import time
4445

46+
EXIT_WAIVED = int(os.environ.get("CUDA_PYTHON_SAMPLE_WAIVER_EXIT_CODE", "2"))
47+
4548
import numpy as np
4649

4750
# This port targets the MLIR-based numba-cuda backend (`numba-cuda-mlir`), which
@@ -403,6 +406,10 @@ def create_window():
403406
except ImportError:
404407
print("This example requires pyglet >= 2.0: pip install pyglet", file=sys.stderr)
405408
sys.exit(1)
409+
except OSError as e:
410+
# OpenGL runtime not available (e.g. headless CI runner without opengl32.dll).
411+
print(f"OpenGL unavailable on this system ({e}); waiving this sample.")
412+
sys.exit(EXIT_WAIVED)
406413
window = pyglet.window.Window(WIDTH, HEIGHT, caption="numba-cuda - Stable Fluids", vsync=False)
407414
return window, _gl, pyglet
408415

‎samples/cuda_core/glInteropPlasma/glInteropPlasma.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ def create_window():
131131
file=sys.stderr,
132132
)
133133
sys.exit(1)
134+
except OSError as e:
135+
# OpenGL runtime not available (e.g. headless CI runner without opengl32.dll).
136+
print(f"OpenGL unavailable on this system ({e}); waiving this sample.")
137+
sys.exit(EXIT_WAIVED)
134138

135139
window = pyglet.window.Window(
136140
WIDTH,

0 commit comments

Comments
 (0)