Skip to main content

Run any PyTorch script on a remote GPU. Change zero lines of code.

Project description

Chidori

Chidori GPU

Use any GPU, from anywhere. Zero code changes.

PyPI License Python


Chidori makes remote GPUs feel local. Your PyTorch training scripts, HuggingFace models, and CUDA applications run on remote GPU servers without changing a single line of code. Just pip install and go.

pip install chidori-gpu

30-Second Demo

On a machine with a GPU:

pip install chidori-gpu
chidori serve

On your laptop (no GPU needed):

pip install chidori-gpu
chidori run --server gpu-box:43211 python train.py

That's it. Your train.py runs on the remote GPU. No Docker, no SSH tunneling, no code changes.

Why Chidori?

Without Chidori With Chidori
SSH into GPU server, set up env, scp files chidori run -s host python train.py
Manage CUDA versions across machines Auto-detects and translates between versions
One user per machine One user per GPU, 8 clients on 8 GPUs
Port-forward Jupyter, sync files Run locally, compute remotely

Performance

Tested over WAN with 70ms round-trip latency:

Workload GPU Throughput
Matrix multiply (4096x4096) A100 40GB 96 TFLOPS
Training (23M params, FP32) A100 40GB 32,600 tok/s
Training (23M params, FP16) A100 40GB 59,000 tok/s
Inference (server-side decode) A100 40GB 100+ tok/s

4 parallel clients on 4 A100s: 384 TFLOPS combined.

Getting Started

1. Install

pip install chidori-gpu

Both client and server. One package, two roles.

2. Start a GPU Server

On any machine with an NVIDIA GPU:

chidori serve

First run auto-compiles the CUDA worker from bundled source (needs gcc + CUDA toolkit). Subsequent runs use the cached binary.

3. Run Your Code Remotely

chidori run --server 10.0.0.5:43211 python train.py

Your script sees a GPU. All CUDA calls are transparently routed over TCP to the remote server.

Multi-GPU

Got a server with 8 GPUs? Start one server per GPU:

for i in $(seq 0 7); do
    CUDA_VISIBLE_DEVICES=$i chidori serve --port $((43211 + i)) &
done

Each client connects to its own GPU:

chidori run -s gpu-box:43211 python job_a.py &   # GPU 0
chidori run -s gpu-box:43212 python job_b.py &   # GPU 1
chidori run -s gpu-box:43213 python job_c.py &   # GPU 2
# ...

8 researchers, 8 GPUs, zero contention.

Fast Inference

Standard model.generate() works out of the box at ~1 tok/s (limited by per-token RPC overhead). For 100x speedup, enable server-side graph decode:

import chidori
chidori.optimize()

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

tokenizer = AutoTokenizer.from_pretrained("TinyLlama/TinyLlama-1.1B-Chat-v1.0")
model = AutoModelForCausalLM.from_pretrained(
    "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
    dtype=torch.float16
).cuda()

# 100+ tok/s — server runs entire decode loop in a single RPC
output = model.generate(
    tokenizer("Hello", return_tensors="pt").input_ids.cuda(),
    max_new_tokens=200,
    do_sample=False,
    cache_implementation="static",
)
print(tokenizer.decode(output[0]))

Or use the direct API:

from chidori import server_decode
text = server_decode(model, tokenizer, "Explain quantum computing:", max_new_tokens=200)
# Returns generated text at 100+ tok/s

How It Works

┌──────────────────┐          TCP/IP          ┌──────────────────┐
│   Your Laptop    │  ◄──────────────────────► │   GPU Server     │
│                  │                           │                  │
│  python train.py │                           │  chidori serve   │
│       │          │                           │       │          │
│  LD_PRELOAD      │                           │  Real CUDA       │
│  libchidori.so   │   CUDA calls over wire    │  Driver + GPU    │
│       │          │  ─────────────────────►   │       │          │
│  intercepts      │                           │  executes on     │
│  280+ CUDA calls │  ◄─────────────────────   │  real hardware   │
│                  │   results back             │                  │
└──────────────────┘                           └──────────────────┘

Chidori uses LD_PRELOAD to intercept CUDA API calls at the driver level before they reach the (non-existent) local GPU. Each call is serialized into a compact wire protocol and sent over TCP. The remote server executes it on a real GPU and returns the result.

Key technical details:

  • 280+ CUDA functions intercepted — Driver API, Runtime API, cuBLAS, cuBLASLt, cuDNN
  • Async RPC batching — kernel launches are fire-and-forget, batched via TCP_CORK into single TCP segments
  • Server-side graph decode — captures a CUDA graph of the forward pass, then runs the entire autoregressive loop server-side (one RPC instead of hundreds)
  • Version-aware struct mapping — automatically translates cudaDeviceProp between CUDA 11.8 through 13.1
  • Zero-copy device-to-device — D2D copies send only 24 bytes over the wire (data stays on GPU)

Supported CUDA Versions

PyTorch Build CUDA Version Status
cu118 CUDA 11.8 Supported
cu121 CUDA 12.1 Supported
cu126 CUDA 12.6 Supported
cu128 CUDA 12.8 Supported
cu130 CUDA 13.0 Supported
cu131 CUDA 13.1 Supported

Client and server can run different CUDA versions. Chidori handles the translation.

CLI Reference

# Start a GPU server (auto-builds on first run)
chidori serve [--port 43211]

# Run a command on a remote GPU
chidori run --server HOST[:PORT] [--verbose] [--trace] COMMAND...

# Examples
chidori run -s 10.0.0.5 python train.py
chidori run -s gpu1:43211 python -c "import torch; print(torch.cuda.get_device_name(0))"
chidori run -s gpu1:43211 --trace python benchmark.py   # show RPC trace

Requirements

Client (your machine):

  • Linux x86_64
  • Python 3.9+
  • PyTorch (any cu11x/cu12x/cu13x build)

Server (GPU machine):

  • Linux x86_64
  • NVIDIA GPU with drivers installed
  • CUDA toolkit (nvcc, headers, libraries)
  • gcc and libzstd-dev

Contributing

Chidori is open source under the Apache 2.0 license. Contributions welcome.

git clone https://github.com/fpolica91/chidori.git
cd chidori/chidori-worker
make all CUDA_PATH=/usr/local/cuda

License

Apache 2.0

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

chidori_gpu-0.1.3.tar.gz (816.7 kB view details)

Uploaded Source

Built Distribution

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

chidori_gpu-0.1.3-py3-none-any.whl (843.8 kB view details)

Uploaded Python 3

File details

Details for the file chidori_gpu-0.1.3.tar.gz.

File metadata

  • Download URL: chidori_gpu-0.1.3.tar.gz
  • Upload date:
  • Size: 816.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for chidori_gpu-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8afbca626124e755f1da2ff536323f3038b2ea37d81899080c4ab0e8901cbdb7
MD5 051271af0a2867681024e1681e2422ba
BLAKE2b-256 633ead51de3209f44dcd264d7d8b522baf06d299ba2df405c154b77fc36c7785

See more details on using hashes here.

File details

Details for the file chidori_gpu-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: chidori_gpu-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 843.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for chidori_gpu-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9e4c34c3f7731cb64e4311e584aef767545bd196202e3421f61596ff5d09d845
MD5 7b5fc737ffaa647deff139ad5230ce68
BLAKE2b-256 543574af58b8940873e67cc16cc174012a952de30a6ef34814df98e10c11e4b0

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