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.3.0.tar.gz (15.7 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.3.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gpuarray-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a8edcb48ec2c782a502880a35608ea10641797b9a46e497f97bb2d81652a61e1
MD5 3a0210a16af354f4b9cc54447248b4ce
BLAKE2b-256 0910e5f6c459badb1faae53b24ec983b995a465e47c305a7bcca059f0a6a1093

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gpuarray-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39e819cc2dac10b0d56492f676d349fc2d1577291cdc5b8f41158d64feba748a
MD5 2bc25ab89f84140ed3fe8e3615304f1d
BLAKE2b-256 fa0251c6a5791bf5a2b802a1d3eba2ee09bed6f90a02011d8501bb372a9b0e86

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