Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
da08f9f6
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看板
未验证
提交
da08f9f6
编写于
1月 20, 2021
作者:
J
Jiawei Wang
提交者:
GitHub
1月 20, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #980 from wangjiawei04/jiawei041
cherry pick PR979 976
上级
7e284dca
a9c357cc
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
64 addition
and
39 deletion
+64
-39
cmake/paddlepaddle.cmake
cmake/paddlepaddle.cmake
+3
-3
paddle_inference/inferencer-fluid-arm/include/fluid_arm_engine.h
...inference/inferencer-fluid-arm/include/fluid_arm_engine.h
+18
-16
python/CMakeLists.txt
python/CMakeLists.txt
+21
-9
python/paddle_serving_app/local_predict.py
python/paddle_serving_app/local_predict.py
+1
-0
python/paddle_serving_server_gpu/__init__.py
python/paddle_serving_server_gpu/__init__.py
+17
-11
python/paddle_serving_server_gpu/serve.py
python/paddle_serving_server_gpu/serve.py
+1
-0
python/paddle_serving_server_gpu/web_service.py
python/paddle_serving_server_gpu/web_service.py
+1
-0
python/pipeline/local_service_handler.py
python/pipeline/local_service_handler.py
+2
-0
未找到文件。
cmake/paddlepaddle.cmake
浏览文件 @
da08f9f6
...
@@ -136,8 +136,8 @@ if (WITH_TRT)
...
@@ -136,8 +136,8 @@ if (WITH_TRT)
endif
()
endif
()
if
(
WITH_LITE
)
if
(
WITH_LITE
)
ADD_LIBRARY
(
paddle_
api_full_bundl
ed STATIC IMPORTED GLOBAL
)
ADD_LIBRARY
(
paddle_
full_api_shar
ed STATIC IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET paddle_
api_full_bundled PROPERTY IMPORTED_LOCATION
${
PADDLE_INSTALL_DIR
}
/third_party/install/lite/cxx/lib/libpaddle_api_full_bundled.a
)
SET_PROPERTY
(
TARGET paddle_
full_api_shared PROPERTY IMPORTED_LOCATION
${
PADDLE_INSTALL_DIR
}
/third_party/install/lite/cxx/lib/libpaddle_full_api_shared.so
)
if
(
WITH_XPU
)
if
(
WITH_XPU
)
ADD_LIBRARY
(
xpuapi SHARED IMPORTED GLOBAL
)
ADD_LIBRARY
(
xpuapi SHARED IMPORTED GLOBAL
)
...
@@ -157,7 +157,7 @@ LIST(APPEND paddle_depend_libs
...
@@ -157,7 +157,7 @@ LIST(APPEND paddle_depend_libs
xxhash
)
xxhash
)
if
(
WITH_LITE
)
if
(
WITH_LITE
)
LIST
(
APPEND paddle_depend_libs paddle_
api_full_bundl
ed
)
LIST
(
APPEND paddle_depend_libs paddle_
full_api_shar
ed
)
if
(
WITH_XPU
)
if
(
WITH_XPU
)
LIST
(
APPEND paddle_depend_libs xpuapi xpurt
)
LIST
(
APPEND paddle_depend_libs xpuapi xpurt
)
endif
()
endif
()
...
...
paddle_inference/inferencer-fluid-arm/include/fluid_arm_engine.h
浏览文件 @
da08f9f6
...
@@ -128,20 +128,22 @@ class FluidArmAnalysisCore : public FluidFamilyCore {
...
@@ -128,20 +128,22 @@ class FluidArmAnalysisCore : public FluidFamilyCore {
config
.
DisableGpu
();
config
.
DisableGpu
();
config
.
SetCpuMathLibraryNumThreads
(
1
);
config
.
SetCpuMathLibraryNumThreads
(
1
);
if
(
params
.
enable_memory_optimization
())
{
if
(
params
.
use_lite
())
{
config
.
Enable
MemoryOptim
(
);
config
.
Enable
LiteEngine
(
PrecisionType
::
kFloat32
,
true
);
}
}
if
(
params
.
enable_memory_optimization
())
{
if
(
params
.
use_xpu
())
{
config
.
Enable
MemoryOptim
(
);
config
.
Enable
Xpu
(
2
*
1024
*
1024
);
}
}
if
(
params
.
use_lite
())
{
if
(
params
.
enable_memory_optimization
())
{
config
.
Enable
LiteEngine
(
PrecisionType
::
kFloat32
,
true
);
config
.
Enable
MemoryOptim
(
);
}
}
if
(
params
.
use_xpu
())
{
if
(
params
.
enable_ir_optimization
())
{
config
.
EnableXpu
(
100
);
config
.
SwitchIrOptim
(
true
);
}
else
{
config
.
SwitchIrOptim
(
false
);
}
}
config
.
SwitchSpecifyInputNames
(
true
);
config
.
SwitchSpecifyInputNames
(
true
);
...
@@ -173,6 +175,14 @@ class FluidArmAnalysisDirCore : public FluidFamilyCore {
...
@@ -173,6 +175,14 @@ class FluidArmAnalysisDirCore : public FluidFamilyCore {
config
.
SwitchSpecifyInputNames
(
true
);
config
.
SwitchSpecifyInputNames
(
true
);
config
.
SetCpuMathLibraryNumThreads
(
1
);
config
.
SetCpuMathLibraryNumThreads
(
1
);
if
(
params
.
use_lite
())
{
config
.
EnableLiteEngine
(
PrecisionType
::
kFloat32
,
true
);
}
if
(
params
.
use_xpu
())
{
config
.
EnableXpu
(
2
*
1024
*
1024
);
}
if
(
params
.
enable_memory_optimization
())
{
if
(
params
.
enable_memory_optimization
())
{
config
.
EnableMemoryOptim
();
config
.
EnableMemoryOptim
();
}
}
...
@@ -183,14 +193,6 @@ class FluidArmAnalysisDirCore : public FluidFamilyCore {
...
@@ -183,14 +193,6 @@ class FluidArmAnalysisDirCore : public FluidFamilyCore {
config
.
SwitchIrOptim
(
false
);
config
.
SwitchIrOptim
(
false
);
}
}
if
(
params
.
use_lite
())
{
config
.
EnableLiteEngine
(
PrecisionType
::
kFloat32
,
true
);
}
if
(
params
.
use_xpu
())
{
config
.
EnableXpu
(
100
);
}
AutoLock
lock
(
GlobalPaddleCreateMutex
::
instance
());
AutoLock
lock
(
GlobalPaddleCreateMutex
::
instance
());
_core
=
CreatePredictor
(
config
);
_core
=
CreatePredictor
(
config
);
if
(
NULL
==
_core
.
get
())
{
if
(
NULL
==
_core
.
get
())
{
...
...
python/CMakeLists.txt
浏览文件 @
da08f9f6
...
@@ -99,15 +99,27 @@ if (SERVER)
...
@@ -99,15 +99,27 @@ if (SERVER)
DEPENDS
${
SERVING_SERVER_CORE
}
server_config_py_proto
${
PY_FILES
}
)
DEPENDS
${
SERVING_SERVER_CORE
}
server_config_py_proto
${
PY_FILES
}
)
add_custom_target
(
paddle_python ALL DEPENDS
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
)
add_custom_target
(
paddle_python ALL DEPENDS
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
)
elseif
(
WITH_LITE
)
elseif
(
WITH_LITE
)
add_custom_command
(
if
(
WITH_XPU
)
OUTPUT
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
add_custom_command
(
COMMAND cp -r
OUTPUT
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
${
CMAKE_CURRENT_SOURCE_DIR
}
/paddle_serving_server_gpu/
${
PADDLE_SERVING_BINARY_DIR
}
/python/
COMMAND cp -r
COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
gen_version.py
${
CMAKE_CURRENT_SOURCE_DIR
}
/paddle_serving_server_gpu/
${
PADDLE_SERVING_BINARY_DIR
}
/python/
"server_gpu"
arm
COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
gen_version.py
COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py bdist_wheel
"server_gpu"
arm-xpu
DEPENDS
${
SERVING_SERVER_CORE
}
server_config_py_proto
${
PY_FILES
}
)
COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py bdist_wheel
add_custom_target
(
paddle_python ALL DEPENDS
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
)
DEPENDS
${
SERVING_SERVER_CORE
}
server_config_py_proto
${
PY_FILES
}
)
add_custom_target
(
paddle_python ALL DEPENDS
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
)
else
()
add_custom_command
(
OUTPUT
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
COMMAND cp -r
${
CMAKE_CURRENT_SOURCE_DIR
}
/paddle_serving_server_gpu/
${
PADDLE_SERVING_BINARY_DIR
}
/python/
COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
gen_version.py
"server_gpu"
arm
COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py bdist_wheel
DEPENDS
${
SERVING_SERVER_CORE
}
server_config_py_proto
${
PY_FILES
}
)
add_custom_target
(
paddle_python ALL DEPENDS
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
)
endif
()
else
()
else
()
add_custom_command
(
add_custom_command
(
OUTPUT
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
OUTPUT
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
...
...
python/paddle_serving_app/local_predict.py
浏览文件 @
da08f9f6
...
@@ -132,6 +132,7 @@ class LocalPredictor(object):
...
@@ -132,6 +132,7 @@ class LocalPredictor(object):
ops_filter
=
[])
ops_filter
=
[])
if
use_xpu
:
if
use_xpu
:
# 2MB l3 cache
config
.
enable_xpu
(
8
*
1024
*
1024
)
config
.
enable_xpu
(
8
*
1024
*
1024
)
self
.
predictor
=
create_paddle_predictor
(
config
)
self
.
predictor
=
create_paddle_predictor
(
config
)
...
...
python/paddle_serving_server_gpu/__init__.py
浏览文件 @
da08f9f6
...
@@ -212,6 +212,7 @@ class Server(object):
...
@@ -212,6 +212,7 @@ class Server(object):
self
.
module_path
=
os
.
path
.
dirname
(
paddle_serving_server
.
__file__
)
self
.
module_path
=
os
.
path
.
dirname
(
paddle_serving_server
.
__file__
)
self
.
cur_path
=
os
.
getcwd
()
self
.
cur_path
=
os
.
getcwd
()
self
.
use_local_bin
=
False
self
.
use_local_bin
=
False
self
.
device
=
"cpu"
self
.
gpuid
=
0
self
.
gpuid
=
0
self
.
use_trt
=
False
self
.
use_trt
=
False
self
.
use_lite
=
False
self
.
use_lite
=
False
...
@@ -279,6 +280,9 @@ class Server(object):
...
@@ -279,6 +280,9 @@ class Server(object):
"GPU not found, please check your environment or use cpu version by
\"
pip install paddle_serving_server
\"
"
"GPU not found, please check your environment or use cpu version by
\"
pip install paddle_serving_server
\"
"
)
)
def
set_device
(
self
,
device
=
"cpu"
):
self
.
device
=
device
def
set_gpuid
(
self
,
gpuid
=
0
):
def
set_gpuid
(
self
,
gpuid
=
0
):
self
.
gpuid
=
gpuid
self
.
gpuid
=
gpuid
...
@@ -311,18 +315,19 @@ class Server(object):
...
@@ -311,18 +315,19 @@ class Server(object):
engine
.
static_optimization
=
False
engine
.
static_optimization
=
False
engine
.
force_update_static_cache
=
False
engine
.
force_update_static_cache
=
False
engine
.
use_trt
=
self
.
use_trt
engine
.
use_trt
=
self
.
use_trt
engine
.
use_lite
=
self
.
use_lite
if
os
.
path
.
exists
(
'{}/__params__'
.
format
(
model_config_path
)):
engine
.
use_xpu
=
self
.
use_xpu
suffix
=
""
else
:
suffix
=
"_DIR"
if
device
==
"arm"
:
engine
.
use_lite
=
self
.
use_lite
engine
.
use_xpu
=
self
.
use_xpu
if
device
==
"cpu"
:
if
device
==
"cpu"
:
engine
.
type
=
"FLUID_CPU_ANALYSIS
_DIR"
engine
.
type
=
"FLUID_CPU_ANALYSIS
"
+
suffix
elif
device
==
"gpu"
:
elif
device
==
"gpu"
:
engine
.
type
=
"FLUID_GPU_ANALYSIS
_DIR"
engine
.
type
=
"FLUID_GPU_ANALYSIS
"
+
suffix
elif
device
==
"arm"
:
elif
device
==
"arm"
:
engine
.
type
=
"FLUID_ARM_ANALYSIS_DIR"
engine
.
type
=
"FLUID_ARM_ANALYSIS"
+
suffix
self
.
model_toolkit_conf
.
engines
.
extend
([
engine
])
self
.
model_toolkit_conf
.
engines
.
extend
([
engine
])
def
_prepare_infer_service
(
self
,
port
):
def
_prepare_infer_service
(
self
,
port
):
...
@@ -425,7 +430,7 @@ class Server(object):
...
@@ -425,7 +430,7 @@ class Server(object):
cuda_version
=
line
.
split
(
"
\"
"
)[
1
]
cuda_version
=
line
.
split
(
"
\"
"
)[
1
]
if
cuda_version
==
"101"
or
cuda_version
==
"102"
or
cuda_version
==
"110"
:
if
cuda_version
==
"101"
or
cuda_version
==
"102"
or
cuda_version
==
"110"
:
device_version
=
"serving-gpu-"
+
cuda_version
+
"-"
device_version
=
"serving-gpu-"
+
cuda_version
+
"-"
elif
cuda_version
==
"arm"
:
elif
cuda_version
==
"arm"
or
cuda_version
==
"arm-xpu"
:
device_version
=
"serving-"
+
cuda_version
+
"-"
device_version
=
"serving-"
+
cuda_version
+
"-"
else
:
else
:
device_version
=
"serving-gpu-cuda"
+
cuda_version
+
"-"
device_version
=
"serving-gpu-cuda"
+
cuda_version
+
"-"
...
@@ -528,7 +533,8 @@ class Server(object):
...
@@ -528,7 +533,8 @@ class Server(object):
else
:
else
:
print
(
"Use local bin : {}"
.
format
(
self
.
bin_path
))
print
(
"Use local bin : {}"
.
format
(
self
.
bin_path
))
#self.check_cuda()
#self.check_cuda()
if
self
.
use_lite
:
# Todo: merge CPU and GPU code, remove device to model_toolkit
if
self
.
device
==
"cpu"
or
self
.
device
==
"arm"
:
command
=
"{} "
\
command
=
"{} "
\
"-enable_model_toolkit "
\
"-enable_model_toolkit "
\
"-inferservice_path {} "
\
"-inferservice_path {} "
\
...
...
python/paddle_serving_server_gpu/serve.py
浏览文件 @
da08f9f6
...
@@ -73,6 +73,7 @@ def start_gpu_card_model(index, gpuid, args): # pylint: disable=doc-string-miss
...
@@ -73,6 +73,7 @@ def start_gpu_card_model(index, gpuid, args): # pylint: disable=doc-string-miss
server
.
set_lite
()
server
.
set_lite
()
device
=
"arm"
device
=
"arm"
server
.
set_device
(
device
)
if
args
.
use_xpu
:
if
args
.
use_xpu
:
server
.
set_xpu
()
server
.
set_xpu
()
...
...
python/paddle_serving_server_gpu/web_service.py
浏览文件 @
da08f9f6
...
@@ -107,6 +107,7 @@ class WebService(object):
...
@@ -107,6 +107,7 @@ class WebService(object):
server
.
set_num_threads
(
thread_num
)
server
.
set_num_threads
(
thread_num
)
server
.
set_memory_optimize
(
mem_optim
)
server
.
set_memory_optimize
(
mem_optim
)
server
.
set_ir_optimize
(
ir_optim
)
server
.
set_ir_optimize
(
ir_optim
)
server
.
set_device
(
device
)
if
use_lite
:
if
use_lite
:
server
.
set_lite
()
server
.
set_lite
()
...
...
python/pipeline/local_service_handler.py
浏览文件 @
da08f9f6
...
@@ -249,6 +249,8 @@ class LocalServiceHandler(object):
...
@@ -249,6 +249,8 @@ class LocalServiceHandler(object):
server
=
Server
()
server
=
Server
()
if
gpuid
>=
0
:
if
gpuid
>=
0
:
server
.
set_gpuid
(
gpuid
)
server
.
set_gpuid
(
gpuid
)
# TODO: support arm or arm + xpu later
server
.
set_device
(
self
.
_device_name
)
server
.
set_op_sequence
(
op_seq_maker
.
get_op_sequence
())
server
.
set_op_sequence
(
op_seq_maker
.
get_op_sequence
())
server
.
set_num_threads
(
thread_num
)
server
.
set_num_threads
(
thread_num
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录