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.3.tar.gz (5.0 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.3-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cunumpy-0.1.3.tar.gz
  • Upload date:
  • Size: 5.0 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.3.tar.gz
Algorithm Hash digest
SHA256 bd50893719558fb9d572a8edaa3dafe587ae2052cb259531f66b9a1d284c1adc
MD5 bcf57d04b320f716a1bf14b41ed90bbb
BLAKE2b-256 a3d6409d686829250527d5d3887d83a9433db54622cc503655836311fa3bc950

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cunumpy-0.1.3-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.10.20

File hashes

Hashes for cunumpy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 171074c1a0a56f25c01f7714f4d641d8874581e7e33f222a340d63e7558e176f
MD5 e7ce6e34e41af37a0924aeaec5c79cf5
BLAKE2b-256 263dfbaa0fe755a6ac68e31bf6bb5911f68be371208dc84be0ed4dae176dd56d

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.4

2 files

This release

0.1.3 This release

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