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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gpuarray-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b0ae921c3f03bae9d89b7e7bd67a3f09d925ee2da1faf4e9f8218311bab476c3
MD5 73cb3635fb41197555858544a3d34d0f
BLAKE2b-256 bab0a1eaedfdf9ef779876d122a02fe56b4efddac49366c3559788f57040b801

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gpuarray-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 20.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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8371dd523e776e83d033be4adc611d00618a4f8e04b6ac3381d03305f468c3a3
MD5 65fe65aee0e4edbb90ad42c95e8f0bca
BLAKE2b-256 6ce748f9c4d2e6d369a105f30d4ab778f2997ffda8f8e61163397d6037619e41

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