NVIDIA CURAND CUDA 12 Runtime Libraries
The `nvidia-curand-cu12` package provides the native runtime libraries for NVIDIA's CUDA Random Number Generation (CURAND) library, specifically compiled for CUDA Toolkit 12.x. It acts as a foundational dependency for higher-level Python libraries that wrap CUDA functionalities, enabling GPU-accelerated random number generation. The current version is 10.3.10.19, and it typically follows the CUDA Toolkit's release cadence.
Warnings
- gotcha This package is a native runtime library for CUDA and does not provide a direct Python API for `curand` functions. You typically use it as a dependency for other Python libraries like CuPy or Numba that wrap CUDA functionalities.
- breaking Requires a compatible NVIDIA CUDA-capable GPU and an NVIDIA GPU driver. Without these, the package will install but its core functionality will not be usable, potentially leading to runtime errors in dependent libraries.
- gotcha Dependency resolution with `pip` can be complex due to the intricate CUDA ecosystem. Installing multiple `nvidia-*cu12` packages or conflicting versions of CUDA-dependent libraries can lead to `pip` backtracking issues, resulting in slow or failed installations.
- gotcha The `cu12` suffix indicates compatibility with CUDA Toolkit 12.x. Using this package with applications built for different major CUDA versions (e.g., CUDA 11.x) will likely lead to compatibility issues or runtime failures.
Install
-
pip install nvidia-curand-cu12
Imports
- No direct Python imports
This package primarily provides native runtime libraries and is typically consumed by other Python wrappers (e.g., CuPy, Numba) rather than being directly imported in Python code.
Quickstart
# The nvidia-curand-cu12 package itself is not directly imported.
# Instead, its functionalities are used by other libraries.
# Here's an example using CuPy, which would leverage CURAND under the hood.
import cupy as cp
# Ensure a CUDA-capable GPU is available
if cp.cuda.is_available():
print(f"CUDA is available. Current device: {cp.cuda.Device().name}")
# Generate random numbers using CuPy, which utilizes CURAND
# on the GPU if nvidia-curand-cu12 is correctly installed and configured.
gpu_random_array = cp.random.rand(5)
print("GPU-generated random array:", gpu_random_array)
# Example of generating normally distributed random numbers
gpu_normal_array = cp.random.normal(loc=0.0, scale=1.0, size=5)
print("GPU-generated normal array:", gpu_normal_array)
else:
print("CUDA is not available. Please ensure a compatible GPU and CUDA Toolkit are installed.")