From e916dc854724b47c215a6e734d5c3cfd034966ec Mon Sep 17 00:00:00 2001 From: inter Date: Sun, 21 Sep 2025 20:19:37 +0800 Subject: [PATCH] Add File --- tools/scripts/torch_test.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tools/scripts/torch_test.sh diff --git a/tools/scripts/torch_test.sh b/tools/scripts/torch_test.sh new file mode 100644 index 0000000..8853a95 --- /dev/null +++ b/tools/scripts/torch_test.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -x +NGPUS=$1 +PY_ARGS=${@:2} + +while true +do + PORT=$(( ((RANDOM<<15)|RANDOM) % 49152 + 10000 )) + status="$(nc -z 127.0.0.1 $PORT < /dev/null &>/dev/null; echo $?)" + if [ "${status}" != "0" ]; then + break; + fi +done +echo $PORT + +torchrun --nproc_per_node=${NGPUS} --rdzv_endpoint=localhost:${PORT} test.py --launcher pytorch ${PY_ARGS} +