Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
b0953a3f
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看板
提交
b0953a3f
编写于
11月 05, 2021
作者:
S
ShiningZhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support ascend_cl arm64 with lite for ascend310
上级
6da3f883
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
104 addition
and
9 deletion
+104
-9
CMakeLists.txt
CMakeLists.txt
+1
-0
cmake/paddlepaddle.cmake
cmake/paddlepaddle.cmake
+15
-1
core/configure/proto/server_configure.proto
core/configure/proto/server_configure.proto
+1
-0
core/general-client/CMakeLists.txt
core/general-client/CMakeLists.txt
+1
-1
paddle_inference/paddle/include/paddle_engine.h
paddle_inference/paddle/include/paddle_engine.h
+27
-0
paddle_inference/paddle/src/paddle_engine.cpp
paddle_inference/paddle/src/paddle_engine.cpp
+5
-0
python/CMakeLists.txt
python/CMakeLists.txt
+2
-0
python/gen_version.py
python/gen_version.py
+2
-0
python/paddle_serving_app/local_predict.py
python/paddle_serving_app/local_predict.py
+19
-3
python/paddle_serving_server/serve.py
python/paddle_serving_server/serve.py
+5
-1
python/paddle_serving_server/server.py
python/paddle_serving_server/server.py
+12
-0
python/pipeline/local_service_handler.py
python/pipeline/local_service_handler.py
+14
-3
未找到文件。
CMakeLists.txt
浏览文件 @
b0953a3f
...
@@ -60,6 +60,7 @@ option(WITH_TRT "Compile Paddle Serving with TRT"
...
@@ -60,6 +60,7 @@ option(WITH_TRT "Compile Paddle Serving with TRT"
option
(
PADDLE_ON_INFERENCE
"Compile for encryption"
ON
)
option
(
PADDLE_ON_INFERENCE
"Compile for encryption"
ON
)
option
(
WITH_OPENCV
"Compile Paddle Serving with OPENCV"
OFF
)
option
(
WITH_OPENCV
"Compile Paddle Serving with OPENCV"
OFF
)
option
(
WITH_ROCM
"Compile Paddle Serving with ROCM"
OFF
)
option
(
WITH_ROCM
"Compile Paddle Serving with ROCM"
OFF
)
option
(
WITH_ASCEND_CL
"Compile PaddlePaddle with ASCEND CL"
OFF
)
if
(
NOT DEFINED VERSION_TAG
)
if
(
NOT DEFINED VERSION_TAG
)
set
(
VERSION_TAG
"0.0.0"
)
set
(
VERSION_TAG
"0.0.0"
)
...
...
cmake/paddlepaddle.cmake
浏览文件 @
b0953a3f
...
@@ -62,6 +62,13 @@ elseif (WITH_LITE)
...
@@ -62,6 +62,13 @@ elseif (WITH_LITE)
elseif
(
CMAKE_SYSTEM_PROCESSOR STREQUAL
"aarch64"
)
elseif
(
CMAKE_SYSTEM_PROCESSOR STREQUAL
"aarch64"
)
SET
(
PADDLE_LIB_VERSION
"arm64_gcc7.3_openblas"
)
SET
(
PADDLE_LIB_VERSION
"arm64_gcc7.3_openblas"
)
endif
()
endif
()
elseif
(
WITH_ASCEND_CL
)
if
(
CMAKE_SYSTEM_PROCESSOR STREQUAL
"x86_64"
)
MESSAGE
(
"paddle lite lib is unknown."
)
SET
(
PADDLE_LIB_VERSION
"paddle-lite-unknown"
)
elseif
(
CMAKE_SYSTEM_PROCESSOR STREQUAL
"aarch64"
)
SET
(
PADDLE_LIB_VERSION
"
${
PADDLE_VERSION
}
/cxx_c/Linux/ASCEND/arm64_gcc7.5_openblas_lite2.10"
)
endif
()
else
()
else
()
MESSAGE
(
"paddle lite lib is unknown."
)
MESSAGE
(
"paddle lite lib is unknown."
)
SET
(
PADDLE_LIB_VERSION
"paddle-lite-unknown"
)
SET
(
PADDLE_LIB_VERSION
"paddle-lite-unknown"
)
...
@@ -81,7 +88,11 @@ else()
...
@@ -81,7 +88,11 @@ else()
endif
()
endif
()
if
(
WITH_LITE
)
if
(
WITH_LITE
)
SET
(
PADDLE_LIB_PATH
"https://paddle-inference-lib.bj.bcebos.com/2.2.0-rc0/cxx_c/Linux/XPU/
${
PADDLE_LIB_VERSION
}
/paddle_inference_install_dir.tar.gz "
)
if
(
WITH_XPU
)
SET
(
PADDLE_LIB_PATH
"https://paddle-inference-lib.bj.bcebos.com/2.2.0-rc0/cxx_c/Linux/XPU/
${
PADDLE_LIB_VERSION
}
/paddle_inference_install_dir.tar.gz "
)
elseif
(
WITH_ASCEND_CL
)
SET
(
PADDLE_LIB_PATH
"http://paddle-serving.bj.bcebos.com/inferlib/
${
PADDLE_LIB_VERSION
}
/paddle_inference_install_dir.tgz "
)
endif
()
else
()
else
()
SET
(
PADDLE_LIB_PATH
"http://paddle-inference-lib.bj.bcebos.com/
${
PADDLE_LIB_VERSION
}
/paddle_inference.tgz"
)
SET
(
PADDLE_LIB_PATH
"http://paddle-inference-lib.bj.bcebos.com/
${
PADDLE_LIB_VERSION
}
/paddle_inference.tgz"
)
endif
()
endif
()
...
@@ -152,6 +163,9 @@ endif()
...
@@ -152,6 +163,9 @@ endif()
ADD_LIBRARY
(
paddle_inference STATIC IMPORTED GLOBAL
)
ADD_LIBRARY
(
paddle_inference STATIC IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET paddle_inference PROPERTY IMPORTED_LOCATION
${
PADDLE_INSTALL_DIR
}
/lib/libpaddle_inference.a
)
SET_PROPERTY
(
TARGET paddle_inference PROPERTY IMPORTED_LOCATION
${
PADDLE_INSTALL_DIR
}
/lib/libpaddle_inference.a
)
if
(
WITH_ASCEND_CL AND WITH_LITE
)
SET_PROPERTY
(
TARGET paddle_inference PROPERTY IMPORTED_LOCATION
${
PADDLE_INSTALL_DIR
}
/lib/libpaddle_inference.so
)
endif
()
if
(
WITH_TRT
)
if
(
WITH_TRT
)
ADD_LIBRARY
(
nvinfer SHARED IMPORTED GLOBAL
)
ADD_LIBRARY
(
nvinfer SHARED IMPORTED GLOBAL
)
...
...
core/configure/proto/server_configure.proto
浏览文件 @
b0953a3f
...
@@ -47,6 +47,7 @@ message EngineDesc {
...
@@ -47,6 +47,7 @@ message EngineDesc {
optional
bool
combined_model
=
18
;
optional
bool
combined_model
=
18
;
optional
bool
encrypted_model
=
19
;
optional
bool
encrypted_model
=
19
;
optional
bool
gpu_multi_stream
=
20
;
optional
bool
gpu_multi_stream
=
20
;
optional
bool
use_ascend_cl
=
21
;
/*
/*
* "runtime_thread_num": n == 0 means don`t use Asynchronous task scheduling
* "runtime_thread_num": n == 0 means don`t use Asynchronous task scheduling
...
...
core/general-client/CMakeLists.txt
浏览文件 @
b0953a3f
...
@@ -18,7 +18,7 @@ add_executable(simple_client example/simple_client.cpp)
...
@@ -18,7 +18,7 @@ add_executable(simple_client example/simple_client.cpp)
add_dependencies
(
simple_client utils sdk-cpp client
)
add_dependencies
(
simple_client utils sdk-cpp client
)
target_link_libraries
(
simple_client -Wl,--whole-archive
target_link_libraries
(
simple_client -Wl,--whole-archive
-Wl,--no-whole-archive -lpthread -lcrypto -lm -lrt -lssl -ldl -lz -Wl,-rpath,'$ORIGIN'/lib
)
-Wl,--no-whole-archive -
Wl,--start-group -
lpthread -lcrypto -lm -lrt -lssl -ldl -lz -Wl,-rpath,'$ORIGIN'/lib
)
target_link_libraries
(
simple_client utils
)
target_link_libraries
(
simple_client utils
)
target_link_libraries
(
simple_client sdk-cpp
)
target_link_libraries
(
simple_client sdk-cpp
)
...
...
paddle_inference/paddle/include/paddle_engine.h
浏览文件 @
b0953a3f
...
@@ -41,6 +41,9 @@ using paddle_infer::CreatePredictor;
...
@@ -41,6 +41,9 @@ using paddle_infer::CreatePredictor;
DECLARE_int32
(
gpuid
);
DECLARE_int32
(
gpuid
);
DECLARE_string
(
precision
);
DECLARE_string
(
precision
);
DECLARE_bool
(
use_calib
);
DECLARE_bool
(
use_calib
);
DECLARE_string
(
nnadapter_device_names
);
DECLARE_string
(
nnadapter_context_properties
);
DECLARE_string
(
nnadapter_model_cache_dir
);
static
const
int
max_batch
=
32
;
static
const
int
max_batch
=
32
;
static
const
int
min_subgraph_size
=
3
;
static
const
int
min_subgraph_size
=
3
;
...
@@ -237,6 +240,7 @@ class PaddleInferenceEngine : public EngineCore {
...
@@ -237,6 +240,7 @@ class PaddleInferenceEngine : public EngineCore {
if
(
engine_conf
.
has_use_lite
()
&&
engine_conf
.
use_lite
())
{
if
(
engine_conf
.
has_use_lite
()
&&
engine_conf
.
use_lite
())
{
config
.
EnableLiteEngine
(
precision_type
,
true
);
config
.
EnableLiteEngine
(
precision_type
,
true
);
config
.
SwitchIrOptim
(
true
);
}
}
if
((
!
engine_conf
.
has_use_lite
()
&&
!
engine_conf
.
has_use_gpu
())
||
if
((
!
engine_conf
.
has_use_lite
()
&&
!
engine_conf
.
has_use_gpu
())
||
...
@@ -269,6 +273,29 @@ class PaddleInferenceEngine : public EngineCore {
...
@@ -269,6 +273,29 @@ class PaddleInferenceEngine : public EngineCore {
config
.
SetXpuDeviceId
(
gpu_id
);
config
.
SetXpuDeviceId
(
gpu_id
);
}
}
if
(
engine_conf
.
has_use_ascend_cl
()
&&
engine_conf
.
use_ascend_cl
())
{
if
(
engine_conf
.
has_use_lite
()
&&
engine_conf
.
use_lite
())
{
FLAGS_nnadapter_device_names
=
"huawei_ascend_npu"
;
FLAGS_nnadapter_context_properties
=
"HUAWEI_ASCEND_NPU_SELECTED_DEVICE_IDS="
+
std
::
to_string
(
gpu_id
);
FLAGS_nnadapter_model_cache_dir
=
""
;
config
.
NNAdapter
()
.
Enable
()
.
SetDeviceNames
({
FLAGS_nnadapter_device_names
})
.
SetContextProperties
(
FLAGS_nnadapter_context_properties
)
.
SetModelCacheDir
(
FLAGS_nnadapter_model_cache_dir
);
LOG
(
INFO
)
<<
"Enable Lite NNAdapter for Ascend,"
<<
"nnadapter_device_names="
<<
FLAGS_nnadapter_device_names
<<
",nnadapter_context_properties="
<<
FLAGS_nnadapter_context_properties
<<
",nnadapter_model_cache_dir="
<<
FLAGS_nnadapter_model_cache_dir
;
}
}
if
(
engine_conf
.
has_enable_memory_optimization
()
&&
if
(
engine_conf
.
has_enable_memory_optimization
()
&&
engine_conf
.
enable_memory_optimization
())
{
engine_conf
.
enable_memory_optimization
())
{
config
.
EnableMemoryOptim
();
config
.
EnableMemoryOptim
();
...
...
paddle_inference/paddle/src/paddle_engine.cpp
浏览文件 @
b0953a3f
...
@@ -22,6 +22,11 @@ namespace inference {
...
@@ -22,6 +22,11 @@ namespace inference {
DEFINE_int32
(
gpuid
,
0
,
"GPU device id to use"
);
DEFINE_int32
(
gpuid
,
0
,
"GPU device id to use"
);
DEFINE_string
(
precision
,
"fp32"
,
"precision to deploy, default is fp32"
);
DEFINE_string
(
precision
,
"fp32"
,
"precision to deploy, default is fp32"
);
DEFINE_bool
(
use_calib
,
false
,
"calibration mode, default is false"
);
DEFINE_bool
(
use_calib
,
false
,
"calibration mode, default is false"
);
DEFINE_string
(
nnadapter_device_names
,
""
,
"Names of nnadapter device"
);
DEFINE_string
(
nnadapter_context_properties
,
""
,
"Properties of nnadapter context"
);
DEFINE_string
(
nnadapter_model_cache_dir
,
""
,
"Cache dir of nnadapter model"
);
REGIST_FACTORY_OBJECT_IMPL_WITH_NAME
(
REGIST_FACTORY_OBJECT_IMPL_WITH_NAME
(
::
baidu
::
paddle_serving
::
predictor
::
FluidInferEngine
<
PaddleInferenceEngine
>
,
::
baidu
::
paddle_serving
::
predictor
::
FluidInferEngine
<
PaddleInferenceEngine
>
,
...
...
python/CMakeLists.txt
浏览文件 @
b0953a3f
...
@@ -14,6 +14,8 @@ if (SERVER)
...
@@ -14,6 +14,8 @@ if (SERVER)
set
(
SERVER_PACKAGE_NAME
"paddle-serving-server-xpu"
)
set
(
SERVER_PACKAGE_NAME
"paddle-serving-server-xpu"
)
elseif
(
WITH_ROCM
)
elseif
(
WITH_ROCM
)
set
(
SERVER_PACKAGE_NAME
"paddle-serving-server-rocm"
)
set
(
SERVER_PACKAGE_NAME
"paddle-serving-server-rocm"
)
elseif
(
WITH_ASCEND_CL
)
set
(
SERVER_PACKAGE_NAME
"paddle-serving-server-npu"
)
endif
()
endif
()
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
)
...
...
python/gen_version.py
浏览文件 @
b0953a3f
...
@@ -45,6 +45,8 @@ elif package_name.endswith('xpu'):
...
@@ -45,6 +45,8 @@ elif package_name.endswith('xpu'):
update_info
(
"paddle_serving_server/version.py"
,
"device_type"
,
"2"
)
update_info
(
"paddle_serving_server/version.py"
,
"device_type"
,
"2"
)
elif
package_name
.
endswith
(
'rocm'
):
elif
package_name
.
endswith
(
'rocm'
):
update_info
(
"paddle_serving_server/version.py"
,
"device_type"
,
"3"
)
update_info
(
"paddle_serving_server/version.py"
,
"device_type"
,
"3"
)
elif
package_name
.
endswith
(
'npu'
):
update_info
(
"paddle_serving_server/version.py"
,
"device_type"
,
"4"
)
path
=
"paddle_serving_"
+
sys
.
argv
[
1
]
path
=
"paddle_serving_"
+
sys
.
argv
[
1
]
commit_id
=
subprocess
.
check_output
([
'git'
,
'rev-parse'
,
'HEAD'
])
commit_id
=
subprocess
.
check_output
([
'git'
,
'rev-parse'
,
'HEAD'
])
...
...
python/paddle_serving_app/local_predict.py
浏览文件 @
b0953a3f
...
@@ -86,7 +86,8 @@ class LocalPredictor(object):
...
@@ -86,7 +86,8 @@ class LocalPredictor(object):
mkldnn_cache_capacity
=
0
,
mkldnn_cache_capacity
=
0
,
mkldnn_op_list
=
None
,
mkldnn_op_list
=
None
,
mkldnn_bf16_op_list
=
None
,
mkldnn_bf16_op_list
=
None
,
use_feed_fetch_ops
=
False
):
use_feed_fetch_ops
=
False
,
use_ascend_cl
=
False
):
"""
"""
Load model configs and create the paddle predictor by Paddle Inference API.
Load model configs and create the paddle predictor by Paddle Inference API.
...
@@ -108,6 +109,7 @@ class LocalPredictor(object):
...
@@ -108,6 +109,7 @@ class LocalPredictor(object):
mkldnn_op_list: op list accelerated using MKLDNN, None default.
mkldnn_op_list: op list accelerated using MKLDNN, None default.
mkldnn_bf16_op_list: op list accelerated using MKLDNN bf16, None default.
mkldnn_bf16_op_list: op list accelerated using MKLDNN bf16, None default.
use_feed_fetch_ops: use feed/fetch ops, False default.
use_feed_fetch_ops: use feed/fetch ops, False default.
use_ascend_cl: run predict on Huawei Ascend, False default
"""
"""
gpu_id
=
int
(
gpu_id
)
gpu_id
=
int
(
gpu_id
)
client_config
=
"{}/serving_server_conf.prototxt"
.
format
(
model_path
)
client_config
=
"{}/serving_server_conf.prototxt"
.
format
(
model_path
)
...
@@ -146,11 +148,12 @@ class LocalPredictor(object):
...
@@ -146,11 +148,12 @@ class LocalPredictor(object):
"gpu_id:{}, use_profile:{}, thread_num:{}, mem_optim:{}, ir_optim:{}, "
"gpu_id:{}, use_profile:{}, thread_num:{}, mem_optim:{}, ir_optim:{}, "
"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:{}, "
.
format
(
"mkldnn_bf16_op_list:{}, use_feed_fetch_ops:{}, "
"use_ascend_cl:{} "
.
format
(
model_path
,
use_gpu
,
gpu_id
,
use_profile
,
thread_num
,
mem_optim
,
model_path
,
use_gpu
,
gpu_id
,
use_profile
,
thread_num
,
mem_optim
,
ir_optim
,
use_trt
,
use_lite
,
use_xpu
,
precision
,
use_calib
,
ir_optim
,
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
))
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
]
...
@@ -215,11 +218,24 @@ class LocalPredictor(object):
...
@@ -215,11 +218,24 @@ class LocalPredictor(object):
zero_copy
=
True
,
zero_copy
=
True
,
passes_filter
=
[],
passes_filter
=
[],
ops_filter
=
[])
ops_filter
=
[])
config
.
switch_ir_optim
(
True
)
# set xpu
# set xpu
if
use_xpu
:
if
use_xpu
:
# 2MB l3 cache
# 2MB l3 cache
config
.
enable_xpu
(
8
*
1024
*
1024
)
config
.
enable_xpu
(
8
*
1024
*
1024
)
config
.
set_xpu_device_id
(
gpu_id
)
config
.
set_xpu_device_id
(
gpu_id
)
# set ascend cl
if
use_ascend_cl
:
if
use_lite
:
nnadapter_device_names
=
"huawei_ascend_npu"
nnadapter_context_properties
=
\
"HUAWEI_ASCEND_NPU_SELECTED_DEVICE_IDS={}"
.
format
(
gpu_id
)
nnadapter_model_cache_dir
=
""
config
.
nnadapter
()
\
.
enable
()
\
.
set_device_names
([
nnadapter_device_names
])
\
.
set_context_properties
(
nnadapter_context_properties
)
\
.
set_model_cache_dir
(
nnadapter_model_cache_dir
)
# set cpu low precision
# set cpu low precision
if
not
use_gpu
and
not
use_lite
:
if
not
use_gpu
and
not
use_lite
:
if
precision_type
==
paddle_infer
.
PrecisionType
.
Int8
:
if
precision_type
==
paddle_infer
.
PrecisionType
.
Int8
:
...
...
python/paddle_serving_server/serve.py
浏览文件 @
b0953a3f
...
@@ -181,6 +181,8 @@ def serve_args():
...
@@ -181,6 +181,8 @@ def serve_args():
"--use_lite"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Use PaddleLite"
)
"--use_lite"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Use PaddleLite"
)
parser
.
add_argument
(
parser
.
add_argument
(
"--use_xpu"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Use XPU"
)
"--use_xpu"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Use XPU"
)
parser
.
add_argument
(
"--use_ascend_cl"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Use Ascend CL"
)
parser
.
add_argument
(
parser
.
add_argument
(
"--product_name"
,
"--product_name"
,
type
=
str
,
type
=
str
,
...
@@ -272,13 +274,15 @@ def start_gpu_card_model(gpu_mode, port, args): # pylint: disable=doc-string-mi
...
@@ -272,13 +274,15 @@ def start_gpu_card_model(gpu_mode, port, args): # pylint: disable=doc-string-mi
server
.
set_device
(
device
)
server
.
set_device
(
device
)
if
args
.
use_xpu
:
if
args
.
use_xpu
:
server
.
set_xpu
()
server
.
set_xpu
()
if
args
.
use_ascend_cl
:
server
.
set_ascend_cl
()
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
:
server
.
set_container_id
(
args
.
container_id
)
server
.
set_container_id
(
args
.
container_id
)
if
gpu_mode
==
True
:
if
gpu_mode
==
True
or
args
.
use_xpu
or
args
.
use_ascend_cl
:
server
.
set_gpuid
(
args
.
gpu_ids
)
server
.
set_gpuid
(
args
.
gpu_ids
)
server
.
load_model_config
(
model
)
server
.
load_model_config
(
model
)
server
.
prepare_server
(
server
.
prepare_server
(
...
...
python/paddle_serving_server/server.py
浏览文件 @
b0953a3f
...
@@ -88,6 +88,7 @@ class Server(object):
...
@@ -88,6 +88,7 @@ class Server(object):
self
.
gpu_multi_stream
=
False
self
.
gpu_multi_stream
=
False
self
.
use_lite
=
False
self
.
use_lite
=
False
self
.
use_xpu
=
False
self
.
use_xpu
=
False
self
.
use_ascend_cl
=
False
self
.
model_config_paths
=
collections
.
OrderedDict
()
self
.
model_config_paths
=
collections
.
OrderedDict
()
self
.
product_name
=
None
self
.
product_name
=
None
self
.
container_id
=
None
self
.
container_id
=
None
...
@@ -189,6 +190,9 @@ class Server(object):
...
@@ -189,6 +190,9 @@ class Server(object):
def
set_xpu
(
self
):
def
set_xpu
(
self
):
self
.
use_xpu
=
True
self
.
use_xpu
=
True
def
set_ascend_cl
(
self
):
self
.
use_ascend_cl
=
True
def
_prepare_engine
(
self
,
model_config_paths
,
device
,
use_encryption_model
):
def
_prepare_engine
(
self
,
model_config_paths
,
device
,
use_encryption_model
):
self
.
device
=
device
self
.
device
=
device
if
self
.
model_toolkit_conf
==
None
:
if
self
.
model_toolkit_conf
==
None
:
...
@@ -202,6 +206,8 @@ class Server(object):
...
@@ -202,6 +206,8 @@ class Server(object):
if
self
.
device
==
"gpu"
or
self
.
use_trt
or
self
.
gpu_multi_stream
:
if
self
.
device
==
"gpu"
or
self
.
use_trt
or
self
.
gpu_multi_stream
:
self
.
gpuid
=
[
"0"
]
self
.
gpuid
=
[
"0"
]
self
.
device
=
"gpu"
self
.
device
=
"gpu"
elif
self
.
use_xpu
or
self
.
use_ascend_cl
:
self
.
gpuid
=
[
"0"
]
else
:
else
:
self
.
gpuid
=
[
"-1"
]
self
.
gpuid
=
[
"-1"
]
...
@@ -238,6 +244,7 @@ class Server(object):
...
@@ -238,6 +244,7 @@ class Server(object):
engine
.
gpu_multi_stream
=
self
.
gpu_multi_stream
engine
.
gpu_multi_stream
=
self
.
gpu_multi_stream
engine
.
use_lite
=
self
.
use_lite
engine
.
use_lite
=
self
.
use_lite
engine
.
use_xpu
=
self
.
use_xpu
engine
.
use_xpu
=
self
.
use_xpu
engine
.
use_ascend_cl
=
self
.
use_ascend_cl
engine
.
use_gpu
=
False
engine
.
use_gpu
=
False
if
len
(
self
.
gpuid
)
==
0
:
if
len
(
self
.
gpuid
)
==
0
:
...
@@ -437,6 +444,11 @@ class Server(object):
...
@@ -437,6 +444,11 @@ class Server(object):
device_version
=
"xpu-"
+
platform
.
machine
()
device_version
=
"xpu-"
+
platform
.
machine
()
elif
device_type
==
"3"
:
elif
device_type
==
"3"
:
device_version
=
"rocm-"
+
platform
.
machine
()
device_version
=
"rocm-"
+
platform
.
machine
()
elif
device_type
==
"4"
:
if
self
.
use_lite
:
device_version
=
"ascendcl-lite-"
+
platform
.
machine
()
else
:
device_version
=
"ascendcl-"
+
platform
.
machine
()
return
device_version
return
device_version
def
download_bin
(
self
):
def
download_bin
(
self
):
...
...
python/pipeline/local_service_handler.py
浏览文件 @
b0953a3f
...
@@ -86,6 +86,7 @@ class LocalServiceHandler(object):
...
@@ -86,6 +86,7 @@ class LocalServiceHandler(object):
self
.
_use_trt
=
False
self
.
_use_trt
=
False
self
.
_use_lite
=
False
self
.
_use_lite
=
False
self
.
_use_xpu
=
False
self
.
_use_xpu
=
False
self
.
_use_ascend_cl
=
False
self
.
_use_mkldnn
=
False
self
.
_use_mkldnn
=
False
self
.
_mkldnn_cache_capacity
=
0
self
.
_mkldnn_cache_capacity
=
0
self
.
_mkldnn_op_list
=
None
self
.
_mkldnn_op_list
=
None
...
@@ -129,6 +130,12 @@ class LocalServiceHandler(object):
...
@@ -129,6 +130,12 @@ class LocalServiceHandler(object):
devices
=
[
int
(
x
)
for
x
in
devices
.
split
(
","
)]
devices
=
[
int
(
x
)
for
x
in
devices
.
split
(
","
)]
self
.
_use_lite
=
True
self
.
_use_lite
=
True
self
.
_use_xpu
=
True
self
.
_use_xpu
=
True
elif
device_type
==
5
:
# Ascend 310 ARM CPU
self
.
_device_name
=
"arm"
devices
=
[
int
(
x
)
for
x
in
devices
.
split
(
","
)]
self
.
_use_lite
=
True
self
.
_use_ascend_cl
=
True
else
:
else
:
_LOGGER
.
error
(
_LOGGER
.
error
(
"LocalServiceHandler initialization fail. device_type={}"
"LocalServiceHandler initialization fail. device_type={}"
...
@@ -163,13 +170,14 @@ class LocalServiceHandler(object):
...
@@ -163,13 +170,14 @@ class LocalServiceHandler(object):
"mem_optim:{}, ir_optim:{}, use_profile:{}, thread_num:{}, "
"mem_optim:{}, ir_optim:{}, use_profile:{}, thread_num:{}, "
"client_type:{}, fetch_names:{}, precision:{}, use_mkldnn:{}, "
"client_type:{}, fetch_names:{}, precision:{}, use_mkldnn:{}, "
"mkldnn_cache_capacity:{}, mkldnn_op_list:{}, "
"mkldnn_cache_capacity:{}, mkldnn_op_list:{}, "
"mkldnn_bf16_op_list:{}"
.
format
(
"mkldnn_bf16_op_list:{}
, use_ascend_cl:{}
"
.
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
.
_use_lite
,
self
.
_use_xpu
,
device_type
,
self
.
_devices
,
self
.
_mem_optim
,
self
.
_ir_optim
,
self
.
_use_profile
,
self
.
_mem_optim
,
self
.
_ir_optim
,
self
.
_use_profile
,
self
.
_thread_num
,
self
.
_client_type
,
self
.
_fetch_names
,
self
.
_thread_num
,
self
.
_client_type
,
self
.
_fetch_names
,
self
.
_precision
,
self
.
_use_mkldnn
,
self
.
_mkldnn_cache_capacity
,
self
.
_precision
,
self
.
_use_mkldnn
,
self
.
_mkldnn_cache_capacity
,
self
.
_mkldnn_op_list
,
self
.
_mkldnn_bf16_op_list
))
self
.
_mkldnn_op_list
,
self
.
_mkldnn_bf16_op_list
,
self
.
_use_ascend_cl
))
def
get_fetch_list
(
self
):
def
get_fetch_list
(
self
):
return
self
.
_fetch_names
return
self
.
_fetch_names
...
@@ -225,7 +233,8 @@ class LocalServiceHandler(object):
...
@@ -225,7 +233,8 @@ class LocalServiceHandler(object):
use_mkldnn
=
self
.
_use_mkldnn
,
use_mkldnn
=
self
.
_use_mkldnn
,
mkldnn_cache_capacity
=
self
.
_mkldnn_cache_capacity
,
mkldnn_cache_capacity
=
self
.
_mkldnn_cache_capacity
,
mkldnn_op_list
=
self
.
_mkldnn_op_list
,
mkldnn_op_list
=
self
.
_mkldnn_op_list
,
mkldnn_bf16_op_list
=
self
.
_mkldnn_bf16_op_list
)
mkldnn_bf16_op_list
=
self
.
_mkldnn_bf16_op_list
,
use_ascend_cl
=
self
.
_use_ascend_cl
)
return
self
.
_local_predictor_client
return
self
.
_local_predictor_client
def
get_client_config
(
self
):
def
get_client_config
(
self
):
...
@@ -284,6 +293,8 @@ class LocalServiceHandler(object):
...
@@ -284,6 +293,8 @@ class LocalServiceHandler(object):
server
.
set_xpu
()
server
.
set_xpu
()
if
self
.
_use_lite
:
if
self
.
_use_lite
:
server
.
set_lite
()
server
.
set_lite
()
if
self
.
_use_ascend_cl
:
server
.
set_ascend_cl
()
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录