Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
f906f849
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1528
Star
32962
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f906f849
编写于
9月 28, 2021
作者:
L
LDOUBLEV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opt benchmark
上级
d89c6b43
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
119 addition
and
8 deletion
+119
-8
benchmark/run_det.sh
benchmark/run_det.sh
+8
-8
ppocr/utils/profiler.py
ppocr/utils/profiler.py
+110
-0
tools/program.py
tools/program.py
+1
-0
未找到文件。
benchmark/run_det.sh
浏览文件 @
f906f849
# 提供可稳定复现性能的脚本,默认在标准docker环境内py37执行: paddlepaddle/paddle:latest-gpu-cuda10.1-cudnn7 paddle=2.1.2 py=37
# 执行目录:需说明
cd
PaddleOCR
#
cd PaddleOCR
# 1 安装该模型需要的依赖 (如需开启优化策略请注明)
python3.7
-m
pip
install
-r
requirements.txt
# 2 拷贝该模型需要数据、预训练模型
wget
-p
./tain_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar
&&
cd
train_data
&&
tar
xf icdar2015.tar
&&
cd
../
wget
-p
./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_vd_pretrained.pdparams
#
wget -p ./tain_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar && cd train_data && tar xf icdar2015.tar && cd ../
#
wget -p ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ResNet50_vd_pretrained.pdparams
# 3 批量运行(如不方便批量,1,2需放到单个模型中)
model_mode_list
=(
det_mv3_db det_r50_vd_east
)
fp_item_list
=(
fp32
)
bs_list
=(
256 12
8
)
bs_list
=(
4
8
)
for
model_mode
in
${
model_mode_list
[@]
}
;
do
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 bash benchmark/run_benchmark
.sh
${
run_mode
}
${
bs_item
}
${
fp_item
}
10
${
model_mode
}
# (5min)
CUDA_VISIBLE_DEVICES
=
3 bash benchmark/run_benchmark_det
.sh
${
run_mode
}
${
bs_item
}
${
fp_item
}
10
${
model_mode
}
# (5min)
sleep
60
echo
"index is speed, 8gpus, run_mode is multi_process, begin,
${
model_name
}
"
run_mode
=
mp
CUDA_VISIBLE_DEVICES
=
0,1,2,3,4,5,6,7 bash benchmark/run_benchmark.sh
${
run_mode
}
${
bs_item
}
${
fp_item
}
10
${
model_mode
}
sleep
60
#
run_mode=mp
#
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} 10 ${model_mode}
#
sleep 60
done
done
done
...
...
ppocr/utils/profiler.py
0 → 100644
浏览文件 @
f906f849
# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
sys
import
paddle
# A global variable to record the number of calling times for profiler
# functions. It is used to specify the tracing range of training steps.
_profiler_step_id
=
0
# A global variable to avoid parsing from string every time.
_profiler_options
=
None
class
ProfilerOptions
(
object
):
'''
Use a string to initialize a ProfilerOptions.
The string should be in the format: "key1=value1;key2=value;key3=value3".
For example:
"profile_path=model.profile"
"batch_range=[50, 60]; profile_path=model.profile"
"batch_range=[50, 60]; tracer_option=OpDetail; profile_path=model.profile"
ProfilerOptions supports following key-value pair:
batch_range - a integer list, e.g. [100, 110].
state - a string, the optional values are 'CPU', 'GPU' or 'All'.
sorted_key - a string, the optional values are 'calls', 'total',
'max', 'min' or 'ave.
tracer_option - a string, the optional values are 'Default', 'OpDetail',
'AllOpDetail'.
profile_path - a string, the path to save the serialized profile data,
which can be used to generate a timeline.
exit_on_finished - a boolean.
'''
def
__init__
(
self
,
options_str
):
assert
isinstance
(
options_str
,
str
)
self
.
_options
=
{
'batch_range'
:
[
10
,
20
],
'state'
:
'All'
,
'sorted_key'
:
'total'
,
'tracer_option'
:
'Default'
,
'profile_path'
:
'/tmp/profile'
,
'exit_on_finished'
:
True
}
self
.
_parse_from_string
(
options_str
)
def
_parse_from_string
(
self
,
options_str
):
for
kv
in
options_str
.
replace
(
' '
,
''
).
split
(
';'
):
key
,
value
=
kv
.
split
(
'='
)
if
key
==
'batch_range'
:
value_list
=
value
.
replace
(
'['
,
''
).
replace
(
']'
,
''
).
split
(
','
)
value_list
=
list
(
map
(
int
,
value_list
))
if
len
(
value_list
)
>=
2
and
value_list
[
0
]
>=
0
and
value_list
[
1
]
>
value_list
[
0
]:
self
.
_options
[
key
]
=
value_list
elif
key
==
'exit_on_finished'
:
self
.
_options
[
key
]
=
value
.
lower
()
in
(
"yes"
,
"true"
,
"t"
,
"1"
)
elif
key
in
[
'state'
,
'sorted_key'
,
'tracer_option'
,
'profile_path'
]:
self
.
_options
[
key
]
=
value
def
__getitem__
(
self
,
name
):
if
self
.
_options
.
get
(
name
,
None
)
is
None
:
raise
ValueError
(
"ProfilerOptions does not have an option named %s."
%
name
)
return
self
.
_options
[
name
]
def
add_profiler_step
(
options_str
=
None
):
'''
Enable the operator-level timing using PaddlePaddle's profiler.
The profiler uses a independent variable to count the profiler steps.
One call of this function is treated as a profiler step.
Args:
profiler_options - a string to initialize the ProfilerOptions.
Default is None, and the profiler is disabled.
'''
if
options_str
is
None
:
return
global
_profiler_step_id
global
_profiler_options
if
_profiler_options
is
None
:
_profiler_options
=
ProfilerOptions
(
options_str
)
if
_profiler_step_id
==
_profiler_options
[
'batch_range'
][
0
]:
paddle
.
utils
.
profiler
.
start_profiler
(
_profiler_options
[
'state'
],
_profiler_options
[
'tracer_option'
])
elif
_profiler_step_id
==
_profiler_options
[
'batch_range'
][
1
]:
paddle
.
utils
.
profiler
.
stop_profiler
(
_profiler_options
[
'sorted_key'
],
_profiler_options
[
'profile_path'
])
if
_profiler_options
[
'exit_on_finished'
]:
sys
.
exit
(
0
)
_profiler_step_id
+=
1
tools/program.py
浏览文件 @
f906f849
...
...
@@ -31,6 +31,7 @@ from ppocr.utils.stats import TrainingStats
from
ppocr.utils.save_load
import
save_model
from
ppocr.utils.utility
import
print_dict
from
ppocr.utils.logging
import
get_logger
from
ppocr.utils
import
profiler
from
ppocr.data
import
build_dataloader
import
numpy
as
np
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录