Skip to content

Commit d427c9b

Browse files
authored
Test cuda_core examples (#1800)
* Test cuda-core examples * Simplify further * Address comments in PR
1 parent 1086f40 commit d427c9b

17 files changed

+176
-79
lines changed

.github/workflows/test-wheel-linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ jobs:
100100
uses: ./.github/actions/install_unix_deps
101101
continue-on-error: false
102102
with:
103-
# for artifact fetching, graphics libs
104-
dependencies: "jq wget libgl1 libegl1"
103+
# for artifact fetching, graphics libs, g++ required for cffi in example
104+
dependencies: "jq wget libgl1 libegl1 g++"
105105
dependent_exes: "jq wget"
106106

107107
- name: Set environment variables

cuda_core/examples/cuda_graphs.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -10,6 +10,10 @@
1010
#
1111
# ################################################################################
1212

13+
# /// script
14+
# dependencies = ["cuda_bindings", "cuda_core", "nvidia-cuda-nvrtc", "cupy-cuda13x"]
15+
# ///
16+
1317
import sys
1418
import time
1519

@@ -121,6 +125,9 @@ def main():
121125
end_time = time.time()
122126

123127
graph_execution_time = end_time - start_time
128+
if graph_execution_time == 0.0:
129+
print("Graph execution time is too fast to measure accurately.")
130+
graph_execution_time = 1e-9 # Assign a small value to avoid division by zero in speedup calculation
124131
print(f"Graph execution time: {graph_execution_time:.6f} seconds")
125132

126133
# Verify results

cuda_core/examples/gl_interop_plasma.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@
5353
# effect popular in the demoscene). The window title shows the current FPS.
5454
# Close the window or press Escape to exit.
5555
#
56-
# Requirements
57-
# ============
58-
# pip install pyglet
56+
57+
# /// script
58+
# dependencies = ["cuda_bindings", "cuda_core>0.6.0", "pyglet"]
59+
# ///
5960

6061
import ctypes
6162
import sys

cuda_core/examples/jit_lto_fractal.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -12,6 +12,10 @@
1212
#
1313
# ################################################################################
1414

15+
# /// script
16+
# dependencies = ["cuda_bindings", "cuda_core", "nvidia-cuda-nvrtc", "cupy-cuda13x"]
17+
# ///
18+
1519
import argparse
1620
import sys
1721

cuda_core/examples/memory_ops.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -10,6 +10,10 @@
1010
#
1111
# ################################################################################
1212

13+
# /// script
14+
# dependencies = ["cuda_bindings", "cuda_core", "nvidia-cuda-nvrtc", "cupy-cuda13x"]
15+
# ///
16+
1317
import sys
1418

1519
import cupy as cp

cuda_core/examples/pytorch_example.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -9,6 +9,10 @@
99
#
1010
# ################################################################################
1111

12+
# /// script
13+
# dependencies = ["cuda_bindings", "cuda_core", "torch"]
14+
# ///
15+
1216
import sys
1317

1418
import torch

cuda_core/examples/saxpy.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -10,8 +10,17 @@
1010
#
1111
# ################################################################################
1212

13+
# /// script
14+
# dependencies = ["cuda_bindings", "cuda_core", "nvidia-cuda-nvrtc", "cupy-cuda13x"]
15+
# ///
16+
17+
1318
import sys
1419

20+
from cuda import pathfinder
21+
22+
print(pathfinder.load_nvidia_dynamic_lib("nvrtc"))
23+
1524
import cupy as cp
1625

1726
from cuda.core import Device, LaunchConfig, Program, ProgramOptions, launch

cuda_core/examples/show_device_properties.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -9,6 +9,10 @@
99
#
1010
# ################################################################################
1111

12+
# /// script
13+
# dependencies = ["cuda_bindings", "cuda_core"]
14+
# ///
15+
1216
import sys
1317

1418
from cuda.core import Device, system

cuda_core/examples/simple_multi_gpu_example.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -9,6 +9,10 @@
99
#
1010
# ################################################################################
1111

12+
# /// script
13+
# dependencies = ["cuda_bindings", "cuda_core", "cupy-cuda13x"]
14+
# ///
15+
1216
import sys
1317

1418
import cupy as cp

cuda_core/examples/strided_memory_view_cpu.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -9,6 +9,10 @@
99
#
1010
# ################################################################################
1111

12+
# /// script
13+
# dependencies = ["cuda_bindings", "cuda_core", "cffi", "setuptools"]
14+
# ///
15+
1216
import importlib
1317
import string
1418
import sys

0 commit comments

Comments
 (0)