run_all.sh 2.6 KB
Newer Older
L
lzzyzlbb 已提交
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

#!usr/bin/env bash

function parse_yaml {
   local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
   sed -ne "s|^\($s\):|\1|" \
        -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
        -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p"  $1 |
   awk -F$fs '{
      indent = length($1)/2;
      vname[indent] = $2;
      if (indent == 0) {
         model_mode_list[model_num]=$2;
         printf("model_mode_list[%d]=%s\n",(model_num), $2);
         printf("model_num=%d\n", (model_num+1));
         model_num=(model_num+1);
      }
      for (i in vname) {if (i > indent) {delete vname[i]}}
      if (length($3) >= 0) {
         vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
         printf("%s%s=\"%s\"\n",vn, $2, $3);
      }
   }'
}
eval $(parse_yaml "benchmark/benchmark.yaml")


for model_mode in ${model_mode_list[@]}; do
      eval fp_item_list='$'"${model_mode}_fp_item"
      eval bs_list='$'"${model_mode}_bs_item"
      eval config='$'"${model_mode}_config"
      eval total_iters='$'"${model_mode}_total_iters"
      eval epochs='$'"${model_mode}_epochs"
      eval dataset_web='$'"${model_mode}_dataset_web"
W
wangna11BD 已提交
35
      eval dataset='$'"${model_mode}_dataset"
L
lzzyzlbb 已提交
36
      eval log_interval='$'"${model_mode}_log_interval"
W
wangna11BD 已提交
37 38 39 40 41 42
      if [ -n "$dataset" ]; then
          cp -r ${dataset} data/
      else
          wget ${dataset_web} -O data/${model_mode}.tar
          tar -vxf data/${model_mode}.tar -C data/
      fi
L
lzzyzlbb 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
      if [ -n "$total_iters" ]; then
          mode="total_iters"
          max_iter=$total_iters
      else
          mode="epochs"
          max_iter=$epochs
      fi
      echo ${epochs}
      for fp_item in ${fp_item_list[@]}; do
          for bs_item in ${bs_list[@]}
            do
            echo "index is speed, 1gpus, begin, ${model_name}"
            run_mode=sp
            CUDA_VISIBLE_DEVICES=0 benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} ${mode} ${max_iter} ${model_mode} ${config} ${log_interval}   #  (5min)
            sleep 60
            echo "index is speed, 8gpus, run_mode is multi_process, begin, ${model_name}"
            run_mode=mp
W
wangna11BD 已提交
60 61 62 63 64 65
            basicvsr_name=basicvsr
            if [ ${model_mode} = ${basicvsr_name} ]; then
                CUDA_VISIBLE_DEVICES=0,1,2,3 bash benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} ${mode} ${max_iter} ${model_mode} ${config} ${log_interval}
            else
                CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} ${mode} ${max_iter} ${model_mode} ${config} ${log_interval}
            fi
L
lzzyzlbb 已提交
66 67 68 69
            sleep 60
            done
      done
done