mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2026-10-13 00:08:26 +08:00
Release v13.3 of the CUDA samples with CUDA 13.3 Toolkit (#435)
This is the release of the CUDA 13.3 samples, which include additions for CUDA Tile C++, and updated CCCL and Python samples.
This commit is contained in:
@@ -106,10 +106,19 @@ When returning a zero-copy view, the caller must close the buffers after use (e.
|
||||
- CUDA Toolkit 13.0 or newer
|
||||
- Python 3.10 or newer
|
||||
- `cuda-python` package (13.0.0+)
|
||||
- `cuda-core` package (>=0.6.0)
|
||||
- `cuda-core` package (>=1.0.0)
|
||||
- `numpy` package (>=2.3.2)
|
||||
- `pillow` package (10.0.0+)
|
||||
|
||||
### Platform Support:
|
||||
|
||||
This sample relies on `ManagedMemoryResource` with **concurrent host access**
|
||||
to managed allocations while GPU kernels are in flight. That behavior
|
||||
requires the device property `concurrent_managed_access=True`, which is only
|
||||
supported on Linux with HMM (Pascal and newer). On Windows (WDDM/MCDM/TCC)
|
||||
the property is `False`, so the sample exits early with a waive message and
|
||||
exit code `2` instead of attempting a run that would crash the process.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
|
||||
@@ -142,8 +142,8 @@ def blur_image_unified_memory(
|
||||
mr = ManagedMemoryResource(options)
|
||||
|
||||
# Allocate unified memory buffers for source and destination images
|
||||
src_buf = mr.allocate(n_bytes, stream)
|
||||
dst_buf = mr.allocate(n_bytes, stream)
|
||||
src_buf = mr.allocate(n_bytes, stream=stream)
|
||||
dst_buf = mr.allocate(n_bytes, stream=stream)
|
||||
try:
|
||||
# Synchronize to ensure allocations are complete before CPU access
|
||||
stream.sync()
|
||||
@@ -197,6 +197,14 @@ def main():
|
||||
3. Unified memory with cuda.core.ManagedMemoryResource
|
||||
4. Kernel launch with cuda.core.launch and LaunchConfig
|
||||
"""
|
||||
if sys.platform == "win32":
|
||||
print(
|
||||
"This sample relies on ManagedMemoryResource with concurrent host "
|
||||
"access, which is not supported on Windows "
|
||||
"(concurrent_managed_access=False). Waiving this sample."
|
||||
)
|
||||
sys.exit(2)
|
||||
|
||||
print("=" * 60)
|
||||
print("Image Blur with Unified Memory (cuda.core)")
|
||||
print("=" * 60)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Image Blur with Unified Memory Sample Requirements
|
||||
|
||||
cuda-python>=13.0.0
|
||||
cuda-core>=0.6.0
|
||||
cuda-core>=1.0.0
|
||||
numpy>=2.3.2
|
||||
pillow>=10.0.0
|
||||
|
||||
@@ -39,7 +39,7 @@ Copy image arrays between CPU and GPU memory using the modern `cuda.core` API wi
|
||||
### From `cupy`:
|
||||
|
||||
- `cp.from_dlpack()` - Create GPU array view from DLPack capsule
|
||||
- `cp.cuda.ExternalStream()` - Use external CUDA stream
|
||||
- `cp.cuda.Stream.from_external()` - Use external CUDA stream
|
||||
|
||||
### From `cuda_samples_utils`:
|
||||
|
||||
@@ -58,8 +58,8 @@ Copy image arrays between CPU and GPU memory using the modern `cuda.core` API wi
|
||||
- Python 3.10 or newer
|
||||
- NumPy 2.3.2 or newer (required for DLPack support)
|
||||
- `cuda-python` package (>=13.0.0+)
|
||||
- `cuda-core` package (>=0.6.0)
|
||||
- `cupy-cuda13x` package (13.0.0+)
|
||||
- `cuda-core` package (>=1.0.0)
|
||||
- `cupy-cuda13x` package (14.0.0+)
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -73,8 +73,8 @@ pip install -r requirements.txt
|
||||
The requirements.txt installs:
|
||||
- `numpy` (2.3.2+, required for DLPack)
|
||||
- `cuda-python` (>=13.0.0+)
|
||||
- `cuda-core` (>=0.6.0)
|
||||
- `cupy-cuda13x` (13.0.0+)
|
||||
- `cuda-core` (>=1.0.0)
|
||||
- `cupy-cuda13x` (14.0.0+)
|
||||
|
||||
## How to Run
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ def main():
|
||||
print(f"[Image array copy of {H}x{W}x{C} image]")
|
||||
|
||||
# Step 2: Configure CuPy to use our CUDA stream (for interoperability)
|
||||
cp.cuda.ExternalStream(int(stream.handle)).use()
|
||||
cp.cuda.Stream.from_external(stream).use()
|
||||
|
||||
# Step 3: Create a test image on CPU
|
||||
print("Creating sample image...")
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
numpy>=2.3.2
|
||||
cuda-python>=13.0.0
|
||||
cuda-core>=0.6.0
|
||||
cupy-cuda13x>=13.0.0
|
||||
cuda-core>=1.0.0
|
||||
cupy-cuda13x>=14.0.0
|
||||
|
||||
@@ -90,7 +90,7 @@ Query and display detailed properties of all CUDA-capable devices in your system
|
||||
- CUDA Toolkit 13.0 or newer (recommended; matches `cuda-python` 13.x)
|
||||
- Python 3.10 or newer
|
||||
- `cuda-python` package (>=13.0.0)
|
||||
- `cuda-core` package (>=0.6.0)
|
||||
- `cuda-core` package (>=1.0.0)
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -103,7 +103,7 @@ pip install -r requirements.txt
|
||||
|
||||
The requirements.txt installs:
|
||||
- `cuda-python` (>=13.0.0)
|
||||
- `cuda-core` (>=0.6.0)
|
||||
- `cuda-core` (>=1.0.0)
|
||||
|
||||
## How to Run
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ def print_device_info(dev_id, device):
|
||||
print(f"Device {dev_id}: {device.name}")
|
||||
|
||||
# cuda.bindings workaround: runtime version not in cuda.core
|
||||
driver_major, driver_minor = system.get_driver_version()
|
||||
driver_major, driver_minor = system.get_user_mode_driver_version()
|
||||
err, runtime_version = cudart.cudaRuntimeGetVersion()
|
||||
if err != cudart.cudaError_t.cudaSuccess:
|
||||
raise RuntimeError(f"Failed to get CUDA runtime version: {err}")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Device Query Sample Requirements
|
||||
|
||||
cuda-python>=13.0.0
|
||||
cuda-core>=0.6.0
|
||||
cuda-core>=1.0.0
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
numpy>=2.3.2
|
||||
cuda-python>=13.0.0
|
||||
cuda-core>=0.6.0
|
||||
cupy-cuda13x>=13.0.0
|
||||
cuda-core>=1.0.0
|
||||
cupy-cuda13x>=14.0.0
|
||||
nvtx
|
||||
|
||||
@@ -57,7 +57,7 @@ def timer(message):
|
||||
@contextlib.contextmanager
|
||||
def gpu_timer(message, stream):
|
||||
"""GPU timing context manager using cuda.core CUDA events."""
|
||||
event_options = EventOptions(enable_timing=True)
|
||||
event_options = EventOptions(timing_enabled=True)
|
||||
start_event = stream.record(options=event_options)
|
||||
yield
|
||||
end_event = stream.record(options=event_options)
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
|
||||
numpy>=2.3.2
|
||||
cuda-python>=13.0.0
|
||||
cuda-core>=0.6.0
|
||||
cupy-cuda13x>=13.0.0
|
||||
cuda-core>=1.0.0
|
||||
cupy-cuda13x>=14.0.0
|
||||
|
||||
@@ -68,7 +68,7 @@ CUDA Python (cuda.core), Numba CUDA, Kernel Compilation, Printf in Kernels, Mult
|
||||
- CUDA Toolkit 13.0 or newer
|
||||
- Python 3.10 or newer
|
||||
- `cuda-python` package (13.0+)
|
||||
- `cuda-core` package (>=0.6.0)
|
||||
- `cuda-core` package (>=1.0.0)
|
||||
- `numba-cuda` package (0.24.0+, for Pythonic kernel authoring)
|
||||
|
||||
Download and install:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Simple Printf Sample - Requirements
|
||||
|
||||
cuda-python>=13.0.0
|
||||
cuda-core>=0.6.0
|
||||
cuda-core>=1.0.0
|
||||
# Numba JIT uses nvJitLink from pip; keep in step with cuda-bindings (e.g. 13.2.x).
|
||||
nvidia-nvjitlink>=13.2.0
|
||||
numba-cuda>=0.24.0
|
||||
numba-cuda>=0.29.0
|
||||
|
||||
@@ -63,7 +63,7 @@ Import stable symbols from the top-level `cuda.core` package (not `cuda.core.exp
|
||||
- CUDA Toolkit 13.0 or newer (matches `cuda-python` 13.x)
|
||||
- Python 3.10 or newer
|
||||
- `cuda-python` (>=13.0.0)
|
||||
- `cuda-core` (>=0.6.0)
|
||||
- `cuda-core` (>=1.0.0)
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -77,7 +77,7 @@ pip install -r requirements.txt
|
||||
The `requirements.txt` installs:
|
||||
|
||||
- `cuda-python` (>=13.0.0)
|
||||
- `cuda-core` (>=0.6.0)
|
||||
- `cuda-core` (>=1.0.0)
|
||||
|
||||
## How to Run
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# System Information Sample Requirements
|
||||
|
||||
cuda-python>=13.0.0
|
||||
cuda-core>=0.6.0
|
||||
cuda-core>=1.0.0
|
||||
|
||||
@@ -43,11 +43,8 @@ import sys
|
||||
|
||||
try:
|
||||
from cuda.core import system
|
||||
from cuda.core.system import (
|
||||
CUDA_BINDINGS_NVML_IS_COMPATIBLE,
|
||||
GpuP2PCapsIndex,
|
||||
TemperatureSensors,
|
||||
)
|
||||
from cuda.core.system import CUDA_BINDINGS_NVML_IS_COMPATIBLE
|
||||
from cuda.core.system.typing import GpuP2PCapsIndex
|
||||
except ImportError as e:
|
||||
print(f"Error: Required package not found: {e}")
|
||||
print("Please install from requirements.txt:")
|
||||
@@ -75,10 +72,11 @@ def format_bytes(nbytes: int) -> str:
|
||||
|
||||
def print_driver_info() -> None:
|
||||
print_header("Driver / NVML")
|
||||
major, minor = system.get_driver_version()
|
||||
print(f"CUDA driver version: {major}.{minor}")
|
||||
print(f"CUDA driver version (full): {system.get_driver_version_full()}")
|
||||
major, minor = system.get_user_mode_driver_version()
|
||||
print(f"CUDA driver version (user-mode): {major}.{minor}")
|
||||
if CUDA_BINDINGS_NVML_IS_COMPATIBLE:
|
||||
kmd = system.get_kernel_mode_driver_version()
|
||||
print(f"CUDA driver version (kernel-mode): {'.'.join(str(x) for x in kmd)}")
|
||||
print(f"NVML version: {system.get_nvml_version()}")
|
||||
try:
|
||||
print(f"Driver branch: {system.get_driver_branch()}")
|
||||
@@ -106,7 +104,7 @@ def print_device_info(device: "system.Device") -> None:
|
||||
except Exception as e: # noqa: BLE001
|
||||
print(f"Architecture: unavailable ({e})")
|
||||
try:
|
||||
print(f"Brand: {device.brand.name}")
|
||||
print(f"Brand: {device.brand}")
|
||||
except Exception as e: # noqa: BLE001
|
||||
print(f"Brand: unavailable ({e})")
|
||||
|
||||
@@ -133,7 +131,7 @@ def print_device_info(device: "system.Device") -> None:
|
||||
|
||||
# Temperature (GPU sensor)
|
||||
try:
|
||||
temp_c = device.temperature.sensor(TemperatureSensors.TEMPERATURE_GPU)
|
||||
temp_c = device.temperature.get_sensor()
|
||||
print(f"Temperature (GPU sensor): {temp_c} C")
|
||||
except Exception as e: # noqa: BLE001
|
||||
print(f"Temperature: unavailable ({e})")
|
||||
@@ -158,12 +156,8 @@ def print_topology(devices: list) -> None:
|
||||
except Exception as e: # noqa: BLE001
|
||||
level_name = f"unavailable ({e})"
|
||||
try:
|
||||
read = system.get_p2p_status(
|
||||
d0, d1, GpuP2PCapsIndex.P2P_CAPS_INDEX_READ
|
||||
)
|
||||
write = system.get_p2p_status(
|
||||
d0, d1, GpuP2PCapsIndex.P2P_CAPS_INDEX_WRITE
|
||||
)
|
||||
read = system.get_p2p_status(d0, d1, GpuP2PCapsIndex.READ)
|
||||
write = system.get_p2p_status(d0, d1, GpuP2PCapsIndex.WRITE)
|
||||
read_name = read.name
|
||||
write_name = write.name
|
||||
except Exception as e: # noqa: BLE001
|
||||
|
||||
@@ -58,8 +58,8 @@ Import stable symbols from the top-level package (not `cuda.core.experimental`).
|
||||
- CUDA Toolkit 13.0 or newer (matches `cuda-python` 13.x)
|
||||
- Python 3.10 or newer
|
||||
- `cuda-python` (>=13.0.0)
|
||||
- `cuda-core` (>=0.6.0)
|
||||
- `cupy-cuda13x` (>=13.0.0)
|
||||
- `cuda-core` (>=1.0.0)
|
||||
- `cupy-cuda13x` (>=14.0.0)
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -73,8 +73,8 @@ pip install -r requirements.txt
|
||||
The requirements.txt installs:
|
||||
|
||||
- `cuda-python` (>=13.0.0)
|
||||
- `cuda-core` (>=0.6.0)
|
||||
- `cupy-cuda13x` (>=13.0.0)
|
||||
- `cuda-core` (>=1.0.0)
|
||||
- `cupy-cuda13x` (>=14.0.0)
|
||||
|
||||
## How to Run
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Vector Addition Sample Requirements
|
||||
|
||||
cuda-python>=13.0.0
|
||||
cuda-core>=0.6.0
|
||||
cupy-cuda13x>=13.0.0
|
||||
cuda-core>=1.0.0
|
||||
cupy-cuda13x>=14.0.0
|
||||
|
||||
Reference in New Issue
Block a user