Learn / DGX Spark Ray Cluster Setup
Ray cluster, part 2: set up, check, stop
Now set up Ray on two DGX Sparks. First, the safety warning. Anyone who can reach Ray's dashboard, jobs or client services can run code on your Sparks.
Chapters
- 0:00Introduction
- 0:06Read this first: Ray runs code
- 0:24On both Sparks: Install the same version
- 0:34First Spark only: One token for both
- 0:48First Spark: Start the head
- 0:57Second Spark: Join the worker
- 1:05First Spark: Check both joined
- 1:15First Spark: See where work ran
- 1:28Stop: Stop the worker first
- 1:38Wrap up
Read the transcript
Introduction
Now set up Ray on two DGX Sparks. First, the safety warning.
Read this first: Ray runs code
Anyone who can reach Ray's dashboard, jobs or client services can run code on your Sparks. Never expose them. Block Ray's ports from every network except the cluster link. Turn on token authentication. It adds to that protection, and doesn't replace it.
On both Sparks: Install the same version
Make a Python environment on both Sparks. Switch it on. Install the same Ray version on both, with matching Python versions.
python3 -m venv ~/ray-env
source ~/ray-env/bin/activate
pip install "ray[default]==VERSION"First Spark only: One token for both
Make the token on the first Spark. This prints it, so keep your screen private. Make a private folder on the second Spark. Copy the token across, over the cluster link. Then make the copy readable only by you.
ray get-auth-token --generate
ssh USER@SECOND-SPARK-LINK-ADDRESS \
'mkdir -p ~/.ray && chmod 700 ~/.ray'
scp ~/.ray/auth_token \
USER@SECOND-SPARK-LINK-ADDRESS:.ray/auth_token
ssh USER@SECOND-SPARK-LINK-ADDRESS \
'chmod 600 .ray/auth_token'First Spark: Start the head
On the first Spark, turn token mode on. Then start the head on its cluster link address, with the dashboard on localhost.
export RAY_AUTH_MODE=token
ray start --head --port=6379 \
--node-ip-address=FIRST-SPARK-LINK-ADDRESS \
--dashboard-host=localhostSecond Spark: Join the worker
On the second Spark, turn token mode on there too. Then join the head, using the second Spark's own link address.
export RAY_AUTH_MODE=token
ray start --address=FIRST-SPARK-LINK-ADDRESS:6379 \
--node-ip-address=SECOND-SPARK-LINK-ADDRESSFirst Spark: Check both joined
Check the listening ports, so you know what your firewall must block. Then ask for the status. You want two active nodes, and two GPUs if you offered both.
sudo ss -ltnp
ray statusFirst Spark: See where work ran
Run the small example from the written page. It counts tasks by host name. Compare default with spread. The counts needn't be equal. Ray's task list can also show which node ran each task.
python where_ran.py
ray list tasks --detailStop: Stop the worker first
Finish your jobs first. Stopping ends all Ray processes on that machine. Run it on the worker. Then run it on the head.
ray stop # on the second Spark
ray stop # then on the firstWrap up
The written page covers vLLM, undoing the setup, and problems.
Sources
- docs.ray.io/en/latest/ray-security/index.html
- docs.ray.io/en/latest/ray-security/token-auth.html
- docs.ray.io/en/latest/cluster/vms/user-guides/launching-clusters/on-premises.html
- docs.ray.io/en/latest/cluster/cli.html
- docs.ray.io/en/latest/ray-core/configure.html
- docs.ray.io/en/latest/ray-overview/installation.html
- docs.ray.io/en/latest/ray-core/scheduling/index.html
- docs.ray.io/en/latest/ray-observability/user-guides/cli-sdk.html