Skip to main content

NumPy-like GPU array library that works on every GPU — NVIDIA, AMD, Intel, Apple Silicon. No CUDA required.

Project description

gpuarray

NumPy-like GPU array library that works on every GPU — NVIDIA, AMD, Intel, Apple Silicon. No CUDA required.

Powered by WebGPU via wgpu-py. Uses Metal on macOS, Vulkan on Windows/Linux, and DirectX 12 on Windows.

Install

pip install gpuarray

Usage

import gpuarray as gp

# Create arrays on GPU
a = gp.array([1, 2, 3, 4, 5])
b = gp.ones(5) * 3

# Operations run on GPU
c = a + b
d = a * b
e = gp.dot(a, b)

# Read back to CPU
print(c.to_numpy())  # [4. 5. 6. 7. 8.]

# Matrix multiply
A = gp.ones((512, 512))
B = gp.ones((512, 512))
C = gp.matmul(A, B)  # runs on GPU

# Reductions
total = gp.sum(a)
avg = gp.mean(a)

# Math functions
x = gp.exp(a)
y = gp.log(a)
z = gp.sqrt(a)

Why?

CuPy only works on NVIDIA GPUs with CUDA. gpuarray works on every GPU:

GPU CuPy gpuarray
NVIDIA (CUDA)
AMD (Vulkan)
Intel (Vulkan)
Apple Silicon (Metal)

Supported Operations

Array Creation

array, zeros, ones, arange, linspace

Elementwise Binary

+, -, *, /, ** (with arrays or scalars)

Elementwise Unary

exp, log, sqrt, abs, neg, relu, sigmoid, tanh

Reductions

sum, mean, max, min

Linear Algebra

dot, matmul

Performance

Benchmarks on Intel UHD 630 (integrated GPU) vs NumPy (CPU with SIMD):

Operation NumPy gpuarray Speedup
add 10M elements 11.6ms 19.9ms 0.59x
matmul 512x512 1.3ms 1.0ms 1.22x
sum 10M 4.3ms 12.5ms 0.34x

The integrated GPU shows speedup on compute-heavy operations (matmul). Discrete GPUs (RTX 3080, RX 7900, etc.) will show much larger speedups across all operations.

Requirements

  • Python 3.10-3.13
  • Any GPU supported by WebGPU (most GPUs from 2015+)
  • No CUDA, no special drivers — just your system GPU

How It Works

  1. Arrays are stored as WebGPU GPU buffers
  2. Operations dispatch WGSL compute shaders to the GPU
  3. Pipelines are cached — repeated operations don't recompile
  4. Results stay on GPU until you call .to_numpy()

License

MIT

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

gpuarray-0.4.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

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

gpuarray-0.4.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file gpuarray-0.4.0.tar.gz.

File metadata

  • Download URL: gpuarray-0.4.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for gpuarray-0.4.0.tar.gz
Algorithm Hash digest
SHA256 5e73325c06cd498d2c1708bc7519a38272c3c95e2d19f347449e72ea3c37cf24
MD5 459ca37cc7430a9a30a9b664a890e494
BLAKE2b-256 f587f37661a4f11b64d73e6db8303bb729a1112c38e3cd8df2a3742814aad3e4

See more details on using hashes here.

File details

Details for the file gpuarray-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: gpuarray-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for gpuarray-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 198cbfee95470245f9a166a24b24e042b6f6f06d1601a9131224f40e08c4159e
MD5 aa7996a0f35a715fae87107cb94ddb56
BLAKE2b-256 b76157d2f1907dda85e5cc6bfd9e878a7693ca9a1b6cd70a17e77b32a36bc1ac

See more details on using hashes here.

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