Registry / ai-ml / pylibraft-cu12

pylibraft-cu12

JSON →
library26.6.0pypypiunverified

pylibraft-cu12 is the Python binding for RAFT (Reusable Algorithms Functions and other Tools), a core component of the NVIDIA RAPIDS ecosystem providing a collection of GPU-accelerated primitives and algorithms for data science. It is designed for optimal performance on NVIDIA GPUs with CUDA 12.x. The current version is 26.4.0, following a monthly release cadence aligned with the broader RAPIDS project.

pip install pylibraft-cu12 cupy-cuda12x
INSTALL
IMPORT
SIG · PYLIBRAFT-CU12
P
pylibraft-cu12
ai-mlpythonv26.6.0
Install
42.7s avg
Import
Disk
2888MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v26.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 42.7s · import 0.000s · 3174.4MB
2888MB installed
● package 2888MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NearestNeighbors
from raft.neighbors import NearestNeighbors
KMeans
from raft.cluster import KMeans
get_device_info
from raft.common.cuda_utils import get_device_info
from pylibraft.common.cuda_utils import get_device_info
The installed package is `pylibraft-cu12`, but the import namespace for Python bindings is `raft`.
LinearRegression
from raft.linear_model import LinearRegression

This quickstart demonstrates how to use `raft.neighbors.NearestNeighbors` to find the k-nearest neighbors on GPU data using CuPy. It initializes random GPU data, fits a NearestNeighbors model, and queries for neighbors. Ensure you have `cupy-cuda12x` installed for this example to run and a CUDA-enabled GPU.

import cupy as cp from raft.neighbors import NearestNeighbors import sys # Ensure CuPy is installed for GPU array handling and a CUDA device is available try: if cp.cuda.runtime.getDeviceCount() == 0: print("Error: No CUDA device found. RAFT requires a CUDA-enabled GPU.") sys.exit(1) except cp.cuda.runtime.CUDARuntimeError as e: print(f"Error initializing CuPy or CUDA runtime: {e}") print("Please ensure CuPy is installed correctly (e.g., `cupy-cuda12x`) and your CUDA environment is set up.") sys.exit(1) # Generate some random GPU data using CuPy n_samples = 100 n_features = 10 X = cp.random.rand(n_samples, n_features, dtype=cp.float32) # Create a NearestNeighbors model nn = NearestNeighbors(n_neighbors=5, metric='euclidean', output_type='cupy') # Fit the model to the data nn.fit(X) # Query for nearest neighbors to the same data distances, indices = nn.kneighbors(X) print("Distances shape:", distances.shape) print("Indices shape:", indices.shape) print("\nFirst 5 distances (sample 0):\n", distances[0, :5]) print("\nFirst 5 indices (sample 0):\n", indices[0, :5])
Debug
Known issues
breakingAs of v25.12.00, `pylibraft-cu12` (and all `raft` variants) explicitly require CUDA 12.2 or newer. Using older CUDA versions will result in runtime errors or compilation failures.
fix
Ensure your system has CUDA Toolkit 12.2+ installed and configured correctly. For Docker, use RAPIDS base images built for CUDA 12.2+.
affects: >=25.12.00
breakingIn v26.02.00, significant internal C++ API restructuring occurred, including the removal of certain specific `neighbors/`, `cluster/`, `distance/`, `spatial/`, and `sparse/neighbors/` APIs. While core Python modules like `raft.neighbors` persist, specific less common algorithms, classes, or parameters within these modules may have been removed or changed.
fix
Consult the RAFT Python documentation for your specific version (e.g., `docs.rapids.ai/api/raft/stable/api_docs/python/`). Adapt your code to use available functions/parameters or alternative algorithms.
affects: >=26.02.00
breakingThe `lanczos` solver API was renamed in v26.04.00. If you were using this specific linear algebra component, your code will break.
fix
Update your code to use the new name for the Lanczos solver. Refer to the RAFT release notes or API documentation for the correct symbol name.
affects: >=26.04.00
gotchaInstalling `pylibraft-cu12` only provides the RAFT bindings. You will almost certainly need `cupy-cuda12x` (or another GPU array library like `cudf` for dataframes) to effectively work with GPU arrays required by RAFT algorithms.
fix
Always install `cupy-cuda12x` alongside `pylibraft-cu12` for practical use cases: `pip install pylibraft-cu12 cupy-cuda12x`.
affects: all
gotchaRAPIDS libraries, including RAFT, follow a monthly release cycle. This means breaking changes can occur frequently between minor version updates, requiring regular attention to release notes when upgrading.
fix
Pin your `pylibraft-cu12` version in `requirements.txt` to avoid unexpected breakage on update (e.g., `pylibraft-cu12==26.4.0`), and review release notes (e.g., on `github.com/rapidsai/raft/releases`) before upgrading.
affects: all
Upgrade
Version history
26.6.0latest on PyPI · released Jun 9, 2026
Audit
Dependencies
cupy-cuda12xoptionalEssential for handling GPU arrays (like CuPy arrays) that RAFT algorithms operate on. While not a direct dependency, RAFT is mostly unusable without it.
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
pylibraft-cu12 — pip install pylibraft-cu12 · libregistry