-
Notifications
You must be signed in to change notification settings - Fork 204
Configure inter-node SSH on multi-node tasks #2394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| type: task | ||
| name: nccl-tests | ||
|
|
||
| image: un1def/aws-efa-test | ||
| nodes: 2 | ||
|
|
||
| env: | ||
| - NCCL_DEBUG=INFO | ||
|
|
||
| commands: | ||
| - | | ||
| # We use FIFO for inter-node communication | ||
| FIFO=/tmp/dstack_job | ||
| if [ ${DSTACK_NODE_RANK} -eq 0 ]; then | ||
| cd /root/nccl-tests/build | ||
| echo "${DSTACK_NODES_IPS}" > hostfile | ||
| MPIRUN='mpirun --allow-run-as-root --hostfile hostfile' | ||
| # Wait for other nodes | ||
| while true; do | ||
| if ${MPIRUN} -n ${DSTACK_NODES_NUM} -N 1 true >/dev/null 2>&1; then | ||
| break | ||
| fi | ||
| echo 'Waiting for nodes...' | ||
| sleep 5 | ||
| done | ||
| # Run NCCL Tests | ||
| ${MPIRUN} \ | ||
| -n $((DSTACK_NODES_NUM * DSTACK_GPUS_PER_NODE)) -N ${DSTACK_GPUS_PER_NODE} \ | ||
| --mca btl_tcp_if_exclude lo,docker0 \ | ||
| --bind-to none \ | ||
| ./all_reduce_perf -b 8 -e 8G -f 2 -g 1 | ||
| # Notify nodes the job is done | ||
| ${MPIRUN} -n ${DSTACK_NODES_NUM} -N 1 sh -c "echo done > ${FIFO}" | ||
| else | ||
| mkfifo ${FIFO} | ||
| # Wait for a message from the first node | ||
| cat ${FIFO} | ||
| fi | ||
|
|
||
| resources: | ||
| gpu: nvidia:4:16GB | ||
| shm_size: 16GB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # NCCL Tests | ||
|
|
||
| This example shows how to run distributed [NCCL Tests :material-arrow-top-right-thin:{ .external }](https://github.com/NVIDIA/nccl-tests){:target="_blank"} with MPI using `dstack`. | ||
|
|
||
| ??? info "AWS EFA" | ||
| The used image is optimized for AWS [EFA :material-arrow-top-right-thin:{ .external }](https://aws.amazon.com/hpc/efa/){:target="_blank"} but works with regular TCP/IP network adapters as well. | ||
|
|
||
| ## Configuration | ||
|
|
||
| This configuration runs AllReduce test on 2 nodes with 4 GPUs each (8 processes total), but you can adjust both `nodes` and `resources.gpu` without modifying the script. | ||
|
|
||
| <div editor-title="examples/misc/nccl-tests/.dstack.yml"> | ||
|
|
||
| ```yaml | ||
| type: task | ||
| name: nccl-tests | ||
|
|
||
| image: un1def/aws-efa-test | ||
| nodes: 2 | ||
|
|
||
| env: | ||
| - NCCL_DEBUG=INFO | ||
|
|
||
| commands: | ||
| - | | ||
| # We use FIFO for inter-node communication | ||
| FIFO=/tmp/dstack_job | ||
| if [ ${DSTACK_NODE_RANK} -eq 0 ]; then | ||
| cd /root/nccl-tests/build | ||
| echo "${DSTACK_NODES_IPS}" > hostfile | ||
| MPIRUN='mpirun --allow-run-as-root --hostfile hostfile' | ||
| # Wait for other nodes | ||
| while true; do | ||
| if ${MPIRUN} -n ${DSTACK_NODES_NUM} -N 1 true >/dev/null 2>&1; then | ||
| break | ||
| fi | ||
| echo 'Waiting for nodes...' | ||
| sleep 5 | ||
| done | ||
| # Run NCCL Tests | ||
| ${MPIRUN} \ | ||
| -n $((DSTACK_NODES_NUM * DSTACK_GPUS_PER_NODE)) -N ${DSTACK_GPUS_PER_NODE} \ | ||
| --mca btl_tcp_if_exclude lo,docker0 \ | ||
| --bind-to none \ | ||
| ./all_reduce_perf -b 8 -e 8G -f 2 -g 1 | ||
| # Notify nodes the job is done | ||
| ${MPIRUN} -n ${DSTACK_NODES_NUM} -N 1 sh -c "echo done > ${FIFO}" | ||
| else | ||
| mkfifo ${FIFO} | ||
| # Wait for a message from the first node | ||
| cat ${FIFO} | ||
| fi | ||
|
|
||
| resources: | ||
| gpu: nvidia:4:16GB | ||
| shm_size: 16GB | ||
|
|
||
| ``` | ||
|
|
||
| </div> | ||
|
|
||
| ### Running a configuration | ||
|
|
||
| To run a configuration, use the [`dstack apply`](https://dstack.ai/docs/reference/cli/dstack/apply/) command. | ||
|
|
||
| <div class="termy"> | ||
|
|
||
| ```shell | ||
| $ dstack apply -f examples/misc/nccl-tests/.dstack.yml | ||
|
|
||
| # BACKEND REGION INSTANCE RESOURCES SPOT PRICE | ||
| 1 aws us-east-1 g4dn.12xlarge 48xCPU, 192GB, 4xT4 (16GB), 100.0GB (disk) no $3.912 | ||
| 2 aws us-west-2 g4dn.12xlarge 48xCPU, 192GB, 4xT4 (16GB), 100.0GB (disk) no $3.912 | ||
| 3 aws us-east-2 g4dn.12xlarge 48xCPU, 192GB, 4xT4 (16GB), 100.0GB (disk) no $3.912 | ||
|
|
||
| Submit the run nccl-tests? [y/n]: y | ||
| ``` | ||
|
|
||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@un-def Shouldn't we use
DSTACK_GPUS_NUMinstead of(DSTACK_NODES_NUM * DSTACK_GPUS_PER_NODE)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll update the docs in a separate PR. Thanks!