{"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":"python","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,"search_vec":"'13.3.0.5':58 'acceler':48 'act':25 'algebra':22,50,75 'align':63 'allow':30 'basic':20 'blas':72 'comput':37 'cubla':2,8,18 'cuda':19,67,70 'cupi':43 'current':55 'deep':33,79 'deep-learn':78 'depend':29 'effici':52 'foundat':28 'framework':38 'gpu':47,71 'gpu-acceler':46 'learn':34,80 'leverag':45 'librari':4,14 'like':39 'linear':21,49,74 'linear-algebra':73 'nativ':12 'new':65 'nvidia':1,7,16,66,76 'nvidia-cubla':6 'oper':51 'packag':9 'provid':10 'python':32 'pytorch':40 'receiv':61 'releas':69 'runtim':3,13,77 'scientif':36 'subroutin':23 'tensorflow':41 'toolkit':68 'typic':60 'updat':62 'version':57","created_at":"2026-04-09T03:54:27.263989+00:00","updated_at":"2026-04-16T17:26:19.606991+00:00","problems":[{"fix":"Reduce batch size, optimize model size, free up GPU memory by clearing unused variables/sessions, or ensure no other memory-intensive processes are running on the GPU.","cause":"This error occurs when the CUBLAS library is unable to allocate sufficient GPU memory for a requested operation, often due to large model sizes, large batch sizes, fragmented memory, or other GPU processes consuming resources.","error":"CUBLAS_STATUS_ALLOC_FAILED"},{"fix":"Ensure the CUDA Toolkit is correctly installed and its library path (e.g., `/usr/local/cuda/lib64`) is added to the `LD_LIBRARY_PATH` environment variable. Verify that the installed `nvidia-cublas` version matches the CUDA Toolkit version expected by your deep learning framework. Reinstalling the correct CUDA Toolkit and aligning framework versions often resolves this.","cause":"This indicates that TensorFlow, PyTorch, or another framework cannot find the necessary `libcublas.so` shared library file, often due to an incorrect CUDA Toolkit installation, missing library paths in `LD_LIBRARY_PATH`, or a mismatch between the expected and installed CUDA/CUBLAS versions.","error":"ImportError: libcublas.so.<version>: cannot open shared object file: No such file or directory"},{"fix":"Ensure `cublasCreate()` is called successfully before any CUBLAS operations. Verify your CUDA installation is correct, GPU drivers are up-to-date, and the GPU is healthy and accessible, potentially checking environment variables like `CUDA_VISIBLE_DEVICES`.","cause":"This error signifies that the CUBLAS library was not properly initialized before an attempt to use its functions, potentially because the CUDA runtime failed to initialize or a valid CUDA context was not established.","error":"RuntimeError: CUDA error: CUBLAS_STATUS_NOT_INITIALIZED when calling `cublasCreate(handle)`"},{"fix":"Carefully inspect input tensors for correct dimensions, valid values (no NaNs or Infs), and appropriate data types. Reduce the complexity or size of the operation if it might be hitting GPU resource limits. Setting `CUDA_LAUNCH_BLOCKING=1` can help pinpoint the exact line of code causing the error by forcing synchronous execution.","cause":"This general error indicates a failure during the execution of a CUBLAS kernel (e.g., matrix multiplication). It can stem from invalid input parameters, out-of-bounds memory access, or the GPU program failing to execute for other reasons.","error":"RuntimeError: CUDA error: CUBLAS_STATUS_EXECUTION_FAILED when calling `cublasSgemm(handle)`"},{"fix":"Install the specific Python package that provides the missing `nvidia` submodule (e.g., `pip install nvidia-dali`, `pip install nvidia-pyindex` if other NVIDIA Python utilities are needed). Ensure your Python environment is correctly activated and the packages are installed for the Python interpreter you are using. If you are specifically trying to interact with `nvidia-cublas` through Python, ensure you are using a higher-level library like PyTorch or TensorFlow that handles the native calls.","cause":"While `nvidia-cublas` provides native libraries, this Python error occurs when a Python application or framework attempts to import a Python module under the `nvidia` namespace (e.g., `nvidia.dali`, `nvidia.cublas` directly) and the corresponding Python package is not installed or discoverable in the Python environment. The `nvidia-cublas` package itself does not expose a `nvidia` Python module for direct import.","error":"ModuleNotFoundError: No module named 'nvidia'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://developer.nvidia.com/cuda-zone","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/nvidia-cublas/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-04-09","next_check":"2026-07-08","install_tag":null}}