Skip to content

Commit 06a71be

Browse files
authored
Updates benchmarks to allow for running in a CPU-only environment (rapidsai#165)
Updates benchmarks to allow for running in a CPU-only environment. Authors: - Rick Ratzel (https://github.com/rlratzel) Approvers: - Ralph Liu (https://github.com/nv-rliu) URL: rapidsai#165
1 parent 72813b2 commit 06a71be

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

benchmarks/pytest-based/bench_algos.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import random
1515
from collections.abc import Mapping
1616

17+
import cupy as cp
1718
import networkx as nx
1819
import numpy as np
1920
import pandas as pd
@@ -66,10 +67,14 @@
6667
def setup_module(module):
6768
"""
6869
Trivial conversion call to force various one-time CUDA initialization
69-
operations to happen outside of benchmarks.
70+
operations to happen outside of benchmarks (if GPU is available).
7071
"""
71-
G = nx.karate_club_graph()
72-
nxcg.from_networkx(G)
72+
if cp.cuda.is_available():
73+
print("CUDA is available, running one-time code to force initialization.")
74+
G = nx.karate_club_graph()
75+
nxcg.from_networkx(G)
76+
else:
77+
print("CUDA is not available, skipping one-time code to force initialization.")
7378

7479

7580
# Test IDs are generated using the lambda assigned to the ids arg to provide an

0 commit comments

Comments
 (0)