Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
b306084f
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看板
提交
b306084f
编写于
4月 16, 2021
作者:
H
HexToString
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/PaddlePaddle/Serving
into merge_branch
上级
241e53da
62a23aec
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
763 addition
and
574 deletion
+763
-574
paddle_inference/paddle/include/paddle_engine.h
paddle_inference/paddle/include/paddle_engine.h
+29
-4
paddle_inference/paddle/src/paddle_engine.cpp
paddle_inference/paddle/src/paddle_engine.cpp
+2
-0
python/paddle_serving_server/serve.py
python/paddle_serving_server/serve.py
+17
-1
python/paddle_serving_server/web_service.py
python/paddle_serving_server/web_service.py
+13
-3
tools/scripts/ipipe_py3.sh
tools/scripts/ipipe_py3.sh
+702
-566
未找到文件。
paddle_inference/paddle/include/paddle_engine.h
浏览文件 @
b306084f
...
...
@@ -37,9 +37,24 @@ using paddle_infer::Tensor;
using
paddle_infer
::
CreatePredictor
;
DECLARE_int32
(
gpuid
);
DECLARE_string
(
precision
);
DECLARE_bool
(
use_calib
);
static
const
int
max_batch
=
32
;
static
const
int
min_subgraph_size
=
3
;
static
PrecisionType
precision_type
;
PrecisionType
GetPrecision
(
const
std
::
string
&
precision_data
)
{
std
::
string
precision_type
=
predictor
::
ToLower
(
precision_data
);
if
(
precision_type
==
"fp32"
)
{
return
PrecisionType
::
kFloat32
;
}
else
if
(
precision_type
==
"int8"
)
{
return
PrecisionType
::
kInt8
;
}
else
if
(
precision_type
==
"fp16"
)
{
return
PrecisionType
::
kHalf
;
}
return
PrecisionType
::
kFloat32
;
}
// Engine Base
class
EngineCore
{
...
...
@@ -137,6 +152,7 @@ class PaddleInferenceEngine : public EngineCore {
// 2000MB GPU memory
config
.
EnableUseGpu
(
2000
,
FLAGS_gpuid
);
}
precision_type
=
GetPrecision
(
FLAGS_precision
);
if
(
engine_conf
.
has_use_trt
()
&&
engine_conf
.
use_trt
())
{
if
(
!
engine_conf
.
has_use_gpu
()
||
!
engine_conf
.
use_gpu
())
{
...
...
@@ -145,14 +161,24 @@ class PaddleInferenceEngine : public EngineCore {
config
.
EnableTensorRtEngine
(
1
<<
20
,
max_batch
,
min_subgraph_size
,
Config
::
Precision
::
kFloat32
,
precision_type
,
false
,
false
);
FLAGS_use_calib
);
LOG
(
INFO
)
<<
"create TensorRT predictor"
;
}
if
(
engine_conf
.
has_use_lite
()
&&
engine_conf
.
use_lite
())
{
config
.
EnableLiteEngine
(
PrecisionType
::
kFloat32
,
true
);
config
.
EnableLiteEngine
(
precision_type
,
true
);
}
if
((
!
engine_conf
.
has_use_lite
()
&&
!
engine_conf
.
has_use_gpu
())
||
(
engine_conf
.
has_use_lite
()
&&
!
engine_conf
.
use_lite
()
&&
engine_conf
.
has_use_gpu
()
&&
!
engine_conf
.
use_gpu
()))
{
if
(
precision_type
==
PrecisionType
::
kInt8
)
{
config
.
EnableMkldnnQuantizer
();
}
else
if
(
precision_type
==
PrecisionType
::
kHalf
)
{
config
.
EnableMkldnnBfloat16
();
}
}
if
(
engine_conf
.
has_use_xpu
()
&&
engine_conf
.
use_xpu
())
{
...
...
@@ -171,7 +197,6 @@ class PaddleInferenceEngine : public EngineCore {
config
.
EnableMemoryOptim
();
}
predictor
::
AutoLock
lock
(
predictor
::
GlobalCreateMutex
::
instance
());
_predictor
=
CreatePredictor
(
config
);
if
(
NULL
==
_predictor
.
get
())
{
...
...
paddle_inference/paddle/src/paddle_engine.cpp
浏览文件 @
b306084f
...
...
@@ -20,6 +20,8 @@ namespace paddle_serving {
namespace
inference
{
DEFINE_int32
(
gpuid
,
0
,
"GPU device id to use"
);
DEFINE_string
(
precision
,
"fp32"
,
"precision to deploy, default is fp32"
);
DEFINE_bool
(
use_calib
,
false
,
"calibration mode, default is false"
);
REGIST_FACTORY_OBJECT_IMPL_WITH_NAME
(
::
baidu
::
paddle_serving
::
predictor
::
FluidInferEngine
<
PaddleInferenceEngine
>
,
...
...
python/paddle_serving_server/serve.py
浏览文件 @
b306084f
...
...
@@ -51,6 +51,16 @@ def serve_args():
"--name"
,
type
=
str
,
default
=
"None"
,
help
=
"Default service name"
)
parser
.
add_argument
(
"--use_mkl"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Use MKL"
)
parser
.
add_argument
(
"--precision"
,
type
=
str
,
default
=
"fp32"
,
help
=
"precision mode(fp32, int8, fp16, bf16)"
)
parser
.
add_argument
(
"--use_calib"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Use TensorRT Calibration"
)
parser
.
add_argument
(
"--mem_optim_off"
,
default
=
False
,
...
...
@@ -147,6 +157,8 @@ def start_standard_model(serving_port): # pylint: disable=doc-string-missing
server
.
use_mkl
(
use_mkl
)
server
.
set_max_body_size
(
max_body_size
)
server
.
set_port
(
port
)
server
.
set_precision
(
args
.
precision
)
server
.
set_use_calib
(
args
.
use_calib
)
server
.
use_encryption_model
(
use_encryption_model
)
if
args
.
product_name
!=
None
:
server
.
set_product_name
(
args
.
product_name
)
...
...
@@ -209,6 +221,8 @@ def start_gpu_card_model(index, gpuid, port, args): # pylint: disable=doc-strin
server
.
set_op_sequence
(
op_seq_maker
.
get_op_sequence
())
server
.
set_num_threads
(
thread_num
)
server
.
use_mkl
(
use_mkl
)
server
.
set_precision
(
args
.
precision
)
server
.
set_use_calib
(
args
.
use_calib
)
server
.
set_memory_optimize
(
mem_optim
)
server
.
set_ir_optimize
(
ir_optim
)
server
.
set_max_body_size
(
max_body_size
)
...
...
@@ -396,7 +410,9 @@ if __name__ == "__main__":
use_lite
=
args
.
use_lite
,
use_xpu
=
args
.
use_xpu
,
ir_optim
=
args
.
ir_optim
,
thread_num
=
args
.
thread
)
thread_num
=
args
.
thread
,
precision
=
args
.
precision
,
use_calib
=
args
.
use_calib
)
web_service
.
run_rpc_service
()
app_instance
=
Flask
(
__name__
)
...
...
python/paddle_serving_server/web_service.py
浏览文件 @
b306084f
...
...
@@ -115,7 +115,9 @@ class WebService(object):
mem_optim
=
True
,
use_lite
=
False
,
use_xpu
=
False
,
ir_optim
=
False
):
ir_optim
=
False
,
precision
=
"fp32"
,
use_calib
=
False
):
device
=
"gpu"
if
gpuid
==
-
1
:
if
use_lite
:
...
...
@@ -146,6 +148,8 @@ class WebService(object):
server
.
set_memory_optimize
(
mem_optim
)
server
.
set_ir_optimize
(
ir_optim
)
server
.
set_device
(
device
)
server
.
set_precision
(
precision
)
server
.
set_use_calib
(
use_calib
)
if
use_lite
:
server
.
set_lite
()
...
...
@@ -166,6 +170,8 @@ class WebService(object):
workdir
=
""
,
port
=
9393
,
device
=
"gpu"
,
precision
=
"fp32"
,
use_calib
=
False
,
use_lite
=
False
,
use_xpu
=
False
,
ir_optim
=
False
,
...
...
@@ -197,7 +203,9 @@ class WebService(object):
mem_optim
=
mem_optim
,
use_lite
=
use_lite
,
use_xpu
=
use_xpu
,
ir_optim
=
ir_optim
))
ir_optim
=
ir_optim
,
precision
=
precision
,
use_calib
=
use_calib
))
else
:
for
i
,
gpuid
in
enumerate
(
self
.
gpus
):
self
.
rpc_service_list
.
append
(
...
...
@@ -209,7 +217,9 @@ class WebService(object):
mem_optim
=
mem_optim
,
use_lite
=
use_lite
,
use_xpu
=
use_xpu
,
ir_optim
=
ir_optim
))
ir_optim
=
ir_optim
,
precision
=
precision
,
use_calib
=
use_calib
))
def
_launch_web_service
(
self
):
gpu_num
=
len
(
self
.
gpus
)
...
...
tools/scripts/ipipe_py3.sh
浏览文件 @
b306084f
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录