-
Notifications
You must be signed in to change notification settings - Fork 48
/
run_dist.sh
executable file
·52 lines (45 loc) · 1.36 KB
/
run_dist.sh
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
49
50
51
#!/bin/bash
set -e
#set -x
. ./config_dist.sh
WORKER_STRING=$(echo ${WORKER_HOSTS[*]} | sed 's/ /,/g')
PS_STRING=$(echo ${PS_HOSTS[*]} | sed 's/ /,/g')
EXPERIMENT_ID=$(date)
EXPERIMENT_ID=${EXPERIMENT_ID// /_}
EXPERIMENT_ID=${EXPERIMENT_ID//:/-}
PS_NUM=${#PS_HOSTS[@]}
WORKER_NUM=${#WORKER_HOSTS[@]}
DEVICE_NUM=${#WORKER_DEVICES[@]}
DATA_NUM=${#DATA_DIR[@]}
if [ ${WORKER_NUM} -ne ${DEVICE_NUM} ]
then
echo "The number of workers (${WORKER_NUM}) does not match the number of devices (${DEVICE_NUM})"
exit
fi
if [ ${WORKER_NUM} -ne ${DATA_NUM} ]
then
echo "The number of workers (${WORKER_NUM}) does not match the number of data paths (${DATA_NUM})"
exit
fi
echo "${PS_NUM} ps hosts: ${PS_STRING}"
echo "${WORKER_NUM} worker hosts: ${WORKER_STRING}"
# start workers
task_id=0
for HOST in ${WORKER_HOSTS[*]}; do
worker=$(echo ${HOST} |cut -d':' -f1)
ssh ${worker} "hostname; \
cd ${WORKSPACE}; \
pwd; \
${WORKER_SCRIPT} ${PS_STRING} ${WORKER_STRING} worker ${task_id} ${WORKER_DEVICES[$task_id]} ${DATA_DIR[$task_id]} ${EXPERIMENT_ID}"
task_id=`expr $task_id + 1`
done
# start ps
task_id=0
for HOST in ${PS_HOSTS[*]}; do
ps=$(echo ${HOST} |cut -d':' -f1)
ssh ${ps} "hostname; \
cd ${WORKSPACE}; \
pwd; \
${PS_SCRIPT} ${PS_STRING} ${WORKER_STRING} ps ${task_id} ${EXPERIMENT_ID}"
task_id=`expr $task_id + 1`
done