Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
b773cf1f
S
Serving
项目概览
PaddlePaddle
/
Serving
接近 2 年 前同步成功
通知
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看板
提交
b773cf1f
编写于
12月 23, 2020
作者:
Z
zhangjun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
run on xpu bugfix
上级
30dcd502
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
105 addition
and
36 deletion
+105
-36
core/configure/CMakeLists.txt
core/configure/CMakeLists.txt
+1
-1
python/CMakeLists.txt
python/CMakeLists.txt
+13
-3
python/paddle_serving_server_gpu/__init__.py
python/paddle_serving_server_gpu/__init__.py
+77
-30
python/paddle_serving_server_gpu/serve.py
python/paddle_serving_server_gpu/serve.py
+14
-2
未找到文件。
core/configure/CMakeLists.txt
浏览文件 @
b773cf1f
...
@@ -76,7 +76,7 @@ if (SERVER)
...
@@ -76,7 +76,7 @@ if (SERVER)
py_proto_compile
(
server_config_py_proto SRCS proto/server_configure.proto
)
py_proto_compile
(
server_config_py_proto SRCS proto/server_configure.proto
)
add_custom_target
(
server_config_py_proto_init ALL COMMAND
${
CMAKE_COMMAND
}
-E touch __init__.py
)
add_custom_target
(
server_config_py_proto_init ALL COMMAND
${
CMAKE_COMMAND
}
-E touch __init__.py
)
add_dependencies
(
server_config_py_proto server_config_py_proto_init
)
add_dependencies
(
server_config_py_proto server_config_py_proto_init
)
if
(
NOT WITH_GPU
)
if
(
NOT WITH_GPU
AND NOT WITH_LITE
)
add_custom_command
(
TARGET server_config_py_proto POST_BUILD
add_custom_command
(
TARGET server_config_py_proto POST_BUILD
COMMAND
${
CMAKE_COMMAND
}
-E make_directory
${
PADDLE_SERVING_BINARY_DIR
}
/python/paddle_serving_server/proto
COMMAND
${
CMAKE_COMMAND
}
-E make_directory
${
PADDLE_SERVING_BINARY_DIR
}
/python/paddle_serving_server/proto
COMMAND cp *.py
${
PADDLE_SERVING_BINARY_DIR
}
/python/paddle_serving_server/proto
COMMAND cp *.py
${
PADDLE_SERVING_BINARY_DIR
}
/python/paddle_serving_server/proto
...
...
python/CMakeLists.txt
浏览文件 @
b773cf1f
...
@@ -7,7 +7,7 @@ if (CLIENT)
...
@@ -7,7 +7,7 @@ if (CLIENT)
endif
()
endif
()
if
(
SERVER
)
if
(
SERVER
)
if
(
NOT WITH_GPU
)
if
(
NOT WITH_GPU
AND NOT WITH_LITE
)
file
(
INSTALL pipeline DESTINATION paddle_serving_server
)
file
(
INSTALL pipeline DESTINATION paddle_serving_server
)
file
(
GLOB_RECURSE SERVING_SERVER_PY_FILES paddle_serving_server/*.py
)
file
(
GLOB_RECURSE SERVING_SERVER_PY_FILES paddle_serving_server/*.py
)
else
()
else
()
...
@@ -34,7 +34,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.app.in
...
@@ -34,7 +34,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.app.in
endif
()
endif
()
if
(
SERVER
)
if
(
SERVER
)
if
(
NOT WITH_GPU
)
if
(
NOT WITH_GPU
AND NOT WITH_LITE
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/setup.py.server.in
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/setup.py.server.in
${
CMAKE_CURRENT_BINARY_DIR
}
/setup.py
)
${
CMAKE_CURRENT_BINARY_DIR
}
/setup.py
)
else
()
else
()
...
@@ -72,7 +72,7 @@ add_custom_target(paddle_python ALL DEPENDS serving_client ${PADDLE_SERVING_BINA
...
@@ -72,7 +72,7 @@ add_custom_target(paddle_python ALL DEPENDS serving_client ${PADDLE_SERVING_BINA
endif
()
endif
()
if
(
SERVER
)
if
(
SERVER
)
if
(
NOT WITH_GPU
)
if
(
NOT WITH_GPU
AND NOT WITH_LITE
)
add_custom_command
(
add_custom_command
(
OUTPUT
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
OUTPUT
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
COMMAND cp -r
${
CMAKE_CURRENT_SOURCE_DIR
}
/paddle_serving_server/
${
PADDLE_SERVING_BINARY_DIR
}
/python/
COMMAND cp -r
${
CMAKE_CURRENT_SOURCE_DIR
}
/paddle_serving_server/
${
PADDLE_SERVING_BINARY_DIR
}
/python/
...
@@ -90,6 +90,16 @@ if (SERVER)
...
@@ -90,6 +90,16 @@ if (SERVER)
COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py bdist_wheel
COMMAND env
${
py_env
}
${
PYTHON_EXECUTABLE
}
setup.py bdist_wheel
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
)
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
)
else
()
else
()
add_custom_command
(
add_custom_command
(
OUTPUT
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
OUTPUT
${
PADDLE_SERVING_BINARY_DIR
}
/.timestamp
...
...
python/paddle_serving_server_gpu/__init__.py
浏览文件 @
b773cf1f
...
@@ -75,6 +75,10 @@ def serve_args():
...
@@ -75,6 +75,10 @@ def serve_args():
help
=
"Use Multi-language-service"
)
help
=
"Use Multi-language-service"
)
parser
.
add_argument
(
parser
.
add_argument
(
"--use_trt"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Use TensorRT"
)
"--use_trt"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Use TensorRT"
)
parser
.
add_argument
(
"--use_lite"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Use PaddleLite"
)
parser
.
add_argument
(
"--use_xpu"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Use XPU"
)
parser
.
add_argument
(
parser
.
add_argument
(
"--product_name"
,
"--product_name"
,
type
=
str
,
type
=
str
,
...
@@ -208,6 +212,8 @@ class Server(object):
...
@@ -208,6 +212,8 @@ class Server(object):
self
.
use_local_bin
=
False
self
.
use_local_bin
=
False
self
.
gpuid
=
0
self
.
gpuid
=
0
self
.
use_trt
=
False
self
.
use_trt
=
False
self
.
use_lite
=
False
self
.
use_xpu
=
False
self
.
model_config_paths
=
None
# for multi-model in a workflow
self
.
model_config_paths
=
None
# for multi-model in a workflow
self
.
product_name
=
None
self
.
product_name
=
None
self
.
container_id
=
None
self
.
container_id
=
None
...
@@ -277,6 +283,12 @@ class Server(object):
...
@@ -277,6 +283,12 @@ class Server(object):
def
set_trt
(
self
):
def
set_trt
(
self
):
self
.
use_trt
=
True
self
.
use_trt
=
True
def
set_lite
(
self
):
self
.
use_lite
=
True
def
set_xpu
(
self
):
self
.
use_xpu
=
True
def
_prepare_engine
(
self
,
model_config_paths
,
device
):
def
_prepare_engine
(
self
,
model_config_paths
,
device
):
if
self
.
model_toolkit_conf
==
None
:
if
self
.
model_toolkit_conf
==
None
:
self
.
model_toolkit_conf
=
server_sdk
.
ModelToolkitConf
()
self
.
model_toolkit_conf
=
server_sdk
.
ModelToolkitConf
()
...
@@ -297,11 +309,17 @@ class Server(object):
...
@@ -297,11 +309,17 @@ 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
engine
.
use_xpu
=
self
.
use_xpu
if
device
==
"cpu"
:
if
device
==
"cpu"
:
engine
.
type
=
"FLUID_CPU_ANALYSIS_DIR"
engine
.
type
=
"FLUID_CPU_ANALYSIS_DIR"
elif
device
==
"gpu"
:
elif
device
==
"gpu"
:
engine
.
type
=
"FLUID_GPU_ANALYSIS_DIR"
engine
.
type
=
"FLUID_GPU_ANALYSIS_DIR"
elif
device
==
"arm"
:
engine
.
type
=
"FLUID_ARM_ANALYSIS_DIR"
self
.
model_toolkit_conf
.
engines
.
extend
([
engine
])
self
.
model_toolkit_conf
.
engines
.
extend
([
engine
])
...
@@ -505,36 +523,65 @@ class Server(object):
...
@@ -505,36 +523,65 @@ class Server(object):
time
.
sleep
(
1
)
time
.
sleep
(
1
)
else
:
else
:
print
(
"Use local bin : {}"
.
format
(
self
.
bin_path
))
print
(
"Use local bin : {}"
.
format
(
self
.
bin_path
))
self
.
check_cuda
()
#self.check_cuda()
command
=
"{} "
\
if
self
.
use_lite
:
"-enable_model_toolkit "
\
command
=
"{} "
\
"-inferservice_path {} "
\
"-enable_model_toolkit "
\
"-inferservice_file {} "
\
"-inferservice_path {} "
\
"-max_concurrency {} "
\
"-inferservice_file {} "
\
"-num_threads {} "
\
"-max_concurrency {} "
\
"-port {} "
\
"-num_threads {} "
\
"-reload_interval_s {} "
\
"-port {} "
\
"-resource_path {} "
\
"-reload_interval_s {} "
\
"-resource_file {} "
\
"-resource_path {} "
\
"-workflow_path {} "
\
"-resource_file {} "
\
"-workflow_file {} "
\
"-workflow_path {} "
\
"-bthread_concurrency {} "
\
"-workflow_file {} "
\
"-gpuid {} "
\
"-bthread_concurrency {} "
\
"-max_body_size {} "
.
format
(
"-max_body_size {} "
.
format
(
self
.
bin_path
,
self
.
bin_path
,
self
.
workdir
,
self
.
workdir
,
self
.
infer_service_fn
,
self
.
infer_service_fn
,
self
.
max_concurrency
,
self
.
max_concurrency
,
self
.
num_threads
,
self
.
num_threads
,
self
.
port
,
self
.
port
,
self
.
reload_interval_s
,
self
.
reload_interval_s
,
self
.
workdir
,
self
.
workdir
,
self
.
resource_fn
,
self
.
resource_fn
,
self
.
workdir
,
self
.
workdir
,
self
.
workflow_fn
,
self
.
workflow_fn
,
self
.
num_threads
,
self
.
num_threads
,
self
.
gpuid
,
self
.
max_body_size
)
self
.
max_body_size
)
else
:
command
=
"{} "
\
"-enable_model_toolkit "
\
"-inferservice_path {} "
\
"-inferservice_file {} "
\
"-max_concurrency {} "
\
"-num_threads {} "
\
"-port {} "
\
"-reload_interval_s {} "
\
"-resource_path {} "
\
"-resource_file {} "
\
"-workflow_path {} "
\
"-workflow_file {} "
\
"-bthread_concurrency {} "
\
"-gpuid {} "
\
"-max_body_size {} "
.
format
(
self
.
bin_path
,
self
.
workdir
,
self
.
infer_service_fn
,
self
.
max_concurrency
,
self
.
num_threads
,
self
.
port
,
self
.
reload_interval_s
,
self
.
workdir
,
self
.
resource_fn
,
self
.
workdir
,
self
.
workflow_fn
,
self
.
num_threads
,
self
.
gpuid
,
self
.
max_body_size
)
print
(
"Going to Run Comand"
)
print
(
"Going to Run Comand"
)
print
(
command
)
print
(
command
)
...
...
python/paddle_serving_server_gpu/serve.py
浏览文件 @
b773cf1f
...
@@ -38,7 +38,9 @@ def start_gpu_card_model(index, gpuid, args): # pylint: disable=doc-string-miss
...
@@ -38,7 +38,9 @@ def start_gpu_card_model(index, gpuid, args): # pylint: disable=doc-string-miss
ir_optim
=
args
.
ir_optim
ir_optim
=
args
.
ir_optim
max_body_size
=
args
.
max_body_size
max_body_size
=
args
.
max_body_size
use_multilang
=
args
.
use_multilang
use_multilang
=
args
.
use_multilang
workdir
=
"{}_{}"
.
format
(
args
.
workdir
,
gpuid
)
workdir
=
args
.
workdir
if
gpuid
>=
0
:
workdir
=
"{}_{}"
.
format
(
args
.
workdir
,
gpuid
)
if
model
==
""
:
if
model
==
""
:
print
(
"You must specify your serving model"
)
print
(
"You must specify your serving model"
)
...
@@ -67,6 +69,13 @@ def start_gpu_card_model(index, gpuid, args): # pylint: disable=doc-string-miss
...
@@ -67,6 +69,13 @@ def start_gpu_card_model(index, gpuid, args): # pylint: disable=doc-string-miss
if
args
.
use_trt
:
if
args
.
use_trt
:
server
.
set_trt
()
server
.
set_trt
()
if
args
.
use_lite
:
server
.
set_lite
()
device
=
"arm"
if
args
.
use_xpu
:
server
.
set_xpu
()
if
args
.
product_name
!=
None
:
if
args
.
product_name
!=
None
:
server
.
set_product_name
(
args
.
product_name
)
server
.
set_product_name
(
args
.
product_name
)
if
args
.
container_id
!=
None
:
if
args
.
container_id
!=
None
:
...
@@ -95,7 +104,10 @@ def start_multi_card(args): # pylint: disable=doc-string-missing
...
@@ -95,7 +104,10 @@ def start_multi_card(args): # pylint: disable=doc-string-missing
exit
(
-
1
)
exit
(
-
1
)
else
:
else
:
env_gpus
=
[]
env_gpus
=
[]
if
len
(
gpus
)
<=
0
:
if
args
.
use_lite
:
print
(
"run arm server."
)
start_gpu_card_model
(
-
1
,
-
1
,
args
)
elif
len
(
gpus
)
<=
0
:
print
(
"gpu_ids not set, going to run cpu service."
)
print
(
"gpu_ids not set, going to run cpu service."
)
start_gpu_card_model
(
-
1
,
-
1
,
args
)
start_gpu_card_model
(
-
1
,
-
1
,
args
)
else
:
else
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录