Learn / DGX Spark PyTorch Distributed
PyTorch on two DGX Sparks, part 2: set up, check and stop
Now let's run a small check across both Sparks. PyTorch's distributed traffic has no sign-in and no encryption.
Chapters
- 0:00Introduction
- 0:04Before you start: A private network
- 0:16On both Sparks: Same container
- 0:30On both Sparks: One command
- 0:39Success: Look for two
- 0:48Your real job: Start small
- 1:04Stop and undo: Stopping loses work
- 1:17Wrap up
Read the transcript
Introduction
Now let's run a small check across both Sparks.
Before you start: A private network
PyTorch's distributed traffic has no sign-in and no encryption. Anyone who can reach it can run code as your user, so use only a network you control.
On both Sparks: Same container
Save the small check script on both Sparks. Open the same PyTorch container on each. It uses the Spark's own network, and your work folder. Set the head address to the first Spark, and name the cluster interface.
On both Sparks: One command
Run the same torchrun command on both. It asks for two nodes, one process each. Start the first, then promptly the second.
torchrun --nnodes=2 --nproc-per-node=1 \
--rdzv-id=spark-check --rdzv-backend=c10d \
--rdzv-endpoint="$HEAD_IP:29400" \
check_link.pySuccess: Look for two
Each side should say a world size of two. And each should show a sum of two. If it waits, check the address, port, job name and link.
Your real job: Start small
Try your own script on a small piece of data. Watch the GPU, processor and memory on both. Change one setting at a time, and compare the same number of steps. Test that you can resume from a checkpoint, and that both Sparks can read it.
Stop and undo: Stopping loses work
Stopping loses work since the last checkpoint. Press control C on both, check the GPU is free, then leave each container. To undo, delete the check script. The container removes itself.
Wrap up
The written page has the commands, fixes and sources.
Sources
- docs.pytorch.org/docs/2.15/elastic/run.html
- docs.pytorch.org/docs/2.15/distributed.html
- github.com/pytorch/pytorch/blob/main/SECURITY.md
- docs.pytorch.org/tutorials/intermediate/ddp_series_multinode.html
- github.com/NVIDIA/dgx-spark-playbooks/tree/main/nvidia/playbook-pytorch-fine-tune