Registry / ai-ml / nvidia-cusparse

nvidia-cusparse

JSON →
library12.8.2.51pypypi✓ verified 22d ago

nvidia-cusparse provides the native NVIDIA cuSPARSE runtime libraries, offering highly optimized routines for sparse matrix computations on NVIDIA GPUs. It is a foundational component for other Python libraries like CuPy to enable sparse GPU operations. The current version is 12.7.9.17, and it typically releases alongside new CUDA toolkit versions.

pip install nvidia-cusparse-cu12
INSTALL
IMPORT
SIG · NVIDIA-CUSPARSE
N
nvidia-cusparse
ai-mlpythonv12.8.2.51
Install
8.3s avg
Import
Disk
624MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 8.3s · import 0.000s · 635MB
624MB installed
● package 624MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cusparse
from nvidia import cusparse
import cupy.sparse as csp

Demonstrates how to create and manipulate sparse matrices on an NVIDIA GPU using CuPy, which internally leverages the `nvidia-cusparse` runtime libraries. This includes creating a COO matrix, converting it to CSR format, and performing a matrix-vector multiplication.

import cupy as cp import cupy.sparse as csp # Create a sparse matrix on GPU using CuPy, which utilizes cuSPARSE internally. # Example: Coordinate format (COO) row = cp.array([0, 1, 2, 0]) col = cp.array([0, 1, 2, 2]) data = cp.array([1.0, 2.0, 3.0, 4.0]) shape = (3, 3) coo_matrix = csp.coo_matrix((data, (row, col)), shape=shape) print("Sparse COO Matrix on GPU:") print(coo_matrix) print(f"Number of non-zero elements: {coo_matrix.nnz}") # Convert to Compressed Sparse Row (CSR) format csr_matrix = coo_matrix.tocsr() print("\nSparse CSR Matrix on GPU:") print(csr_matrix) # Perform a simple operation, e.g., matrix-vector multiplication vec = cp.array([10., 20., 30.]) result = csr_matrix @ vec print("\nMatrix-vector multiplication result:") print(result) # Note: The `nvidia-cusparse` package provides the underlying CUSPARSE runtime libraries. # Higher-level libraries like CuPy wrap these for Python usage.
Debug
Known issues
gotchaThe `nvidia-cusparse` package does not expose direct Python importable modules. It provides the underlying C++ shared libraries that other Python packages (e.g., `cupy`) link against. Users should access cuSPARSE functionality via such higher-level libraries.
fix
Use a wrapping library like `cupy` (e.g., `import cupy.sparse`) to interact with cuSPARSE functionality in Python.
affects: All
gotchaInstallation typically requires specifying the CUDA toolkit version (e.g., `nvidia-cusparse-cu12` for CUDA 12.x). Installing the generic `nvidia-cusparse` or a version mismatched with your system's CUDA toolkit can lead to runtime errors or degraded GPU acceleration.
fix
Ensure the installed `nvidia-cusparse` package matches your system's CUDA toolkit version. Consult NVIDIA's documentation or the respective Python library's (e.g., CuPy) installation guide.
affects: All
gotchaEffective use of cuSPARSE requires understanding sparse matrix storage formats (e.g., CSR, CSC, COO) and their implications for GPU memory access patterns and computational efficiency. Naive usage without considering these aspects can lead to sub-optimal performance.
fix
Familiarize yourself with sparse matrix theory and best practices for GPU computing. Utilize performance profiling tools to identify bottlenecks in your sparse GPU workloads.
affects: All
Upgrade
Version history
12.8.2.51latest on PyPI · released Jun 29, 2026
Audit
Dependencies
cupyrequiredProvides Python bindings and a high-level API for using cuSPARSE functionalities. `nvidia-cusparse` itself does not expose direct Python imports.
nvidia-cuda-runtimeoptionalProvides core CUDA runtime libraries, often a peer dependency.
nvidia-cublasoptionalProvides BLAS operations, often a peer dependency for numerical libraries.
Agent activity
3 hits · last 30 days
node
2
Resources
nvidia-cusparse — pip install nvidia-cusparse · libregistry