partagpu
Client Python pour PartaGPU — utilisez les GPU de plusieurs machines d'une salle de cours pour l'entraînement distribué.
Installation
pip install partagpu
Pré-requis
L'application PartaGPU doit tourner sur votre machine et sur chaque pair, toutes dans la même salle (même code d'accès), avec le partage activé sur les pairs cibles.
Pour DDP : torch doit être installé dans le Python système (/usr/bin/python3) de chaque pair — un venv utilisateur ne suffit pas (le sandbox tourne sous l'utilisateur partagpu et ne voit pas votre $HOME). Sur Ubuntu :
sudo pip install --break-system-packages torch
Découvrir les GPU
import partagpu
gpus = partagpu.discover()
# Une entree par CUDA device. Un PC avec 2 GPU produit 2 entrees,
# meme `host` / `ip`, `device_index` distinct.
# [GPU('local', ip='192.168.70.103', dev=0, limit=100%, verified),
# GPU('local', ip='192.168.70.103', dev=1, limit=100%, verified),
# GPU('César 2', ip='192.168.70.105', dev=0, limit=50%, verified)]
Exécuter une commande sur un pair (run_remote)
import partagpu
peer = next(g for g in partagpu.discover() if g.host != "local")
result = partagpu.run_remote(
peer,
["python3", "-c", "import torch; print(torch.cuda.get_device_name(0))"],
timeout=30,
)
print(result.stdout)
result.check() # raise si exit != 0
run_remote accepte aussi :
network=True— laisse le sandbox accéder au réseau (téléchargement de données, DDP, etc.)workspace={path: content}ouworkspace=[Path, ...]— pousse des fichiers dans le/workspacedu sandbox avant exécutiontimeout=int— secondes (défaut 300)user="alice"— label informatif côté pairlocal_id="..."— id pré-alloué pour pouvoir annuler la tâche par programme avant qu'elle ne retourne
Ctrl+C dans le notebook propage automatiquement le cancel au pair.
Annuler une tâche
# Par programme, depuis un autre notebook ou cellule
partagpu.cancel(local_id)
Le local_id vient de TaskResult.id (retourné par run_remote/distribute), ou que vous avez vous-même fixé via le kwarg local_id=.
Entraînement distribué (distribute)
import partagpu
results = partagpu.distribute(
"train.py",
args=["--epochs", "10"],
extra_files=["config.yaml", "utils.py"],
timeout=1800,
)
for r in results:
print(r.target_machine, r.exit_code)
print(r.stdout[-500:])
distribute :
- découvre tous les GPU de la salle (sauf si
gpus=est passé). Multi-GPU par machine géré : un PC avec 4 GPU contribue 4 workers ; - pousse
train.py(etextra_files) dans le sandbox de chaque pair ; - définit
MASTER_ADDR,MASTER_PORT,RANK,WORLD_SIZE,LOCAL_RANK,CUDA_VISIBLE_DEVICES,PARTAGPU_LOCAL_RANK,BACKENDsur chaque worker ; - isole chaque worker à un seul GPU physique via
CUDA_VISIBLE_DEVICES(le script utilise toujourscuda:0, peu importe l'index physique) ; - ouvre l'isolation réseau du sandbox de chaque pair (NCCL/Gloo rendezvous) ;
- lance les
world_sizeworkers en parallèle (sur les machines respectives), attend tous les résultats.
Côté train.py, vous initialisez DDP standard :
import os
import torch.distributed as dist
dist.init_process_group(backend=os.environ["BACKEND"], init_method="env://")
rank = int(os.environ["RANK"])
world_size = int(os.environ["WORLD_SIZE"])
# ... votre training ...
dist.destroy_process_group()
Configurer le backend manuellement (setup_ddp / cleanup_ddp)
Si vous voulez orchestrer DDP par vous-même (autre que distribute), les helpers minimaux sont disponibles :
from partagpu.distributed import setup_ddp, cleanup_ddp
setup_ddp(rank=0, world_size=2, master_addr="192.168.70.103", backend="nccl")
# ... votre code DDP ...
cleanup_ddp()
Voir aussi
- README principal — installation de l'app, gestion de salle, UI
- Architecture — comment fonctionne le dispatch pair-à-pair, le sandbox, DDP
- Diagnostic — erreurs courantes (auth HMAC mismatch, NCCL, sandbox, torch missing, etc.)
- Notebook d'exemples : examples/decouverte_gpu.ipynb
- Smoke tests : smoke_run_remote.py, smoke_ddp.py, smoke_multi_gpu.py
Metadata
Release files for partagpu 1.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| partagpu-1.6.1.tar.gz | 16.5 kB | With provenance | Details for partagpu-1.6.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| partagpu-1.6.1-py3-none-any.whl | Python 3 | none | any | Details for partagpu-1.6.1-py3-none-any.whl |
Total release size: 32.7 kB
Release files / partagpu-1.6.1.tar.gz
| Download URL | partagpu-1.6.1.tar.gz |
|---|---|
| Size | 16.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ff80f8de090884b3b921a786d17196c48d4ed709658541a0e32f44576a7a55b
|
|
BLAKE2b-256 checksum How to use checksums |
f0d6a7e8f689c856c93353bcd113ca212b8aea1633975bb6d9bf2339df0bba44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 9, 2026.
Transparency logRelease files / partagpu-1.6.1-py3-none-any.whl
| Download URL | partagpu-1.6.1-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
13628a350fea3615ce4ae110f93376610da5e9f16b07ac92def4cafddd398f25
|
|
BLAKE2b-256 checksum How to use checksums |
31f4124562991fd056ce042eca5237b8cca981274c8736b7046f07dccb6ba578
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 9, 2026.
Transparency logSecurity for partagpu 1.6.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for partagpu-1.6.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.