Skip to content

Commit 67ecb8b

Browse files
authored
Catch CUDARuntimeError in CuPy GPU check (rapidsai#166)
Catch `CUDARuntimeError` in the benchmarks when checking for a GPU and treat it as no GPU is available. Authors: - https://github.com/jakirkham - Rick Ratzel (https://github.com/rlratzel) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: rapidsai#166
1 parent 06a71be commit 67ecb8b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

benchmarks/pytest-based/bench_algos.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ def setup_module(module):
6969
Trivial conversion call to force various one-time CUDA initialization
7070
operations to happen outside of benchmarks (if GPU is available).
7171
"""
72-
if cp.cuda.is_available():
72+
has_cuda_gpu = False
73+
try:
74+
has_cuda_gpu = cp.cuda.is_available()
75+
except cp.cuda.runtime.CUDARuntimeError:
76+
# Treat errors as no GPU available.
77+
# xref: https://github.com/cupy/cupy/issues/9091
78+
pass
79+
80+
if has_cuda_gpu:
7381
print("CUDA is available, running one-time code to force initialization.")
7482
G = nx.karate_club_graph()
7583
nxcg.from_networkx(G)

0 commit comments

Comments
 (0)