{"id":1585,"library":"nvidia-cublas","title":"NVIDIA CUBLAS Runtime Libraries","description":"The `nvidia-cublas` package provides the native runtime libraries for NVIDIA's CUBLAS (CUDA Basic Linear Algebra Subroutines). It acts as a foundational dependency, allowing other Python deep learning and scientific computing frameworks (like PyTorch, TensorFlow, and CuPy) to leverage GPU-accelerated linear algebra operations efficiently. It is currently at version 13.3.0.5 and typically receives updates aligned with new NVIDIA CUDA Toolkit releases.","status":"active","version":"13.3.0.5","language":"en","source_language":"en","source_url":"https://github.com/NVIDIA/cuda-python","tags":["cuda","gpu","blas","linear-algebra","nvidia","runtime","deep-learning"],"install":[{"cmd":"pip install nvidia-cublas","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[],"quickstart":{"code":"import torch\n\ndef check_cublas_availability():\n    # Ensure PyTorch is installed and CUDA is available for CUBLAS to be used\n    try:\n        if not torch.cuda.is_available():\n            print(\"CUDA is not available. CUBLAS operations will run on CPU or not at all.\")\n            return\n\n        print(f\"CUDA is available. Device name: {torch.cuda.get_device_name(0)}\")\n        print(f\"Number of CUDA devices: {torch.cuda.device_count()}\")\n\n        # Perform a simple matrix multiplication that typically uses CUBLAS\n        a = torch.randn(1000, 1000, device='cuda')\n        b = torch.randn(1000, 1000, device='cuda')\n        c = torch.matmul(a, b)\n        print(\"Successfully performed a GPU matrix multiplication (likely using CUBLAS).\")\n        print(f\"Result shape: {c.shape}\")\n    except Exception as e:\n        print(f\"An error occurred during CUDA operation: {e}\")\n        print(\"This might indicate an issue with CUBLAS, CUDA installation, or drivers.\")\n\nif __name__ == \"__main__\":\n    check_cublas_availability()","lang":"python","description":"This quickstart demonstrates how to verify that your system has CUDA (and by extension, CUBLAS through `nvidia-cublas`) correctly configured and available for a framework like PyTorch. This package itself does not expose a direct Python API, but rather provides the underlying shared libraries for other GPU-accelerated libraries. Ensure `torch` is installed (`pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118` or similar for your CUDA version)."},"warnings":[{"fix":"Do not attempt to import specific functions or classes from `nvidia-cublas` itself. Instead, ensure it's installed alongside your deep learning framework, which will then automatically utilize the provided CUBLAS libraries if CUDA is detected.","message":"The `nvidia-cublas` package does not expose a direct Python API. Its primary function is to provide the underlying native CUBLAS shared libraries that other Python libraries (e.g., PyTorch, TensorFlow, CuPy) link against to perform GPU-accelerated linear algebra operations.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use the `nvidia-*` PyPI packages that correspond to your CUDA Toolkit version (e.g., `nvidia-cublas==12.1.*` for CUDA 12.1). When using frameworks like PyTorch, ensure you install the PyTorch version compiled for a compatible CUDA version (e.g., `cu118` for CUDA 11.8). The `nvidia-cublas` PyPI package attempts to bundle the correct version for common CUDA releases.","message":"CUBLAS versions must be compatible with your installed NVIDIA GPU drivers and the CUDA Toolkit version used by your deep learning framework. Mismatches can lead to runtime errors or performance issues.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Prioritize a single method for managing CUDA libraries (PyPI `nvidia-*` packages, Conda, or system installation). If using `nvidia-*` PyPI packages, ensure they are the primary source of CUDA libraries in your environment. You might need to adjust `LD_LIBRARY_PATH` or use virtual environments to isolate dependencies.","message":"Installing `nvidia-cublas` via pip can conflict with existing system-wide or Conda-managed CUDA installations if `LD_LIBRARY_PATH` or other environment variables are not correctly managed, potentially leading to 'DLL not found' or 'CUDA driver' errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}