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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd50893719558fb9d572a8edaa3dafe587ae2052cb259531f66b9a1d284c1adc
|
|
| MD5 |
bcf57d04b320f716a1bf14b41ed90bbb
|
|
| BLAKE2b-256 |
a3d6409d686829250527d5d3887d83a9433db54622cc503655836311fa3bc950
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
171074c1a0a56f25c01f7714f4d641d8874581e7e33f222a340d63e7558e176f
|
|
| MD5 |
e7ce6e34e41af37a0924aeaec5c79cf5
|
|
| BLAKE2b-256 |
263dfbaa0fe755a6ac68e31bf6bb5911f68be371208dc84be0ed4dae176dd56d
|