Client Python pour PartaGPU — entraînement distribué multi-GPU sur réseau local
Project description
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
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
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 partagpu-1.6.1.tar.gz.
File metadata
- Download URL: partagpu-1.6.1.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ff80f8de090884b3b921a786d17196c48d4ed709658541a0e32f44576a7a55b
|
|
| MD5 |
9a7eaf57d8a9b1fbc8585cabcdf7a0a0
|
|
| BLAKE2b-256 |
f0d6a7e8f689c856c93353bcd113ca212b8aea1633975bb6d9bf2339df0bba44
|
Provenance
The following attestation bundles were made for partagpu-1.6.1.tar.gz:
Publisher:
pypi.yml on cesar-lizurey/partagpu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
partagpu-1.6.1.tar.gz -
Subject digest:
5ff80f8de090884b3b921a786d17196c48d4ed709658541a0e32f44576a7a55b - Sigstore transparency entry: 1484462300
- Sigstore integration time:
-
Permalink:
cesar-lizurey/partagpu@889c57877ba9d0a7d3c9a6d33222878f096c5272 -
Branch / Tag:
refs/tags/python-v1.6.1 - Owner: https://github.com/cesar-lizurey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@889c57877ba9d0a7d3c9a6d33222878f096c5272 -
Trigger Event:
push
-
Statement type:
File details
Details for the file partagpu-1.6.1-py3-none-any.whl.
File metadata
- Download URL: partagpu-1.6.1-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13628a350fea3615ce4ae110f93376610da5e9f16b07ac92def4cafddd398f25
|
|
| MD5 |
23931a53db413ad646986aa5300bdafb
|
|
| BLAKE2b-256 |
31f4124562991fd056ce042eca5237b8cca981274c8736b7046f07dccb6ba578
|
Provenance
The following attestation bundles were made for partagpu-1.6.1-py3-none-any.whl:
Publisher:
pypi.yml on cesar-lizurey/partagpu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
partagpu-1.6.1-py3-none-any.whl -
Subject digest:
13628a350fea3615ce4ae110f93376610da5e9f16b07ac92def4cafddd398f25 - Sigstore transparency entry: 1484462364
- Sigstore integration time:
-
Permalink:
cesar-lizurey/partagpu@889c57877ba9d0a7d3c9a6d33222878f096c5272 -
Branch / Tag:
refs/tags/python-v1.6.1 - Owner: https://github.com/cesar-lizurey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@889c57877ba9d0a7d3c9a6d33222878f096c5272 -
Trigger Event:
push
-
Statement type: