NVIDIA CUDA Runtime (cu11)
The `nvidia-cuda-runtime-cu11` package provides the native CUDA Runtime libraries for Python applications. It acts as a foundational component, offering Cython/Python wrappers for CUDA driver and runtime APIs, enabling higher-level Python libraries to leverage NVIDIA GPUs. This is a low-level runtime dependency rather than a library with direct user-facing Python APIs. The current version is 11.8.89. It is actively maintained by NVIDIA.
Warnings
- gotcha This package is a low-level runtime dependency. It does not provide direct Python APIs for coding. Its primary function is to make the CUDA Runtime libraries available for other Python frameworks (e.g., PyTorch, TensorFlow, Numba) that perform GPU-accelerated computing.
- breaking Installing `nvidia-cuda-runtime-cu11` (and other `nvidia-cuda-*` packages) from PyPI requires the `nvidia-pyindex` package to be installed first, or specifying the NVIDIA PyPI index URL. Without it, `pip` may fail to find the package.
- gotcha A compatible NVIDIA GPU and an appropriately installed NVIDIA driver are prerequisites. This Python package only provides the software runtime; it does not install the GPU driver or ensure hardware compatibility.
- gotcha These PyPI packages (`nvidia-cuda-runtime-cu11`, etc.) are intended for runtime use and do not include developer tools such as `nvcc` (the CUDA compiler). For CUDA development (e.g., compiling custom CUDA kernels), the full CUDA Toolkit installation is typically required.
- gotcha Mixing CUDA versions from different installation methods (e.g., system-wide CUDA Toolkit, Conda, and PyPI wheels) can lead to environment conflicts and unexpected errors.
Install
-
pip install nvidia-pyindex && pip install nvidia-cuda-runtime-cu11
Quickstart
import os
# This package primarily provides runtime libraries.
# To verify successful installation and CUDA availability in a Python environment,
# you typically check via a framework that utilizes CUDA, like PyTorch.
# Ensure 'torch' is installed (e.g., pip install torch --index-url https://download.pytorch.org/whl/cu118)
try:
import torch
if torch.cuda.is_available():
print(f"CUDA is available! Device name: {torch.cuda.get_device_name(0)}")
else:
print("CUDA is not available according to PyTorch.")
except ImportError:
print("PyTorch not installed. Install it to verify CUDA availability:")
print("pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118")
except Exception as e:
print(f"An error occurred while checking CUDA with PyTorch: {e}")