From fbdf80dc1355593f517b7ffd93db480caa6a79f8 Mon Sep 17 00:00:00 2001 From: dyning Date: Tue, 14 Jul 2020 14:13:13 +0800 Subject: [PATCH] add parameter enable_mkldnn --- doc/doc_ch/benchmark.md | 12 ++++++++++-- tools/infer/utility.py | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/doc/doc_ch/benchmark.md b/doc/doc_ch/benchmark.md index ade7c548..3d8d3da9 100644 --- a/doc/doc_ch/benchmark.md +++ b/doc/doc_ch/benchmark.md @@ -17,5 +17,13 @@ 说明: - 评估耗时阶段为图像输入到结果输出的完整阶段,包括了图像的预处理和后处理。 -- `Intel至强6148`为服务器端CPU型号,测试中使用Intel MKL-DNN 加速CPU预测速度,需要更新到飞桨latest版本。 -- `骁龙855`为移动端处理平台型号。 +- `Intel至强6148`为服务器端CPU型号,测试中使用Intel MKL-DNN 加速CPU预测速度,使用该操作需要: + - 更新到飞桨latest版本:https://www.paddlepaddle.org.cn/documentation/docs/zh/install/Tables.html#whl-dev ,请根据自己环境的CUDA版本和Python版本选择相应的mkl版wheel包,如,CUDA10、Python3.7环境,应操作: + ```shell + # 获取安装包 + wget https://paddle-wheel.bj.bcebos.com/0.0.0-gpu-cuda10-cudnn7-mkl/paddlepaddle_gpu-0.0.0-cp37-cp37m-linux_x86_64.whl + # 安装 + pip3.7 install paddlepaddle_gpu-0.0.0-cp37-cp37m-linux_x86_64.whl + ``` + - 预测时使用参数打开加速开关: `--enable_mkldnn True` +- `骁龙855`为移动端处理平台型号。 \ No newline at end of file diff --git a/tools/infer/utility.py b/tools/infer/utility.py index 0cf66d4c..bab211a8 100755 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -64,6 +64,7 @@ def parse_args(): type=str, default="./ppocr/utils/ppocr_keys_v1.txt") parser.add_argument("--use_space_char", type=bool, default=True) + parser.add_argument("--enable_mkldnn", type=bool, default=False) return parser.parse_args() @@ -91,8 +92,10 @@ def create_predictor(args, mode): config.enable_use_gpu(args.gpu_mem, 0) else: config.disable_gpu() - # config.enable_mkldnn() - config.set_cpu_math_library_num_threads(4) + config.set_cpu_math_library_num_threads(6) + if args.enable_mkldnn: + config.enable_mkldnn() + #config.enable_memory_optim() config.disable_glog_info() -- GitLab