Skip to main content

A package for the k-means algorithm on DPU.

Project description

dpu_kmeans README

CI status
pip builds Pip Actions Status
docs Doc Status

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

Documentation

Installation

  • install the UPMEM SDK
  • pip install dpu-kmeans

If you get an error about RANLIB, create a symlink to llvm-ar:

sudo ln -s /usr/bin/llvm-ar /usr/bin/llvm-ranlib

Usage

import numpy as np
from dpu_kmeans import KMeans

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

kmeans = KMeans(2)
kmeans.fit(X)

print(kmeans.cluster_centers_)

Output:

[[ 0.99986267  2.        ]
 [10.00013733  2.        ]]

Development

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

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.

Templating

To use this project as a base for your own UPMEM DIMM project:

  • click on "Use this template" in github
  • create a new project from this one
  • turn off Conda and Wheels workflows in github actions as they are not operational right now
  • change folder src/dpu_kmeans to src/<your_project>
  • change project name (all instances of dpu_kmeans) and info in:
    • README.md
    • setup.cfg
    • setup.py (cmake_install_dir="src/dpu_kmeans")
    • .gitignore (src/dpu_kmeans/dpu_program/)
    • CMakeLists.txt (project(dpu_kmeans VERSION ${VERSION}))
    • conda.recipe/meta.yaml (optional)
    • docs (optional)
  • if you intend to use github actions to auto-publish to pypi, update the project secrets as described in Publishing package distribution releases using GitHub Actions CI/CD workflows

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.2.3.tar.gz (30.9 kB view details)

Uploaded Source

File details

Details for the file dpu_kmeans-0.2.3.tar.gz.

File metadata

  • Download URL: dpu_kmeans-0.2.3.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for dpu_kmeans-0.2.3.tar.gz
Algorithm Hash digest
SHA256 0cf16c6a626acebaacc454899954f03c61b77db4da3a3a82141951a1b742baed
MD5 1cb7bc71accd5460f1da3c2ce5c7795a
BLAKE2b-256 4e5eb32abf3797f1772975765a39cb9e171c1400af4897a2e9929a8e85499351

See more details on using hashes here.

Provenance

The following attestation bundles were made for dpu_kmeans-0.2.3.tar.gz:

Publisher: publish-to-test-pypi.yml on upmem/dpu_kmeans

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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