Skip to content

Commit 4906537

Browse files
committed
fix(samples): resolve two CI failures in systemInfo and vectorAdd
- systemInfo: guard get_process_name() call behind CUDA_BINDINGS_NVML_IS_COMPATIBLE to avoid NameError when NVML bindings are incompatible with the driver. - vectorAdd: replace cp.random.rand() with NumPy-generated data transferred via cp.asarray() to avoid a dependency on libcurand which is not present in the cuda-13x wheel environment.
1 parent 053b2cf commit 4906537

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎samples/cuda_core/systemInfo/systemInfo.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def print_driver_info() -> None:
8888
print(f"Driver branch: unavailable ({e})")
8989
else:
9090
print("NVML bindings are not compatible with this driver; device info will be limited.")
91-
print(f"Current process: {system.get_process_name(os.getpid())}")
91+
if CUDA_BINDINGS_NVML_IS_COMPATIBLE:
92+
print(f"Current process: {system.get_process_name(os.getpid())}")
9293

9394

9495
def print_device_info(device: "system.Device") -> None:

‎samples/cuda_core/vectorAdd/vectorAdd.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
import sys
5050
from pathlib import Path
5151

52+
import numpy as np
53+
5254
# Add parent directory to path to import utilities
5355
sys.path.insert(0, str(Path(__file__).parent.parent / "Utilities"))
5456
from cuda_samples_utils import verify_array_result
@@ -96,8 +98,8 @@ def _demo_float_cupy(stream, kernel, num_elements, verify):
9698
print(f"\n[1] vectorAdd<float> on {num_elements} CuPy-allocated elements")
9799
dtype = cp.float32
98100

99-
a = cp.random.rand(num_elements).astype(dtype)
100-
b = cp.random.rand(num_elements).astype(dtype)
101+
a = cp.asarray(np.random.rand(num_elements).astype(np.float32))
102+
b = cp.asarray(np.random.rand(num_elements).astype(np.float32))
101103
c = cp.empty(num_elements, dtype=dtype)
102104
_launch_add(stream, kernel, num_elements, a.data.ptr, b.data.ptr, c.data.ptr)
103105

@@ -118,8 +120,8 @@ def _demo_double_owned_buffer(device, stream, kernel, num_elements, verify):
118120
print(f"\n[2] vectorAdd<double> on {num_elements} elements with device.allocate() output")
119121
dtype = cp.float64
120122

121-
a = cp.random.rand(num_elements).astype(dtype)
122-
b = cp.random.rand(num_elements).astype(dtype)
123+
a = cp.asarray(np.random.rand(num_elements).astype(np.float64))
124+
b = cp.asarray(np.random.rand(num_elements).astype(np.float64))
123125

124126
out_bytes = num_elements * dtype().itemsize
125127
out_buf = device.allocate(out_bytes, stream=stream)

0 commit comments

Comments
 (0)