Skip to main content

🇬🇧 English version

PartaGPU

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} ou workspace=[Path, ...] — pousse des fichiers dans le /workspace du sandbox avant exécution
  • timeout=int — secondes (défaut 300)
  • user="alice" — label informatif côté pair
  • local_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 (et extra_files) dans le sandbox de chaque pair ;
  • définit MASTER_ADDR, MASTER_PORT, RANK, WORLD_SIZE, LOCAL_RANK, CUDA_VISIBLE_DEVICES, PARTAGPU_LOCAL_RANK, BACKEND sur chaque worker ;
  • isole chaque worker à un seul GPU physique via CUDA_VISIBLE_DEVICES (le script utilise toujours cuda:0, peu importe l'index physique) ;
  • ouvre l'isolation réseau du sandbox de chaque pair (NCCL/Gloo rendezvous) ;
  • lance les world_size workers 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

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)

Source distribution for partagpu 1.6.1
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)

Table of built distributions (wheels) for partagpu 1.6.1
File Interpreter ABI Platform Actions
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 log

Release 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 log

Security 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.

Select from 2 files

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 log

A 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.

Release history Release notifications | RSS feed

This release

1.6.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page