Package for data prefetching on GPU.
Project description
GPU prefetching
A minimal package for GPU prefetching from disk.
Installation 🚀
pip install --upgrade pip uv
uv pip install gpuprefetch
Usage 🔥
The snippet below show how to easily instantiate our prefetching.
from gpuprefetch import Prefetcher
# By default, we do not install jax,
# you need to install it separately if you want to use our converter.
from gpuprefetch.converter import cupy_to_jax
def my_loader():
# Replace with your real disk I/O
return np.random.rand(64, 64, 3).astype(np.float32)
with Prefetcher(
loader=my_loader, # The callable loading the data
# (e.g., from disk)
dtype=cp.float32, # Type of data.
shape=(64,64,3), # Shape of the data for pre-allocation.
capacity=100, # Buffer size.
# The larger, the higher the memory
# consumption but the lower the latency.
device="cuda:0", # Where you want your data to be loaded.
# We currently support only cuda devices.
post=cupy_to_jax, # By default, we return a cupy array.
# You can use one of our efficient converters
# on the returned value, pass it as `post`
# argument, or pass a custom callable.
# We use it as: return post(data)
nworkers=32, # We spawn nworkers processes to concurrently
# fill the queue.
) as loader_with_prefetching:
# Inside this block, the workers are active and they are safely
# killed on exit.
# You can access the pre-fetched data with:
prefetched_data = next(loader_with_prefetching)
Citation ☕️
If this was useful in your research software, you can cite this work as:
@software{terpin2025gpuprefetching,
author = {Terpin, Antonio},
title = {A minimal GPU prefetching package.},
year = {2025},
version = {1.0.0},
url = {https://github.com/antonioterpin/gpu-prefetch},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gpuprefetch-0.1.0.tar.gz
(5.6 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 gpuprefetch-0.1.0.tar.gz.
File metadata
- Download URL: gpuprefetch-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
415add77fee3ebbdd8463e7c16e93ac2fc7cdb7676bfdb1eabedf32ac1383932
|
|
| MD5 |
c7d31ec02a3b23ca040649293135830d
|
|
| BLAKE2b-256 |
cda317327080180ae8191f23f304676e799bebd8d5e4980d23b551d9104a80f5
|
File details
Details for the file gpuprefetch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gpuprefetch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
238c93a93654b6dee27f57672cd60041dcb0f632e336278ec6858b272f890e49
|
|
| MD5 |
644d0e362de87d595b4be5afc6ff6189
|
|
| BLAKE2b-256 |
0eb22a0b2349014ee15ea81076406271d0c84b778c5ce42a15ad8d2ecc0d9e93
|