Skip to main content

cuKNN ⚡

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.1.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.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cuknn-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 caa817fcdfe88c6de659048b2f306d8169dec9312c897484f138de2fe8b40465
MD5 4ee17768ebbda6819b95e8bda9a925a7
BLAKE2b-256 61d63cff528d22af0b15938d5117249528b02a718e5946af553a7a39587a49e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cuknn-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a121aeab5a8d7d4165e853153ccce28523b2f94013b455215f7090f34d107914
MD5 bf87b90d877f486577e9fae1b7d4b0bc
BLAKE2b-256 3c17f373355da3d6f798f8e2573d0856181ffa6bb9fb6ee8f6ea3b95bd0dc101

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

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