-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaseline.sh
More file actions
49 lines (41 loc) · 1.4 KB
/
Copy pathbaseline.sh
File metadata and controls
49 lines (41 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash -l
#PBS -l select=<number-of-nodes>:system=<your-system>
#PBS -l place=scatter
#PBS -l walltime=1:00:00
#PBS -l filesystems=home:<your-file-system-of-choice>
#PBS -q <your-queue-of-choice>
#PBS -A <your-allocation>
# MPI example w/ <PPN> MPI ranks per node spread evenly across cores
NNODES=`wc -l < $PBS_NODEFILE`
NRANKS_PER_NODE=<PPN>
echo "=================================="
echo "Starting MPI job at $(date)"
echo "=================================="
echo ""
source <your-conda-directory>/bin/activate
cd <your-BatteryML-directory>
cat $PBS_NODEFILE > <your-BatteryML-directory>/nodelist
MASTER_ADDR=$(head -n 1 <your-BatteryML-directory>/nodelist)
MASTER_PORT=29500
HOSTLIST=$(cat <your-BatteryML-directory>/nodelist | uniq)
NTOTRANKS=$(( NNODES * NRANKS_PER_NODE ))
echo "NUM_OF_NODES= ${NNODES} TOTAL_NUM_RANKS= ${NTOTRANKS} RANKS_PER_NODE=${NRANKS_PER_NODE}"
RANK=0
for node in $HOSTLIST; do
echo "Launching on node $node with rank $RANK"
ssh $node "source <your-conda-directory>/bin/activate && \
cd <your-BatteryML-directory> && \
torchrun \
--nnodes=$NNODES \
--nproc_per_node=$NRANKS_PER_NODE \
--node_rank=$RANK \
--master_addr=$MASTER_ADDR \
--master_port=$MASTER_PORT \
/home/atang/BatteryML/baseline.py" &
RANK=$((RANK+1))
done
wait
echo ""
echo "====================================="
echo "MPI job finished at $(date)"
echo "====================================="