Skip to main content

A package for the k-means algorithm on DPU.

Project description

dpu_kmeans

CI status
pip builds Pip Actions Status

A project built with pybind11 and scikit-build, running the KMeans algorithm on in-memory processors with the UPMEM SDK.

Installation

  • install the UPMEM SDK
  • pip install dpu-kmeans

Usage

import numpy as np
from dpu_kmeans import DIMM_data, KMeans

X = np.array([[1, 2], [1, 4], [1, 0],[10, 2], [10, 4], [10, 0]])
dimm_data = DIMM_data(X)

kmeans = KMeans(2)

centroids, iterations, time = kmeans.fit(dimm_data)
print(centroids)

Output:

[[ 0.9998627  2.       ]
 [10.000137   2.       ]]

Alternatively you can import data from a CSV file:

dimm_data = DIMM_data("/path/to/data")

Development

  • clone this repository
  • install the UPMEM SDK
  • install the build requirements in pyproject.toml
  • cd dpu_kmeans
  • pre-commit install
  • pip install -e .
  • python setup.py clean

OR

  • clone this repository
  • open folder in VS Code
  • start in Dev Container

to debug: python setup.py develop --build-type Debug

Note: The dev container is for development only and uses the PIM simulator.

Testing

  • clone this repository
  • install the UPMEM SDK
  • install nox
  • cd dpu_trees
  • nox

OR

  • clone this repository
  • open folder in VS Code
  • start in Dev Container
  • nox

Note: nox, python setup.py and pip might fail if you executed pip install -e . previously, delete the _skbuild cache or run python setup.py clean to solve.

Test call

import dpu_kmeans
dpu_kmeans.test_checksum()

Expected return: 0x007f8000

Project details


Download files

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

Source Distribution

dpu_kmeans-0.1.6.tar.gz (24.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page