CUSPARSE Native Runtime Libraries (CUDA 11)

11.7.5.86 · active · verified Sat Apr 11

The `nvidia-cusparse-cu11` package provides the native runtime libraries for NVIDIA's cuSPARSE, a GPU-accelerated library offering basic linear algebra subroutines for sparse matrix computations. It is an essential low-level component for high-performance computing, machine learning, and AI applications that leverage sparse matrices on NVIDIA GPUs with CUDA Toolkit 11.x. The current version is 11.7.5.86, with the last major version release on October 18, 2022, indicating a slow release cadence for this specific Python wrapper version, though the underlying C++ library continues to evolve.

Warnings

Install

Quickstart

The `nvidia-cusparse-cu11` package is a low-level runtime dependency and does not expose direct Python APIs. Its functionality is implicitly used by higher-level deep learning and scientific computing libraries like PyTorch or CuPy. This quickstart demonstrates how to check for CUDA availability using PyTorch, which, when successful, confirms the underlying NVIDIA libraries (including cuSPARSE) are accessible for sparse tensor operations.

import torch
import os

# Check for CUDA availability, which indirectly means cuSPARSE (if torch uses it) can be leveraged.
if torch.cuda.is_available():
    print(f"CUDA is available. Device name: {torch.cuda.get_device_name(0)}")
    
    # Example of a sparse tensor, which relies on underlying sparse matrix libraries like cuSPARSE
    # This package provides the *runtime* for such operations, not direct Python APIs.
    i = torch.tensor([[0, 1, 1], [2, 0, 2]])
    v = torch.tensor([3, 4, 5], dtype=torch.float32)
    size = torch.Size([2, 3])
    
    if torch.cuda.device_count() > 0:
        sparse_tensor_cpu = torch.sparse_coo_tensor(i, v, size)
        print(f"Sparse tensor on CPU:\n{sparse_tensor_cpu}")
        
        # Move to GPU if available
        sparse_tensor_gpu = sparse_tensor_cpu.to('cuda')
        print(f"Sparse tensor on GPU:\n{sparse_tensor_gpu}")
        print("This operation implicitly leverages NVIDIA's sparse computation libraries.")
    else:
        print("No CUDA devices found, cannot create sparse tensor on GPU.")
else:
    print("CUDA is not available. Please ensure NVIDIA drivers and CUDA Toolkit 11.x are installed.")

view raw JSON →