Skip to main content

CuNumpy

Simple wrapper for numpy and cupy. Replace import numpy as np with import cunumpy as xp.

Install

pip install cunumpy

Example usage:

export ARRAY_BACKEND=cupy
import cunumpy as xp

arr = xp.array([1, 2])

print(type(arr))
print(xp.__version__)

# Convert to NumPy
arr_np = xp.to_numpy(arr)

# Convert to active backend
arr_xp = xp.to_cunumpy(arr)

# Inspect backend
print(xp.get_backend(arr))
print(xp.is_gpu(arr))
print(xp.is_cpu(arr))

# Temporarily switch backend
with xp.use_backend("numpy"):
    # This code runs on CPU even if ARRAY_BACKEND=cupy
    arr_cpu = xp.zeros(100)

# Set backend globally
xp.set_backend("cupy")

# Synchronize GPU operations (no-op on CPU)
xp.synchronize()

Build docs

make html
cd ../
open docs/_build/html/index.html

Download files

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

Source Distribution

cunumpy-0.1.4.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

cunumpy-0.1.4-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file cunumpy-0.1.4.tar.gz.

File metadata

  • Download URL: cunumpy-0.1.4.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for cunumpy-0.1.4.tar.gz
Algorithm Hash digest
SHA256 4acbe230aaa7ad7ec342a0b08d2e15adf8245affacabb7bec004a334152318b6
MD5 7bf9a24c0905aeea7661c2dbacbf0f18
BLAKE2b-256 34483314be3511e9d2c146a1708eed8645d9ee3e36d5b0d0792ea10b4f0d61d7

See more details on using hashes here.

File details

Details for the file cunumpy-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: cunumpy-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for cunumpy-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4901e1ba21e959cec1964590029dc831571fe2d984c73a45a0e7735555202ed6
MD5 af25815e75e132f9ad4ad91703ecf181
BLAKE2b-256 5197e7aa1c5215dd4ceb16c1ce3fc864a750b2606dfd5d4fed8e37cdd2d0a956

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page