Skip to main content

CuPy-KNN ⚡

CuPy-KNN logo

GPU-Accelerated K-Nearest Neighbors using NVIDIA CUDA and CuPy

Python CUDA License

🚀 Overview

CuPy-KNN is a GPU accelerated implementation of the K-Nearest Neighbors algorithm powered by CuPy.

It provides a scikit-learn compatible API while exploiting NVIDIA GPUs for large-scale nearest neighbor search.

Designed for:

  • Machine Learning
  • Deep Learning embeddings
  • Computer Vision features
  • Bioinformatics embeddings
  • Large-scale similarity search

✨ Features

✅ GPU acceleration with CUDA
✅ Batch-based distance computation
✅ Multiple distance metrics:

  • Euclidean
  • Cosine
  • Manhattan

✅ sklearn-like API

  • fit()
  • predict()
  • predict_proba()
  • kneighbors()

✅ Supports large datasets
✅ Fully implemented with CuPy tensors

📦 Installation

Install from PyPI:

pip install cuknn

For CUDA-enabled systems install CuPy first:

pip install cupy-cuda12x

or select the version matching your CUDA installation.

⚡ Quick Start

from cuknn import KNN

from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split


X, y = make_classification(
    n_samples=100000,
    n_features=512,
    n_classes=5
)


X_train, X_test, y_train, y_test = train_test_split(
    X,
    y
)


model = KNN(
    k=5,
    distance="euclidean",
    batch_size=1024
)


model.fit(
    X_train,
    y_train
)


prediction = model.predict(
    X_test
)

📚 Citation

If you use cuKNN in your research:

@software{cupy_knn,
 author = {Calderaro, Salvatore},
 title = {cuKNN: GPU Accelerated K-Nearest Neighbors},
 year = {2026}
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cuknn-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cuknn-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file cuknn-0.1.0.tar.gz.

File metadata

  • Download URL: cuknn-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for cuknn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8c124e0fd97e7a00e193daa1d9159bc91ad09fe6f1beec5ed79e4ebe5dcbbe2b
MD5 6117bd5b22a58ba2d4d6b0f147da1561
BLAKE2b-256 2fd95a7aa259ac0050189416059a3e8bfb7281bf9de80cc6347f395501160504

See more details on using hashes here.

File details

Details for the file cuknn-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cuknn-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for cuknn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6c5519139253d82a7d7df309cbfb30b09a9113e1f78ad7e718f34dce36f8d00
MD5 13bdbcade2880d67ffa356f46940519b
BLAKE2b-256 f60b6d9d5245c2fc84c6abcb0cbb3bb3d1aa16959a06ab6c2909a1d3a6c9c184

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page