mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2026-10-13 00:08:26 +08:00
CUDA 13.4 samples update - v13.4-public
Release 13.4 of the CUDA Samples supported by CUDA Toolkit 13.4. See Changelog for more information.
This commit is contained in:
@@ -112,12 +112,12 @@ When returning a zero-copy view, the caller must close the buffers after use (e.
|
||||
|
||||
### 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.
|
||||
This sample builds host NumPy views over managed allocations, which requires
|
||||
the device property `concurrent_managed_access=True`. Devices that report
|
||||
`False` — Windows (WDDM/MCDM/TCC), and older integrated GPUs such as Jetson
|
||||
Orin — keep managed allocations GPU-exclusive, so the sample reports the
|
||||
missing capability and exits with code `2` instead of attempting a run that
|
||||
would crash the process.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -174,4 +174,4 @@ Verifying result...
|
||||
- [cuda.core Documentation](https://nvidia.github.io/cuda-python/cuda-core/latest/)
|
||||
- [cuda.core.Program](https://nvidia.github.io/cuda-python/cuda-core/latest/generated/cuda.core.Program.html)
|
||||
- [cuda.core.ManagedMemoryResource](https://nvidia.github.io/cuda-python/cuda-core/latest/generated/cuda.core.ManagedMemoryResource.html)
|
||||
- [CUDA Managed Memory](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#um-unified-memory-programming-hd)
|
||||
- [CUDA Managed Memory](https://docs.nvidia.com/cuda/cuda-programming-guide/04-special-topics/unified-memory.html#unified-memory)
|
||||
|
||||
@@ -197,14 +197,6 @@ 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)
|
||||
@@ -213,6 +205,13 @@ def main():
|
||||
device = Device(0)
|
||||
device.set_current()
|
||||
|
||||
# This sample builds host NumPy views over managed memory. Devices without
|
||||
# concurrent managed access keep managed allocations GPU-exclusive while
|
||||
# the GPU is active, so those host views fault.
|
||||
if not device.properties.concurrent_managed_access:
|
||||
print("Concurrent managed memory access is not supported on this platform.")
|
||||
sys.exit(2)
|
||||
|
||||
print(f"\nDevice: {device.name}")
|
||||
print(f"Compute Capability: sm_{device.arch}")
|
||||
|
||||
|
||||
@@ -189,6 +189,14 @@ def main():
|
||||
# Step 1: Set up CUDA device and stream
|
||||
dev = Device() # Get default CUDA device (GPU 0)
|
||||
dev.set_current() # Make this device the active one
|
||||
|
||||
# Pinned memory resources are backed by a host memory pool, which requires
|
||||
# CUDA memory-pool support. This is not available on every platform (for
|
||||
# example, Windows in TCC mode), so check before using it.
|
||||
if not dev.properties.host_memory_pools_supported:
|
||||
print("Host pinned memory pools are not supported on this platform.")
|
||||
return 2
|
||||
|
||||
stream = dev.create_stream() # Create stream for async operations
|
||||
|
||||
print(f"Device: {dev.name}")
|
||||
@@ -233,7 +241,8 @@ def main():
|
||||
cp.cuda.Stream.null.use() # Reset CuPy's stream to default
|
||||
|
||||
print("\nDone")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
sys.exit(main())
|
||||
|
||||
@@ -186,4 +186,4 @@ For multi-GPU systems, the output will include information for all detected devi
|
||||
|
||||
- [CUDA Python Documentation](https://nvidia.github.io/cuda-python/)
|
||||
- [cuda.core API Guide](https://nvidia.github.io/cuda-python/cuda-core/latest/)
|
||||
- [CUDA Programming Guide - Device Information](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#device-enumeration)
|
||||
- [CUDA Programming Guide - Device Information](https://docs.nvidia.com/cuda/cuda-programming-guide/03-advanced/multi-gpu-systems.html#device-enumeration)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Device Query Sample Requirements
|
||||
|
||||
cuda-python>=13.0.0
|
||||
cuda-core>=1.0.0
|
||||
cuda-core>=1.2.0
|
||||
|
||||
@@ -259,5 +259,5 @@ Try modifying:
|
||||
- [nvmath-python Device APIs](https://docs.nvidia.com/cuda/nvmath-python/latest/device-apis/index.html) - Optimized math operations for Numba CUDA kernels
|
||||
|
||||
### CUDA References:
|
||||
- [CUDA C Programming Guide - Printf](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#formatted-output)
|
||||
- [CUDA C Programming Guide - Printf](https://docs.nvidia.com/cuda/cuda-programming-guide/05-appendices/cpp-language-support.html#printf)
|
||||
- [C++ simplePrintf Sample](https://github.com/NVIDIA/cuda-samples/tree/master/Samples/0_Introduction/simplePrintf)
|
||||
|
||||
@@ -3,5 +3,9 @@
|
||||
cuda-python>=13.0.0
|
||||
cuda-core>=1.0.0
|
||||
# Numba JIT uses nvJitLink from pip; keep in step with cuda-bindings (e.g. 13.2.x).
|
||||
# Also pin libnvvm from pip so Numba doesn't fall back to a mismatched
|
||||
# system-toolkit libnvvm (nvJitLink ERROR_OUTDATED_LIBRARY).
|
||||
nvidia-nvvm>=13.2.0
|
||||
nvidia-nvjitlink>=13.2.0
|
||||
numba-cuda>=0.29.0
|
||||
numpy<2.5
|
||||
|
||||
Reference in New Issue
Block a user