NVIDIA cuBLAS Runtime Library (CUDA 12.x)

12.9.2.10 · active · verified Sat Mar 28

nvidia-cublas-cu12 provides the native runtime libraries for NVIDIA's CUBLAS (CUDA Basic Linear Algebra Subprograms) on CUDA 12.x enabled systems. It's a GPU-accelerated library designed for high-performance linear algebra operations crucial for AI, machine learning, and high-performance computing (HPC) applications. This Python package acts as a runtime dependency for other Python libraries that leverage cuBLAS functionalities, rather than exposing a direct Python API itself. The current version is 12.9.2.10, and it is actively maintained with frequent updates.

Warnings

Install

Imports

Quickstart

This package primarily installs native runtime shared libraries, and does not provide a direct Python API for end-user interaction. Its functionality is exposed through higher-level Python wrappers like CuPy or frameworks like PyTorch. The quickstart demonstrates how to verify the installation of the `nvidia-cublas-cu12` package and conceptually shows how a dependent library like CuPy would leverage the underlying CUBLAS functionality if properly set up. For actual usage of cuBLAS operations, refer to the documentation of libraries that wrap cuBLAS (e.g., `nvmath-python`, `CuPy`, `PyTorch`).

import os
# nvidia-cublas-cu12 itself does not have direct Python imports or a quickstart.
# Its purpose is to provide the underlying shared libraries for other Python packages.
# For example, nvmath-python can leverage it.
# To use a library that depends on nvidia-cublas-cu12, you'd typically install it like:
# pip install nvmath-python[cu12] cupy-cuda12x

# Example of how a dependent library (like nvmath-python or CuPy) *might*
# indicate the presence of cuBLAS. This code is conceptual, not direct use of this package.
# Replace with actual usage from a wrapper library if available and runnable.

try:
    # Attempt to import a library that *uses* cuBLAS if installed
    import cupy as cp
    print(f"CuPy version: {cp.__version__}")
    print(f"CuPy CUDA enabled: {cp.cuda.is_available()}")
    if cp.cuda.is_available():
        a = cp.random.rand(5, 5)
        b = cp.random.rand(5, 5)
        c = a @ b # This operation would internally use cuBLAS
        print(f"CuPy matrix multiplication (via cuBLAS if linked) successful.\nResult shape: {c.shape}")
    else:
        print("CuPy is installed but CUDA is not available. Ensure drivers and CUDA runtime are correctly set up.")
except ImportError:
    print("CuPy not installed. Install with `pip install cupy-cuda12x` to test CUDA functionality.")
except Exception as e:
    print(f"An error occurred during CuPy test: {e}")

# The presence of `nvidia-cublas-cu12` itself can be verified at the system level.
# For direct validation of the package installation:
import pkg_resources
try:
    distribution = pkg_resources.get_distribution('nvidia-cublas-cu12')
    print(f"\nPackage 'nvidia-cublas-cu12' is installed. Version: {distribution.version}")
except pkg_resources.DistributionNotFound:
    print("Package 'nvidia-cublas-cu12' not found. Please install it.")

view raw JSON →