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)
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.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4acbe230aaa7ad7ec342a0b08d2e15adf8245affacabb7bec004a334152318b6
|
|
| MD5 |
7bf9a24c0905aeea7661c2dbacbf0f18
|
|
| BLAKE2b-256 |
34483314be3511e9d2c146a1708eed8645d9ee3e36d5b0d0792ea10b4f0d61d7
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4901e1ba21e959cec1964590029dc831571fe2d984c73a45a0e7735555202ed6
|
|
| MD5 |
af25815e75e132f9ad4ad91703ecf181
|
|
| BLAKE2b-256 |
5197e7aa1c5215dd4ceb16c1ce3fc864a750b2606dfd5d4fed8e37cdd2d0a956
|