Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
a7b81193
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
1 年多 前同步成功
通知
1535
Star
32963
Fork
6643
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
108
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
108
Issue
108
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a7b81193
编写于
1月 25, 2022
作者:
L
LDOUBLEV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add benchmark_train.sh
上级
892c0e67
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
108 addition
and
30 deletion
+108
-30
test_tipc/benchmark_train.sh
test_tipc/benchmark_train.sh
+108
-30
未找到文件。
test_tipc/benchmark_train.sh
浏览文件 @
a7b81193
...
...
@@ -2,9 +2,8 @@
source
test_tipc/common_func.sh
# run benchmark sh
# params: batch
# Usage:
# bash run_benchmark_train.sh config.txt
benchmark_train batch_size=2 precision=3 profile_option=4
# bash run_benchmark_train.sh config.txt
params
function
func_parser_params
(){
strs
=
$1
...
...
@@ -43,41 +42,120 @@ function func_sed_params(){
function
set_gpu_id
(){
string
=
$1
_str
=
${
string
:1:6
}
IFS
=
"C"
arr
=(
${
_str
}
)
M
=
${
arr
[0]
}
P
=
${
arr
[1]
}
gpu_num
=
`
expr
$P
- 1
`
gn
=
`
expr
$P
- 1
`
gpu_num
=
`
expr
$gn
/
$M
`
seq
=
`
seq
-s
","
0
$gpu_num
`
echo
$seq
}
FILENAME
=
$1
# MODE be one of ['benchmark_train']
MODE
=
$2
#
# line_bs=9
# line_presion=6
# line_profile=13
# if [ $# -eq 4 ] ; then
# echo "Usage: bash run_benchmark_train.sh config.txt benchmark_train batch_size=2 precision=fp16"
# elif [ $# -eq 5 ] ; then
# echo "Usage: bash run_benchmark_train.sh config.txt benchmark_train batch_size=2 precision=fp16 profile_option=None"
# profile_options=$(func_parser_params "$5")
# else
# echo "None"
# fi
# l=`grep -n "benchmark_params" ${FILENAME} | cut -d ":" -f 1`
# echo $l
function
get_repo_name
(){
IFS
=
";"
cur_dir
=
$(
pwd
)
IFS
=
"/"
arr
=(
${
cur_dir
}
)
echo
${
arr
[-1]
}
}
# sed -i '[第n行]s/[正则通配符]/[替换内容]/' [指定文件]
# FILENAME=$1
# # MODE be one of ['benchmark_train']
# MODE=$2
# params=$3
IFS
=
"
\n
"
FILENAME
=
"test_tipc/configs/det_mv3_db_v2.0/train_benchmark.txt"
MODE
=
"benchmark_train"
params
=
"dynamic_bs8_fp32_SingleP_DP_N1C4"
# parser params from input: modeltype_bs${bs_item}_${fp_item}_${run_process_type}_${run_mode}_${device_num}
IFS
=
"_"
params_list
=(
${
params
}
)
model_type
=
${
params_list
[0]
}
batch_size
=
${
params_list
[1]
}
batch_size
=
`
echo
${
batch_size
}
|
tr
-cd
"[0-9]"
`
precision
=
${
params_list
[2]
}
run_process_type
=
${
params_list
[3]
}
run_mode
=
${
params_list
[4]
}
device_num
=
${
params_list
[5]
}
device_num_copy
=
$device_num
IFS
=
";"
echo
$precision
# sed batchsize and precision
func_sed_params
"
$FILENAME
"
"6"
"
$precision
"
func_sed_params
"
$FILENAME
"
"9"
"
$batch_size
"
# parser params from train_benchmark.txt
dataline
=
`
cat
$FILENAME
`
# parser params
IFS
=
$'
\n
'
lines
=(
${
dataline
}
)
model_name
=
$(
func_parser_value
"
${
lines
[1]
}
"
)
# 获取benchmark_params所在的行数
line_num
=
`
grep
-n
"benchmark_params"
$FILENAME
|
cut
-d
":"
-f
1
`
echo
$line_num
# debug
echo
${
lines
[
$line_num
]
}
# debug
# for train log parser
line_num
=
`
expr
$line_num
+ 3
`
ips_unit_value
=
$(
func_parser_value
"
${
lines
[line_num]
}
"
)
line_num
=
`
expr
$line_num
+ 1
`
skip_steps_value
=
$(
func_parser_value
"
${
lines
[line_num]
}
"
)
echo
$skip_steps_value
"haha"
line_num
=
`
expr
$line_num
+ 1
`
keyword_value
=
$(
func_parser_value
"
${
lines
[line_num]
}
"
)
line_num
=
`
expr
$line_num
+ 1
`
convergence_key_value
=
$(
func_parser_value
"
${
lines
[line_num]
}
"
)
line_num
=
`
expr
$line_num
+ 1
`
flags_value
=
$(
func_parser_value
"
${
lines
[line_num]
}
"
)
# echo "device_num: $device_num"
# gpu_id=$(set_gpu_id "N4C32")
# echo "gpuid: $gpu_id"
gpu_id
=
$(
set_gpu_id
$device_num
)
echo
"gpu_id:
$gpu_id
"
repo_name
=
$(
get_repo_name
)
echo
"repo_name:
${
repo_name
}
"
# train_log_file=${run_log_path}/${model_repo}_${model_name}_${device_num}_log
# profiling_log_file=${profiling_log_path}/${model_repo}_${model_name}_${device_num}_profiling
SAVE_LOG
=
"benchmark_log"
if
[
${#
gpu_id
}
-le
1
]
;
then
echo
"single_gpu train"
log_path
=
"
$SAVE_LOG
/profiling_log"
mkdir
-p
$log_path
log_name
=
"
${
repo_name
}
_
${
model_name
}
_bs
${
batch_size
}
_
${
precision
}
_
${
run_process_type
}
_
${
run_mode
}
_
${
device_num
}
_profiling"
echo
$log_name
func_sed_params
"
$FILENAME
"
"4"
"0"
# sed used gpu_id
cmd
=
"bash test_tipc/test_train_inference_python.sh benchmark_train >
${
log_path
}
/
${
log_name
}
2>&1 "
echo
$cmd
# without profile
log_path
=
"
$SAVE_LOG
/train_log"
mkdir
-p
$log_path
log_name
=
"
${
repo_name
}
_
${
model_name
}
_bs
${
batch_size
}
_
${
precision
}
_
${
run_process_type
}
_
${
run_mode
}
_
${
device_num
}
_log"
func_sed_params
"
$FILENAME
"
"13"
"null"
# sed used gpu_id
cmd
=
"bash test_tipc/test_train_inference_python.sh benchmark_train >
${
log_path
}
/
${
log_name
}
2>&1 "
echo
$cmd
else
echo
"multi_gpu training"
log_path
=
"
$SAVE_LOG
/train_log"
mkdir
-p
$log_path
log_name
=
"
${
repo_name
}
_
${
model_name
}
_bs
${
batch_size
}
_
${
precision
}
_
${
run_process_type
}
_
${
run_mode
}
_
${
device_num
}
_log"
func_sed_params
"
$FILENAME
"
"4"
"
$gpu_id
"
# sed used gpu_id
func_sed_params
"
$FILENAME
"
"13"
"
$null
"
# sed --profile_option as null
cmd
=
"bash test_tipc/test_train_inference_python.sh benchmark_train >
${
log_path
}
/
${
log_name
}
2>&1 "
echo
$cmd
fi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录