run_det.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. # 提供可稳定复现性能的脚本,默认在标准docker环境内py37执行: paddlepaddle/paddle:latest-gpu-cuda10.1-cudnn7 paddle=2.1.2 py=37
  3. # 执行目录: ./PaddleOCR
  4. # 1 安装该模型需要的依赖 (如需开启优化策略请注明)
  5. log_path=${LOG_PATH_INDEX_DIR:-$(pwd)}
  6. python -m pip install -r requirements.txt
  7. # 2 拷贝该模型需要数据、预训练模型
  8. wget -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar && cd train_data && tar xf icdar2015.tar && cd ../
  9. wget -P ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_vd_pretrained.pdparams
  10. wget -P ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet18_vd_pretrained.pdparams
  11. wget -P ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_vd_ssld_pretrained.pdparams
  12. # 3 批量运行(如不方便批量,1,2需放到单个模型中)
  13. model_mode_list=(det_res18_db_v2.0 det_r50_vd_east det_r50_vd_pse)
  14. fp_item_list=(fp32)
  15. for model_mode in ${model_mode_list[@]}; do
  16. for fp_item in ${fp_item_list[@]}; do
  17. if [ ${model_mode} == "det_r50_vd_east" ]; then
  18. bs_list=(16)
  19. else
  20. bs_list=(8 16)
  21. fi
  22. for bs_item in ${bs_list[@]}; do
  23. echo "index is speed, 1gpus, begin, ${model_name}"
  24. run_mode=sp
  25. log_name=ocr_${model_mode}_bs${bs_item}_${fp_item}_${run_mode}
  26. CUDA_VISIBLE_DEVICES=0 bash benchmark/run_benchmark_det.sh ${run_mode} ${bs_item} ${fp_item} 1 ${model_mode} | tee ${log_path}/${log_name}_speed_1gpus 2>&1 # (5min)
  27. sleep 60
  28. echo "index is speed, 8gpus, run_mode is multi_process, begin, ${model_name}"
  29. run_mode=mp
  30. log_name=ocr_${model_mode}_bs${bs_item}_${fp_item}_${run_mode}
  31. CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash benchmark/run_benchmark_det.sh ${run_mode} ${bs_item} ${fp_item} 2 ${model_mode} | tee ${log_path}/${log_name}_speed_8gpus8p 2>&1
  32. sleep 60
  33. done
  34. done
  35. done