forked from SMILELab-FL/FedPETuning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfed_run.sh
79 lines (70 loc) · 1.62 KB
/
fed_run.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# shellcheck disable=SC2068
# 读取参数
idx=0
for i in $@
do
args[${idx}]=$i
let "idx=${idx}+1"
done
# 分离参数
run_dirs=${args[0]}
task_name=${args[1]}
fl_algorithm=${args[2]}
port=${args[3]}
# 读取 GPU 参数
idx=0
for(( i=4;i<${#args[@]};i++ ))
do
device[${idx}]=${args[i]}
let "idx=${idx}+1"
done
world_size=${#device[@]}
echo "world_size is ${world_size}"
if [ ${task_name} == "qnli" ];
then
max_seq=256
data_file=fedglue
elif [ ${task_name} == "conll" ];
then
max_seq=32
data_file=fedner
else
max_seq=128
data_file=fedglue
fi
echo "${task_name}'s max_seq is ${max_seq}"
#sleep 7h
CUDA_VISIBLE_DEVICES=${device[0]} python main.py \
--model_name_or_path ${run_dirs}/pretrain/nlp/roberta-base/ \
--output_dir ${run_dirs}/output/${data_file} \
--rank 0 \
--task_name ${task_name} \
--fl_algorithm ${fl_algorithm} \
--raw_dataset_path ${run_dirs}/data/${data_file} \
--partition_dataset_path ${run_dirs}/data/${data_file} \
--max_seq_length ${max_seq} \
--world_size ${world_size} \
--port ${port} \
--test_rounds True &
#sleep 2s
for(( i=1;i<${world_size};i++))
do
{
echo "client ${i} started"
CUDA_VISIBLE_DEVICES=${device[i]} python main.py \
--model_name_or_path ${run_dirs}/pretrain/nlp/roberta-base/ \
--output_dir ${run_dirs}/output/${data_file} \
--rank ${i} \
--task_name ${task_name} \
--fl_algorithm ${fl_algorithm} \
--raw_dataset_path ${run_dirs}/data/${data_file} \
--partition_dataset_path ${run_dirs}/data/${data_file} \
--max_seq_length ${max_seq} \
--world_size ${world_size} \
--port ${port} \
--test_rounds True &
# sleep 2s
}
done
wait