未验证 提交 48305205 编写于 作者: T TeslaZhao 提交者: GitHub

Merge branch 'PaddlePaddle:develop' into develop

...@@ -43,7 +43,7 @@ The goal of Paddle Serving is to provide high-performance, flexible and easy-to- ...@@ -43,7 +43,7 @@ The goal of Paddle Serving is to provide high-performance, flexible and easy-to-
<h2 align="center">Tutorial and Papers</h2> <h2 align="center">Tutorial and Papers</h2>
- AIStudio tutorial(Chinese) : [Paddle Serving服务化部署框架](https://www.paddlepaddle.org.cn/tutorials/projectdetail/2538249) - AIStudio tutorial(Chinese) : [Paddle Serving服务化部署框架](https://www.paddlepaddle.org.cn/tutorials/projectdetail/3946013)
- AIStudio OCR practice(Chinese) : [基于PaddleServing的OCR服务化部署实战](https://aistudio.baidu.com/aistudio/projectdetail/3630726) - AIStudio OCR practice(Chinese) : [基于PaddleServing的OCR服务化部署实战](https://aistudio.baidu.com/aistudio/projectdetail/3630726)
- Video tutorial(Chinese) : [深度学习服务化部署-以互联网应用为例](https://aistudio.baidu.com/aistudio/course/introduce/19084) - Video tutorial(Chinese) : [深度学习服务化部署-以互联网应用为例](https://aistudio.baidu.com/aistudio/course/introduce/19084)
- Edge AI solution(Chinese) : [基于Paddle Serving&百度智能边缘BIE的边缘AI解决方案](https://mp.weixin.qq.com/s/j0EVlQXaZ7qmoz9Fv96Yrw) - Edge AI solution(Chinese) : [基于Paddle Serving&百度智能边缘BIE的边缘AI解决方案](https://mp.weixin.qq.com/s/j0EVlQXaZ7qmoz9Fv96Yrw)
......
...@@ -41,7 +41,7 @@ Paddle Serving依托深度学习框架PaddlePaddle旨在帮助深度学习开发 ...@@ -41,7 +41,7 @@ Paddle Serving依托深度学习框架PaddlePaddle旨在帮助深度学习开发
<h2 align="center">教程与论文</h2> <h2 align="center">教程与论文</h2>
- AIStudio 使用教程 : [Paddle Serving服务化部署框架](https://www.paddlepaddle.org.cn/tutorials/projectdetail/2538249) - AIStudio 使用教程 : [Paddle Serving服务化部署框架](https://www.paddlepaddle.org.cn/tutorials/projectdetail/3946013)
- AIStudio OCR实战 : [基于PaddleServing的OCR服务化部署实战](https://aistudio.baidu.com/aistudio/projectdetail/3630726) - AIStudio OCR实战 : [基于PaddleServing的OCR服务化部署实战](https://aistudio.baidu.com/aistudio/projectdetail/3630726)
- 视频教程 : [深度学习服务化部署-以互联网应用为例](https://aistudio.baidu.com/aistudio/course/introduce/19084) - 视频教程 : [深度学习服务化部署-以互联网应用为例](https://aistudio.baidu.com/aistudio/course/introduce/19084)
- 边缘AI 解决方案 : [基于Paddle Serving&百度智能边缘BIE的边缘AI解决方案](https://mp.weixin.qq.com/s/j0EVlQXaZ7qmoz9Fv96Yrw) - 边缘AI 解决方案 : [基于Paddle Serving&百度智能边缘BIE的边缘AI解决方案](https://mp.weixin.qq.com/s/j0EVlQXaZ7qmoz9Fv96Yrw)
......
...@@ -30,7 +30,7 @@ message( "WITH_GPU = ${WITH_GPU}") ...@@ -30,7 +30,7 @@ message( "WITH_GPU = ${WITH_GPU}")
# Paddle Version should be one of: # Paddle Version should be one of:
# latest: latest develop build # latest: latest develop build
# version number like 1.5.2 # version number like 1.5.2
SET(PADDLE_VERSION "2.3.0-rc0") SET(PADDLE_VERSION "2.3.0")
if (WITH_GPU) if (WITH_GPU)
message("CUDA: ${CUDA_VERSION}, CUDNN_MAJOR_VERSION: ${CUDNN_MAJOR_VERSION}") message("CUDA: ${CUDA_VERSION}, CUDNN_MAJOR_VERSION: ${CUDNN_MAJOR_VERSION}")
# cuda 11.0 is not supported, 11.2 would be added. # cuda 11.0 is not supported, 11.2 would be added.
......
...@@ -93,7 +93,9 @@ class LocalPredictor(object): ...@@ -93,7 +93,9 @@ class LocalPredictor(object):
use_ascend_cl=False, use_ascend_cl=False,
min_subgraph_size=3, min_subgraph_size=3,
dynamic_shape_info={}, dynamic_shape_info={},
use_calib=False): use_calib=False,
collect_shape_range_info="",
tuned_dynamic_shape_info=""):
""" """
Load model configs and create the paddle predictor by Paddle Inference API. Load model configs and create the paddle predictor by Paddle Inference API.
...@@ -160,12 +162,14 @@ class LocalPredictor(object): ...@@ -160,12 +162,14 @@ class LocalPredictor(object):
"use_trt:{}, use_lite:{}, use_xpu:{}, precision:{}, use_calib:{}, " "use_trt:{}, use_lite:{}, use_xpu:{}, precision:{}, use_calib:{}, "
"use_mkldnn:{}, mkldnn_cache_capacity:{}, mkldnn_op_list:{}, " "use_mkldnn:{}, mkldnn_cache_capacity:{}, mkldnn_op_list:{}, "
"mkldnn_bf16_op_list:{}, use_feed_fetch_ops:{}, " "mkldnn_bf16_op_list:{}, use_feed_fetch_ops:{}, "
"use_ascend_cl:{}, min_subgraph_size:{}, dynamic_shape_info:{}". "use_ascend_cl:{}, min_subgraph_size:{}, dynamic_shape_info:{},"
"collect_shape_range_info:{},tuned_dynamic_shape_info:{}".
format(model_path, use_gpu, gpu_id, use_profile, thread_num, format(model_path, use_gpu, gpu_id, use_profile, thread_num,
mem_optim, ir_optim, use_trt, use_lite, use_xpu, precision, mem_optim, ir_optim, use_trt, use_lite, use_xpu, precision,
use_calib, use_mkldnn, mkldnn_cache_capacity, mkldnn_op_list, use_calib, use_mkldnn, mkldnn_cache_capacity, mkldnn_op_list,
mkldnn_bf16_op_list, use_feed_fetch_ops, use_ascend_cl, mkldnn_bf16_op_list, use_feed_fetch_ops, use_ascend_cl,
min_subgraph_size, dynamic_shape_info)) min_subgraph_size, dynamic_shape_info,
collect_shape_range_info,tuned_dynamic_shape_info))
self.feed_names_ = [var.alias_name for var in model_conf.feed_var] self.feed_names_ = [var.alias_name for var in model_conf.feed_var]
self.fetch_names_ = [var.alias_name for var in model_conf.fetch_var] self.fetch_names_ = [var.alias_name for var in model_conf.fetch_var]
...@@ -213,6 +217,8 @@ class LocalPredictor(object): ...@@ -213,6 +217,8 @@ class LocalPredictor(object):
if mkldnn_op_list is not None: if mkldnn_op_list is not None:
config.set_mkldnn_op(mkldnn_op_list) config.set_mkldnn_op(mkldnn_op_list)
# set gpu # set gpu
if collect_shape_range_info != "":
config.collect_shape_range_info(collect_shape_range_info)
if not use_gpu: if not use_gpu:
config.disable_gpu() config.disable_gpu()
else: else:
...@@ -226,6 +232,9 @@ class LocalPredictor(object): ...@@ -226,6 +232,9 @@ class LocalPredictor(object):
use_static=False, use_static=False,
use_calib_mode=use_calib) use_calib_mode=use_calib)
if tuned_dynamic_shape_info != "":
config.enable_tuned_tensorrt_dynamic_shape(tuned_dynamic_shape_info, True)
@ErrorCatch @ErrorCatch
@ParamChecker @ParamChecker
def dynamic_shape_info_helper(dynamic_shape_info:lambda dynamic_shape_info: check_dynamic_shape_info(dynamic_shape_info)): def dynamic_shape_info_helper(dynamic_shape_info:lambda dynamic_shape_info: check_dynamic_shape_info(dynamic_shape_info)):
...@@ -235,7 +244,7 @@ class LocalPredictor(object): ...@@ -235,7 +244,7 @@ class LocalPredictor(object):
print("dynamic_shape_info configure error, it should contain [min_input_shape', 'max_input_shape', 'opt_input_shape' {}".format(resp.err_msg)) print("dynamic_shape_info configure error, it should contain [min_input_shape', 'max_input_shape', 'opt_input_shape' {}".format(resp.err_msg))
kill_stop_process_by_pid("kill", os.getpgid(os.getpid())) kill_stop_process_by_pid("kill", os.getpgid(os.getpid()))
if len(dynamic_shape_info): if len(dynamic_shape_info) and tuned_dynamic_shape_info == "":
config.set_trt_dynamic_shape_info( config.set_trt_dynamic_shape_info(
dynamic_shape_info['min_input_shape'], dynamic_shape_info['min_input_shape'],
dynamic_shape_info['max_input_shape'], dynamic_shape_info['max_input_shape'],
......
...@@ -53,7 +53,9 @@ class LocalServiceHandler(object): ...@@ -53,7 +53,9 @@ class LocalServiceHandler(object):
mkldnn_bf16_op_list=None, mkldnn_bf16_op_list=None,
min_subgraph_size=3, min_subgraph_size=3,
dynamic_shape_info={}, dynamic_shape_info={},
use_calib=False): use_calib=False,
collect_shape_range_info="",
tuned_dynamic_shape_info=""):
""" """
Initialization of localservicehandler Initialization of localservicehandler
...@@ -99,6 +101,8 @@ class LocalServiceHandler(object): ...@@ -99,6 +101,8 @@ class LocalServiceHandler(object):
self.min_subgraph_size = 3 self.min_subgraph_size = 3
self.dynamic_shape_info = {} self.dynamic_shape_info = {}
self._use_calib = False self._use_calib = False
self.collect_shape_range_info = ""
self.tuned_dynamic_shape_info = ""
if device_type == -1: if device_type == -1:
# device_type is not set, determined by `devices`, # device_type is not set, determined by `devices`,
...@@ -179,6 +183,8 @@ class LocalServiceHandler(object): ...@@ -179,6 +183,8 @@ class LocalServiceHandler(object):
self._mkldnn_op_list = mkldnn_op_list self._mkldnn_op_list = mkldnn_op_list
self._mkldnn_bf16_op_list = mkldnn_bf16_op_list self._mkldnn_bf16_op_list = mkldnn_bf16_op_list
self._use_calib = use_calib self._use_calib = use_calib
self.collect_shape_range_info = collect_shape_range_info
self.tuned_dynamic_shape_info = tuned_dynamic_shape_info
_LOGGER.info( _LOGGER.info(
"Models({}) will be launched by device {}. use_gpu:{}, " "Models({}) will be launched by device {}. use_gpu:{}, "
...@@ -187,14 +193,16 @@ class LocalServiceHandler(object): ...@@ -187,14 +193,16 @@ class LocalServiceHandler(object):
"client_type:{}, fetch_names:{}, precision:{}, use_calib:{}, " "client_type:{}, fetch_names:{}, precision:{}, use_calib:{}, "
"use_mkldnn:{}, mkldnn_cache_capacity:{}, mkldnn_op_list:{}, " "use_mkldnn:{}, mkldnn_cache_capacity:{}, mkldnn_op_list:{}, "
"mkldnn_bf16_op_list:{}, use_ascend_cl:{}, min_subgraph_size:{}," "mkldnn_bf16_op_list:{}, use_ascend_cl:{}, min_subgraph_size:{},"
"is_set_dynamic_shape_info:{}".format( "is_set_dynamic_shape_info:{},collect_shape_range_info:{},"
"tuned_dynamic_shape_info:{}".format(
model_config, self._device_name, self._use_gpu, self._use_trt, model_config, self._device_name, self._use_gpu, self._use_trt,
self._use_lite, self._use_xpu, device_type, self._devices, self. self._use_lite, self._use_xpu, device_type, self._devices, self.
_mem_optim, self._ir_optim, self._use_profile, self._thread_num, _mem_optim, self._ir_optim, self._use_profile, self._thread_num,
self._client_type, self._fetch_names, self._precision, self. self._client_type, self._fetch_names, self._precision, self.
_use_calib, self._use_mkldnn, self._mkldnn_cache_capacity, self. _use_calib, self._use_mkldnn, self._mkldnn_cache_capacity, self.
_mkldnn_op_list, self._mkldnn_bf16_op_list, self._use_ascend_cl, _mkldnn_op_list, self._mkldnn_bf16_op_list, self._use_ascend_cl,
self.min_subgraph_size, bool(len(self.dynamic_shape_info)))) self.min_subgraph_size, bool(len(self.dynamic_shape_info)),
self.collect_shape_range_info, self.tuned_dynamic_shape_info))
def get_fetch_list(self): def get_fetch_list(self):
return self._fetch_names return self._fetch_names
...@@ -254,7 +262,9 @@ class LocalServiceHandler(object): ...@@ -254,7 +262,9 @@ class LocalServiceHandler(object):
use_ascend_cl=self._use_ascend_cl, use_ascend_cl=self._use_ascend_cl,
min_subgraph_size=self.min_subgraph_size, min_subgraph_size=self.min_subgraph_size,
dynamic_shape_info=self.dynamic_shape_info, dynamic_shape_info=self.dynamic_shape_info,
use_calib=self._use_calib) use_calib=self._use_calib,
collect_shape_range_info=self.collect_shape_range_info,
tuned_dynamic_shape_info=self.tuned_dynamic_shape_info)
return self._local_predictor_client return self._local_predictor_client
def get_client_config(self): def get_client_config(self):
......
...@@ -121,6 +121,8 @@ class Op(object): ...@@ -121,6 +121,8 @@ class Op(object):
self._succ_close_op = False self._succ_close_op = False
self.dynamic_shape_info = {} self.dynamic_shape_info = {}
self.set_dynamic_shape_info() self.set_dynamic_shape_info()
self.collect_shape_range_info = ""
self.tuned_dynamic_shape_info = ""
def set_dynamic_shape_info(self): def set_dynamic_shape_info(self):
""" """
...@@ -235,6 +237,14 @@ class Op(object): ...@@ -235,6 +237,14 @@ class Op(object):
"mkldnn_bf16_op_list") "mkldnn_bf16_op_list")
self.min_subgraph_size = local_service_conf.get( self.min_subgraph_size = local_service_conf.get(
"min_subgraph_size") "min_subgraph_size")
self.collect_shape_range_info = local_service_conf.get(
"collect_shape_range_info")
self.tuned_dynamic_shape_info = local_service_conf.get(
"tuned_dynamic_shape_info")
if self.collect_shape_range_info is None:
self.collect_shape_range_info = ""
if self.tuned_dynamic_shape_info is None:
self.tuned_dynamic_shape_info = ""
if self.model_config is None: if self.model_config is None:
self.with_serving = False self.with_serving = False
...@@ -259,7 +269,9 @@ class Op(object): ...@@ -259,7 +269,9 @@ class Op(object):
mkldnn_bf16_op_list=self.mkldnn_bf16_op_list, mkldnn_bf16_op_list=self.mkldnn_bf16_op_list,
min_subgraph_size=self.min_subgraph_size, min_subgraph_size=self.min_subgraph_size,
dynamic_shape_info=self.dynamic_shape_info, dynamic_shape_info=self.dynamic_shape_info,
use_calib=self.use_calib) use_calib=self.use_calib,
collect_shape_range_info=self.collect_shape_range_info,
tuned_dynamic_shape_info=self.tuned_dynamic_shape_info)
service_handler.prepare_server() # get fetch_list service_handler.prepare_server() # get fetch_list
serivce_ports = service_handler.get_port_list() serivce_ports = service_handler.get_port_list()
self._server_endpoints = [ self._server_endpoints = [
...@@ -290,7 +302,9 @@ class Op(object): ...@@ -290,7 +302,9 @@ class Op(object):
mkldnn_bf16_op_list=self.mkldnn_bf16_op_list, mkldnn_bf16_op_list=self.mkldnn_bf16_op_list,
min_subgraph_size=self.min_subgraph_size, min_subgraph_size=self.min_subgraph_size,
dynamic_shape_info=self.dynamic_shape_info, dynamic_shape_info=self.dynamic_shape_info,
use_calib=self.use_calib) use_calib=self.use_calib,
collect_shape_range_info=self.collect_shape_range_info,
tuned_dynamic_shape_info=self.tuned_dynamic_shape_info)
if self._client_config is None: if self._client_config is None:
self._client_config = service_handler.get_client_config( self._client_config = service_handler.get_client_config(
) )
...@@ -1387,7 +1401,9 @@ class Op(object): ...@@ -1387,7 +1401,9 @@ class Op(object):
mkldnn_bf16_op_list=mkldnn_bf16_op_list, mkldnn_bf16_op_list=mkldnn_bf16_op_list,
min_subgraph_size=min_subgraph_size, min_subgraph_size=min_subgraph_size,
dynamic_shape_info=dynamic_shape_info, dynamic_shape_info=dynamic_shape_info,
use_calib=use_calib) use_calib=use_calib,
collect_shape_range_info=self.collect_shape_range_info,
tuned_dynamic_shape_info=self.tuned_dynamic_shape_info)
_LOGGER.info("Init cuda env in process {}".format( _LOGGER.info("Init cuda env in process {}".format(
concurrency_idx)) concurrency_idx))
......
...@@ -261,6 +261,8 @@ class PipelineServer(object): ...@@ -261,6 +261,8 @@ class PipelineServer(object):
"use_mkldnn": False, "use_mkldnn": False,
"mkldnn_cache_capacity": 0, "mkldnn_cache_capacity": 0,
"min_subgraph_size": 3, "min_subgraph_size": 3,
"collect_shape_range_info": "",
"tuned_dynamic_shape_info": "",
}, },
} }
for op in self._used_op: for op in self._used_op:
...@@ -422,6 +424,8 @@ class ServerYamlConfChecker(object): ...@@ -422,6 +424,8 @@ class ServerYamlConfChecker(object):
"use_mkldnn": False, "use_mkldnn": False,
"mkldnn_cache_capacity": 0, "mkldnn_cache_capacity": 0,
"min_subgraph_size": 3, "min_subgraph_size": 3,
"collect_shape_range_info": "",
"tuned_dynamic_shape_info": "",
} }
conf_type = { conf_type = {
"model_config": str, "model_config": str,
...@@ -438,6 +442,8 @@ class ServerYamlConfChecker(object): ...@@ -438,6 +442,8 @@ class ServerYamlConfChecker(object):
"mkldnn_op_list": list, "mkldnn_op_list": list,
"mkldnn_bf16_op_list": list, "mkldnn_bf16_op_list": list,
"min_subgraph_size": int, "min_subgraph_size": int,
"collect_shape_range_info": str,
"tuned_dynamic_shape_info": str,
} }
conf_qualification = {"thread_num": (">=", 1), } conf_qualification = {"thread_num": (">=", 1), }
ServerYamlConfChecker.check_conf(conf, default_conf, conf_type, ServerYamlConfChecker.check_conf(conf, default_conf, conf_type,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册