Skip to main content

Borrow your friends' GPUs: a terminal-based distributed compute mesh in pure Python

Project description

gpumesh

Borrow your friends' GPUs. A distributed compute mesh that lets you share GPU power across machines using Python.

PyPI version Python License


Features

  • Unified GPU pool — See all connected GPUs as one system
  • One-line setupgpumesh setup handles everything
  • Auto-discovery — Workers find coordinators on the same network
  • Smart scheduling — Fast GPUs get heavy tasks, slow ones get light tasks
  • Fault tolerance — Dead workers are detected, tasks are re-queued
  • Python API — Distribute functions from Jupyter notebooks

Installation

pip install gpumesh

Optional extras:

pip install gpumesh[gpu]       # GPU detection + CUDA benchmarks
pip install gpumesh[tunnel]    # ngrok for public URLs
pip install gpumesh[all]       # everything

Requires Python 3.9+.


Quick Start

1. Start a coordinator (one machine)

gpumesh serve --token mySecret

2. Join a worker (another machine)

gpumesh join http://192.168.1.10:8000 --token mySecret

3. Submit a job

# Set connection (saved automatically after first join)
export GPUMESH_URL=http://192.168.1.10:8000
export GPUMESH_TOKEN=mySecret

# Run a script across all workers
gpumesh submit examples/grid_search.py --payloads examples/payloads.json --wait

CLI Commands

Command Description
gpumesh setup Interactive setup wizard
gpumesh serve Start coordinator
gpumesh join URL Join as worker
gpumesh submit SCRIPT --payloads FILE Submit a job
gpumesh status JOB_ID Check job progress
gpumesh cancel JOB_ID Cancel a job
gpumesh kill Kill all tasks
gpumesh workers List connected workers
gpumesh devices Show all GPUs as one pool
gpumesh --version Show version

Python API

from gpumesh import GPUMesh

# Connect to coordinator
mesh = GPUMesh("http://192.168.1.10:8000", token="mySecret")

# List workers
mesh.workers()

# Distribute a function across all workers
def train(lr, epochs):
    import os
    device = os.environ.get("GPUMESH_DEVICE", "cpu")
    # Your training code here
    return {"accuracy": 0.95, "lr": lr, "device": device}

results = mesh.distribute(
    function=train,
    params=[
        {"lr": 0.01, "epochs": 100},
        {"lr": 0.05, "epochs": 200},
    ],
)

See full API documentation for Jupyter/Colab examples, closures, and error handling.


Writing Task Scripts

Your script receives parameters on stdin and prints JSON on stdout:

import json, sys, os

payload = json.load(sys.stdin)
device = os.environ.get("GPUMESH_DEVICE", "cpu")

result = {"answer": 42, "device": device}
print(json.dumps(result))

Network Options

Method Setup Best for
LAN None Same Wi-Fi, fastest
Tailscale Install Tailscale Remote teams
ngrok pip install gpumesh[tunnel] Public access

Limitations

  • Python only — Tasks must be Python scripts
  • No GPU memory sharing — Each task gets its own process
  • No model sharding — Each task runs on one machine
  • Single coordinator — Single point of failure
  • No persistent storage — Export results before shutdown

Troubleshooting

Problem Fix
command not found Use python -m gpumesh instead
401 bad token Check coordinator and worker tokens match
coordinator unreachable Check firewall and that coordinator is running
task timed out Increase --timeout 600 or split into smaller tasks

Security

  • Token authentication on all API requests
  • Tokens hashed with SHA-256 before storage
  • Rate limiting after 5 failed attempts
  • Process isolation for all tasks

Important: Workers execute code from the coordinator. Only share your URL and token with people you trust.


Contributing

git clone https://github.com/Samurai007AK/gpumesh.git
cd gpumesh
pip install -e ".[dev]"
pytest

License

MIT License. See LICENSE for details.


Links

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

gpumesh-0.7.1.tar.gz (96.5 kB view details)

Uploaded Source

Built Distribution

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

gpumesh-0.7.1-py3-none-any.whl (61.8 kB view details)

Uploaded Python 3

File details

Details for the file gpumesh-0.7.1.tar.gz.

File metadata

  • Download URL: gpumesh-0.7.1.tar.gz
  • Upload date:
  • Size: 96.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for gpumesh-0.7.1.tar.gz
Algorithm Hash digest
SHA256 a6cca19d767080a7a6570e2e23af715c290750069b84318c03b16d0604c54289
MD5 5c0c9a92b34eddd1bebac38415a3bf40
BLAKE2b-256 b7d5d6d7591aa2cba706812486345a5581536c91d36565b2e17d55821b599c0f

See more details on using hashes here.

File details

Details for the file gpumesh-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: gpumesh-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 61.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for gpumesh-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ac258bdccf5b126a2e42b28b230a4f203ff8f071d5ce098ff1d004238a000f4
MD5 1bec3c3c658092dad44a9a7ae30602ed
BLAKE2b-256 407491a9e51ffad113904a4ca98dbcc80e97c7675878cae70a30c4d386310278

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