Skip to content

Commit 1640ecb

Browse files
committed
Tell CuPy to use our stream
1 parent 1d5d5ee commit 1640ecb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cuda_core/examples/cuda_graphs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def main():
4949
dev = Device()
5050
dev.set_current()
5151
stream = dev.create_stream()
52+
# tell CuPy to use our stream as the current stream:
53+
cp.cuda.ExternalStream(int(stream.handle)).use()
5254

5355
# Compile the program
5456
arch = "".join(f"{i}" for i in dev.compute_capability)
@@ -161,6 +163,8 @@ def main():
161163
assert cp.allclose(result2, expected_result2, rtol=1e-5, atol=1e-5), "Result 2 mismatch"
162164
assert cp.allclose(result3, expected_result3, rtol=1e-5, atol=1e-5), "Result 3 mismatch"
163165

166+
cp.cuda.Stream.null.use() # reset CuPy's current stream to the null stream
167+
164168
print("\nExample completed successfully!")
165169

166170

0 commit comments

Comments
 (0)