File size: 896 Bytes
c881b77 | 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 | #!/usr/bin/env bash
set -e
CONFIGS=()
while [[ $# -gt 0 ]]; do
case $1 in
--config)
shift
CONFIGS=($1)
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
shift
done
echo "CONFIGS: ${CONFIGS[@]}"
run_with_retry(){
local cmd=("$@")
local max=3
local attempt=1
while (( attempt <= max )); do
echo "Attempt $attempt/$max: ${cmd[*]}"
set +e
"${cmd[@]}"
status=$?
set -e
if [[ $status -eq 0 ]]; then
return 0
fi
((attempt++))
sleep 2
done
return 1
}
for config in "${CONFIGS[@]}"; do
echo "config: $config"
run_with_retry \
accelerate launch --multi_gpu --gpu_ids 0,1,2,3 --num_processes 4 main.py --config ./configs/$config.yaml -m train -p base
done |