-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathlaunch.sh
More file actions
executable file
·41 lines (34 loc) · 881 Bytes
/
launch.sh
File metadata and controls
executable file
·41 lines (34 loc) · 881 Bytes
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
#!/bin/bash
offload_found=false
zero1_found=false
args=()
for arg in "$@"; do
if [ "$arg" = "offload" ]; then
offload_found=true
elif [ "$arg" = "zero1" ]; then
zero1_found=true
else
args+=("$arg")
fi
done
if [ "$offload_found" = true ]; then
config="accelerate_configs/deepspeed_zero3_cpu_offloading.yaml"
elif [ "$zero1_found" = true ]; then
config="accelerate_configs/deepspeed_zero1.yaml"
else
config="accelerate_configs/deepspeed_zero3.yaml"
fi
nproc=${args[0]}
arg2=${args[1]:-"default"}
prefix="cfgs/run_cfg/"
if [[ "$arg2" == $prefix* ]]; then
arg2="${arg2#$prefix}"
fi
extra_args=("${args[@]:2}")
# generate random port
RND_PORT=$(($RANDOM % 1000 + 12000))
echo $RND_PORT
accelerate launch --num_processes "$nproc" \
--main_process_port "$RND_PORT" \
--config_file "$config" \
train.py run_cfg@_global_="$arg2" "${extra_args[@]}"