Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
ae859b7d
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
ae859b7d
编写于
1月 25, 2022
作者:
T
Thomas Young
提交者:
GitHub
1月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into fix_async_while
上级
71f6b56c
b8922d6b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
75 addition
and
19 deletion
+75
-19
cmake/paddlepaddle.cmake
cmake/paddlepaddle.cmake
+1
-1
python/paddle_serving_app/local_predict.py
python/paddle_serving_app/local_predict.py
+39
-12
python/pipeline/channel.py
python/pipeline/channel.py
+3
-1
python/pipeline/error_catch.py
python/pipeline/error_catch.py
+12
-0
python/pipeline/operator.py
python/pipeline/operator.py
+20
-5
未找到文件。
cmake/paddlepaddle.cmake
浏览文件 @
ae859b7d
...
...
@@ -30,7 +30,7 @@ message( "WITH_GPU = ${WITH_GPU}")
# Paddle Version should be one of:
# latest: latest develop build
# version number like 1.5.2
SET
(
PADDLE_VERSION
"2.2.
0
"
)
SET
(
PADDLE_VERSION
"2.2.
2
"
)
if
(
WITH_GPU
)
message
(
"CUDA:
${
CUDA_VERSION
}
, CUDNN_MAJOR_VERSION:
${
CUDNN_MAJOR_VERSION
}
"
)
# cuda 11.0 is not supported, 11.2 would be added.
...
...
python/paddle_serving_app/local_predict.py
浏览文件 @
ae859b7d
...
...
@@ -23,10 +23,13 @@ from .proto import general_model_config_pb2 as m_config
import
paddle.inference
as
paddle_infer
import
logging
import
glob
from
paddle_serving_server.pipeline.error_catch
import
ErrorCatch
,
CustomException
,
CustomExceptionCode
,
ParamChecker
,
ParamVerify
check_dynamic_shape_info
=
ParamVerify
.
check_dynamic_shape_info
logging
.
basicConfig
(
format
=
"%(asctime)s - %(levelname)s - %(message)s"
)
logger
=
logging
.
getLogger
(
"LocalPredictor"
)
logger
.
setLevel
(
logging
.
INFO
)
from
paddle_serving_server.util
import
kill_stop_process_by_pid
precision_map
=
{
'int8'
:
paddle_infer
.
PrecisionType
.
Int8
,
...
...
@@ -157,12 +160,12 @@ class LocalPredictor(object):
"use_trt:{}, use_lite:{}, use_xpu:{}, precision:{}, use_calib:{}, "
"use_mkldnn:{}, mkldnn_cache_capacity:{}, mkldnn_op_list:{}, "
"mkldnn_bf16_op_list:{}, use_feed_fetch_ops:{}, "
"use_ascend_cl:{}, min_subgraph_size:{}, dynamic_shape_info:{}"
.
format
(
model_path
,
use_gpu
,
gpu_id
,
use_profile
,
thread_num
,
mem_opti
m
,
ir_optim
,
use_trt
,
use_lite
,
use_xpu
,
precision
,
use_calib
,
use_mkldnn
,
mkldnn_cache_capacity
,
mkldnn_op_list
,
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:{}"
.
format
(
model_path
,
use_gpu
,
gpu_id
,
use_profile
,
thread_nu
m
,
mem_optim
,
ir_optim
,
use_trt
,
use_lite
,
use_xpu
,
precision
,
use_calib
,
use_mkldnn
,
mkldnn_cache_capacity
,
mkldnn_op_list
,
mkldnn_bf16_op_list
,
use_feed_fetch_ops
,
use_ascend_cl
,
min_subgraph_size
,
dynamic_shape_info
))
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
]
...
...
@@ -223,11 +226,20 @@ class LocalPredictor(object):
use_static
=
False
,
use_calib_mode
=
use_calib
)
@
ErrorCatch
@
ParamChecker
def
dynamic_shape_info_helper
(
dynamic_shape_info
:
lambda
dynamic_shape_info
:
check_dynamic_shape_info
(
dynamic_shape_info
)):
pass
_
,
resp
=
dynamic_shape_info_helper
(
dynamic_shape_info
)
if
resp
.
err_no
!=
CustomExceptionCode
.
OK
.
value
:
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
()))
if
len
(
dynamic_shape_info
):
config
.
set_trt_dynamic_shape_info
(
dynamic_shape_info
[
'min_input_shape'
],
dynamic_shape_info
[
'max_input_shape'
],
dynamic_shape_info
[
'opt_input_shape'
])
config
.
set_trt_dynamic_shape_info
(
dynamic_shape_info
[
'min_input_shape'
],
dynamic_shape_info
[
'max_input_shape'
],
dynamic_shape_info
[
'opt_input_shape'
])
# set lite
if
use_lite
:
config
.
enable_lite_engine
(
...
...
@@ -269,7 +281,18 @@ class LocalPredictor(object):
if
mkldnn_bf16_op_list
is
not
None
:
config
.
set_bfloat16_op
(
mkldnn_bf16_op_list
)
self
.
predictor
=
paddle_infer
.
create_predictor
(
config
)
@
ErrorCatch
def
create_predictor_check
(
config
):
predictor
=
paddle_infer
.
create_predictor
(
config
)
return
predictor
predictor
,
resp
=
create_predictor_check
(
config
)
if
resp
.
err_no
!=
CustomExceptionCode
.
OK
.
value
:
logger
.
critical
(
"failed to create predictor: {}"
.
format
(
resp
.
err_msg
),
exc_info
=
False
)
print
(
"failed to create predictor: {}"
.
format
(
resp
.
err_msg
))
kill_stop_process_by_pid
(
"kill"
,
os
.
getpgid
(
os
.
getpid
()))
self
.
predictor
=
predictor
def
predict
(
self
,
feed
=
None
,
fetch
=
None
,
batch
=
False
,
log_id
=
0
):
"""
...
...
@@ -315,7 +338,8 @@ class LocalPredictor(object):
# Assemble the input data of paddle predictor, and filter invalid inputs.
input_names
=
self
.
predictor
.
get_input_names
()
for
name
in
input_names
:
if
isinstance
(
feed
[
name
],
list
):
if
isinstance
(
feed
[
name
],
list
)
and
not
isinstance
(
feed
[
name
][
0
],
str
):
feed
[
name
]
=
np
.
array
(
feed
[
name
]).
reshape
(
self
.
feed_shapes_
[
name
])
if
self
.
feed_types_
[
name
]
==
0
:
...
...
@@ -342,6 +366,9 @@ class LocalPredictor(object):
feed
[
name
]
=
feed
[
name
].
astype
(
"complex64"
)
elif
self
.
feed_types_
[
name
]
==
11
:
feed
[
name
]
=
feed
[
name
].
astype
(
"complex128"
)
elif
isinstance
(
feed
[
name
],
list
)
and
isinstance
(
feed
[
name
][
0
],
str
):
pass
else
:
raise
ValueError
(
"local predictor receives wrong data type"
)
...
...
python/pipeline/channel.py
浏览文件 @
ae859b7d
...
...
@@ -34,6 +34,7 @@ from .error_catch import CustomExceptionCode as ChannelDataErrcode
_LOGGER
=
logging
.
getLogger
(
__name__
)
class
ChannelDataType
(
enum
.
Enum
):
"""
Channel data type
...
...
@@ -167,7 +168,8 @@ class ChannelData(object):
elif
isinstance
(
npdata
,
dict
):
# batch_size = 1
for
_
,
value
in
npdata
.
items
():
if
not
isinstance
(
value
,
np
.
ndarray
):
if
not
isinstance
(
value
,
np
.
ndarray
)
and
not
(
isinstance
(
value
,
list
)
and
isinstance
(
value
[
0
],
str
)):
error_code
=
ChannelDataErrcode
.
TYPE_ERROR
.
value
error_info
=
"Failed to check data: the value "
\
"of data must be np.ndarray, but get {}."
.
format
(
...
...
python/pipeline/error_catch.py
浏览文件 @
ae859b7d
...
...
@@ -227,5 +227,17 @@ class ParamVerify(object):
if
key
not
in
right_fetch_list
:
return
False
return
True
@
staticmethod
def
check_dynamic_shape_info
(
dynamic_shape_info
):
if
not
isinstance
(
dynamic_shape_info
,
dict
):
return
False
if
len
(
dynamic_shape_info
)
==
0
:
return
True
shape_info_keys
=
[
"min_input_shape"
,
"max_input_shape"
,
"opt_input_shape"
]
if
all
(
key
in
dynamic_shape_info
for
key
in
shape_info_keys
):
return
True
else
:
return
False
ErrorCatch
=
ErrorCatch
()
python/pipeline/operator.py
浏览文件 @
ae859b7d
...
...
@@ -46,6 +46,7 @@ from .util import NameGenerator
from
.profiler
import
UnsafeTimeProfiler
as
TimeProfiler
from
.
import
local_service_handler
from
.pipeline_client
import
PipelineClient
as
PPClient
from
paddle_serving_server.util
import
kill_stop_process_by_pid
_LOGGER
=
logging
.
getLogger
(
__name__
)
_op_name_gen
=
NameGenerator
(
"Op"
)
...
...
@@ -1328,7 +1329,12 @@ class Op(object):
# init ops
profiler
=
None
try
:
@
ErrorCatch
def
check_helper
(
self
,
is_thread_op
,
model_config
,
workdir
,
thread_num
,
device_type
,
devices
,
mem_optim
,
ir_optim
,
precision
,
use_mkldnn
,
mkldnn_cache_capacity
,
mkldnn_op_list
,
mkldnn_bf16_op_list
,
min_subgraph_size
,
dynamic_shape_info
):
if
is_thread_op
==
False
and
self
.
client_type
==
"local_predictor"
:
self
.
service_handler
=
local_service_handler
.
LocalServiceHandler
(
model_config
=
model_config
,
...
...
@@ -1354,12 +1360,21 @@ class Op(object):
concurrency_idx
)
# check all ops initialized successfully.
profiler
=
self
.
_initialize
(
is_thread_op
,
concurrency_idx
)
return
profiler
except
Exception
as
e
:
profiler
,
resp
=
check_helper
(
self
,
is_thread_op
,
model_config
,
workdir
,
thread_num
,
device_type
,
devices
,
mem_optim
,
ir_optim
,
precision
,
use_mkldnn
,
mkldnn_cache_capacity
,
mkldnn_op_list
,
mkldnn_bf16_op_list
,
min_subgraph_size
,
dynamic_shape_info
)
if
resp
.
err_no
!=
CustomExceptionCode
.
OK
.
value
:
_LOGGER
.
critical
(
"{} failed to init op: {}"
.
format
(
op_info_prefix
,
e
),
exc_info
=
True
)
os
.
_exit
(
-
1
)
"{} failed to init op: {}"
.
format
(
op_info_prefix
,
resp
.
err_msg
),
exc_info
=
False
)
print
(
"{} failed to init op: {}"
.
format
(
op_info_prefix
,
resp
.
err_msg
))
kill_stop_process_by_pid
(
"kill"
,
os
.
getpgid
(
os
.
getpid
()))
_LOGGER
.
info
(
"{} Succ init"
.
format
(
op_info_prefix
))
batch_generator
=
self
.
_auto_batching_generator
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录