Skip to content

Commit 7ea1361

Browse files
committed
xfail tests if CUDA not available
1 parent ae3295b commit 7ea1361

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

rtxpy/rtx.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ def __init__(self):
3939
c_lib.traceRTX.restype = ctypes.c_int
4040
c_lib.cleanRTX.restype = ctypes.c_int
4141
c_lib.getHashRTX.restype = ctypes.c_uint64
42-
if c_lib.initRTX():
43-
free_optix_resources()
44-
raise RuntimeError("Failed to initialize RTX library")
45-
else:
46-
atexit.register(free_optix_resources)
4742
except:
4843
raise RuntimeError("Failed to load RTX library")
4944

45+
if c_lib.initRTX():
46+
free_optix_resources()
47+
raise RuntimeError("Failed to initialize RTX library")
48+
else:
49+
atexit.register(free_optix_resources)
50+
5051
def build(self, hashValue, vertexBuffer, indexBuffer):
5152
if has_cupy and isinstance(vertexBuffer, cupy.ndarray):
5253
vb = ctypes.c_ulonglong(vertexBuffer.data.ptr)

rtxpy/tests/test_simple.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ def test_simple(test_cupy):
2121
rays = backend.float32([0.33,0.33,100,0,0,0,-1,1000])
2222
hits =backend.float32([0,0,0,0])
2323

24-
optix = RTX()
24+
try:
25+
optix = RTX()
26+
except RuntimeError as e:
27+
# RTX fails to initialize if CUDA not available.
28+
if str(e) == "Failed to initialize RTX library":
29+
pytest.xfail("CUDA not available")
30+
raise
2531

2632
res = optix.build(0, verts, triangles)
2733
assert res == 0

0 commit comments

Comments
 (0)