{"library":"nvidia-cusparse-cu11","title":"CUSPARSE Native Runtime Libraries (CUDA 11)","description":"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.","language":"python","status":"active","last_verified":"Sat Apr 11","install":{"commands":["pip install nvidia-cusparse-cu11"],"cli":null},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import torch\nimport os\n\n# Check for CUDA availability, which indirectly means cuSPARSE (if torch uses it) can be leveraged.\nif torch.cuda.is_available():\n    print(f\"CUDA is available. Device name: {torch.cuda.get_device_name(0)}\")\n    \n    # Example of a sparse tensor, which relies on underlying sparse matrix libraries like cuSPARSE\n    # This package provides the *runtime* for such operations, not direct Python APIs.\n    i = torch.tensor([[0, 1, 1], [2, 0, 2]])\n    v = torch.tensor([3, 4, 5], dtype=torch.float32)\n    size = torch.Size([2, 3])\n    \n    if torch.cuda.device_count() > 0:\n        sparse_tensor_cpu = torch.sparse_coo_tensor(i, v, size)\n        print(f\"Sparse tensor on CPU:\\n{sparse_tensor_cpu}\")\n        \n        # Move to GPU if available\n        sparse_tensor_gpu = sparse_tensor_cpu.to('cuda')\n        print(f\"Sparse tensor on GPU:\\n{sparse_tensor_gpu}\")\n        print(\"This operation implicitly leverages NVIDIA's sparse computation libraries.\")\n    else:\n        print(\"No CUDA devices found, cannot create sparse tensor on GPU.\")\nelse:\n    print(\"CUDA is not available. Please ensure NVIDIA drivers and CUDA Toolkit 11.x are installed.\")","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}