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

  1. 0:00Introduction
  2. 0:04Before you start: A private network
  3. 0:16On both Sparks: Same container
  4. 0:30On both Sparks: One command
  5. 0:39Success: Look for two
  6. 0:48Your real job: Start small
  7. 1:04Stop and undo: Stopping loses work
  8. 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.py

Success: 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

More lessons