Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
b4c83b9e
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看板
提交
b4c83b9e
编写于
8月 12, 2020
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
for compile
上级
3cdad373
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
68 addition
and
22 deletion
+68
-22
cmake/paddlepaddle.cmake
cmake/paddlepaddle.cmake
+38
-19
core/general-server/CMakeLists.txt
core/general-server/CMakeLists.txt
+5
-1
core/predictor/framework/infer.h
core/predictor/framework/infer.h
+10
-0
paddle_inference/inferencer-fluid-gpu/CMakeLists.txt
paddle_inference/inferencer-fluid-gpu/CMakeLists.txt
+1
-0
paddle_inference/inferencer-fluid-gpu/include/fluid_gpu_engine.h
...inference/inferencer-fluid-gpu/include/fluid_gpu_engine.h
+14
-2
未找到文件。
cmake/paddlepaddle.cmake
浏览文件 @
b4c83b9e
...
...
@@ -31,13 +31,14 @@ message( "WITH_GPU = ${WITH_GPU}")
# Paddle Version should be one of:
# latest: latest develop build
# version number like 1.5.2
SET
(
PADDLE_VERSION
"1.8.
1
"
)
SET
(
PADDLE_VERSION
"1.8.
3
"
)
if
(
WITH_GPU
)
if
(
WITH_TRT
)
SET
(
PADDLE_LIB_VERSION
"
${
PADDLE_VERSION
}
-gpu-cuda10.1-cudnn7.6-avx-mkl-trt6"
)
else
()
SET
(
PADDLE_LIB_VERSION
"
${
PADDLE_VERSION
}
-gpu-cuda10-cudnn7-avx-mkl"
)
endif
()
else
()
if
(
WITH_AVX
)
if
(
WITH_MKLML
)
...
...
@@ -53,21 +54,38 @@ endif()
SET
(
PADDLE_LIB_PATH
"http://paddle-inference-lib.bj.bcebos.com/
${
PADDLE_LIB_VERSION
}
/fluid_inference.tgz"
)
MESSAGE
(
STATUS
"PADDLE_LIB_PATH=
${
PADDLE_LIB_PATH
}
"
)
if
(
WITH_GPU OR WITH_MKLML
)
ExternalProject_Add
(
"extern_paddle"
${
EXTERNAL_PROJECT_LOG_ARGS
}
URL
"
${
PADDLE_LIB_PATH
}
"
PREFIX
"
${
PADDLE_SOURCES_DIR
}
"
DOWNLOAD_DIR
"
${
PADDLE_DOWNLOAD_DIR
}
"
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
UPDATE_COMMAND
""
INSTALL_COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/paddle/include
${
PADDLE_INSTALL_DIR
}
/include &&
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/paddle/lib
${
PADDLE_INSTALL_DIR
}
/lib &&
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/third_party
${
PADDLE_INSTALL_DIR
}
/third_party &&
${
CMAKE_COMMAND
}
-E copy
${
PADDLE_INSTALL_DIR
}
/third_party/install/mkldnn/lib/libmkldnn.so.0
${
PADDLE_INSTALL_DIR
}
/third_party/install/mkldnn/lib/libmkldnn.so
)
if
(
WITH_TRT
)
ExternalProject_Add
(
"extern_paddle"
${
EXTERNAL_PROJECT_LOG_ARGS
}
URL
"
${
PADDLE_LIB_PATH
}
"
PREFIX
"
${
PADDLE_SOURCES_DIR
}
"
DOWNLOAD_DIR
"
${
PADDLE_DOWNLOAD_DIR
}
"
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
UPDATE_COMMAND
""
INSTALL_COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/paddle/include
${
PADDLE_INSTALL_DIR
}
/include &&
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/paddle/lib
${
PADDLE_INSTALL_DIR
}
/lib &&
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/third_party
${
PADDLE_INSTALL_DIR
}
/third_party
)
else
()
ExternalProject_Add
(
"extern_paddle"
${
EXTERNAL_PROJECT_LOG_ARGS
}
URL
"
${
PADDLE_LIB_PATH
}
"
PREFIX
"
${
PADDLE_SOURCES_DIR
}
"
DOWNLOAD_DIR
"
${
PADDLE_DOWNLOAD_DIR
}
"
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
UPDATE_COMMAND
""
INSTALL_COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/paddle/include
${
PADDLE_INSTALL_DIR
}
/include &&
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/paddle/lib
${
PADDLE_INSTALL_DIR
}
/lib &&
${
CMAKE_COMMAND
}
-E copy_directory
${
PADDLE_DOWNLOAD_DIR
}
/third_party
${
PADDLE_INSTALL_DIR
}
/third_party &&
${
CMAKE_COMMAND
}
-E copy
${
PADDLE_INSTALL_DIR
}
/third_party/install/mkldnn/lib/libmkldnn.so.0
${
PADDLE_INSTALL_DIR
}
/third_party/install/mkldnn/lib/libmkldnn.so
)
endif
()
else
()
ExternalProject_Add
(
"extern_paddle"
...
...
@@ -98,12 +116,13 @@ SET_PROPERTY(TARGET openblas PROPERTY IMPORTED_LOCATION ${PADDLE_INSTALL_DIR}/th
ADD_LIBRARY
(
paddle_fluid SHARED IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET paddle_fluid PROPERTY IMPORTED_LOCATION
${
PADDLE_INSTALL_DIR
}
/lib/libpaddle_fluid.so
)
if
(
WITH_TRT
)
ADD_LIBRARY
(
nvinfer SHARED IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET nvinfer PROPERTY IMPORTED_LOCATION
/paddle/third_party/TensorRT-6.0.1.5
/lib/libnvinfer.so
)
SET_PROPERTY
(
TARGET nvinfer PROPERTY IMPORTED_LOCATION
${
TENSORRT_ROOT
}
/lib/libnvinfer.so
)
ADD_LIBRARY
(
nvinfer_plugin SHARED IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET nvinfer_plugin PROPERTY IMPORTED_LOCATION
/paddle/third_party/TensorRT-6.0.1.5
/lib/libnvinfer_plugin.so
)
SET_PROPERTY
(
TARGET nvinfer_plugin PROPERTY IMPORTED_LOCATION
${
TENSORRT_ROOT
}
/lib/libnvinfer_plugin.so
)
endif
()
ADD_LIBRARY
(
xxhash STATIC IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET xxhash PROPERTY IMPORTED_LOCATION
${
PADDLE_INSTALL_DIR
}
/third_party/install/xxhash/lib/libxxhash.a
)
...
...
core/general-server/CMakeLists.txt
浏览文件 @
b4c83b9e
...
...
@@ -9,7 +9,7 @@ endif()
target_include_directories
(
serving PUBLIC
${
CMAKE_CURRENT_BINARY_DIR
}
/../../core/predictor
)
include_directories
(
${
CUDNN_ROOT
}
/include/
)
if
(
WITH_GPU
)
target_link_libraries
(
serving -Wl,--whole-archive fluid_gpu_engine
-Wl,--no-whole-archive
)
...
...
@@ -29,7 +29,11 @@ if(WITH_GPU)
endif
()
if
(
WITH_MKL OR WITH_GPU
)
if
(
WITH_TRT
)
target_link_libraries
(
serving -liomp5 -lmklml_intel -lpthread -lcrypto -lm -lrt -lssl -ldl -lz -lbz2
)
else
()
target_link_libraries
(
serving -liomp5 -lmklml_intel -lmkldnn -lpthread -lcrypto -lm -lrt -lssl -ldl -lz -lbz2
)
endif
()
else
()
target_link_libraries
(
serving openblas -lpthread -lcrypto -lm -lrt -lssl -ldl -lz -lbz2
)
endif
()
...
...
core/predictor/framework/infer.h
浏览文件 @
b4c83b9e
...
...
@@ -38,6 +38,7 @@ class InferEngineCreationParams {
_enable_ir_optimization
=
false
;
_static_optimization
=
false
;
_force_update_static_cache
=
false
;
_use_trt
=
false
;
}
void
set_path
(
const
std
::
string
&
path
)
{
_path
=
path
;
}
...
...
@@ -50,12 +51,16 @@ class InferEngineCreationParams {
_enable_ir_optimization
=
enable_ir_optimization
;
}
void
set_use_trt
(
bool
use_trt
)
{
_use_trt
=
use_trt
;
}
bool
enable_memory_optimization
()
const
{
return
_enable_memory_optimization
;
}
bool
enable_ir_optimization
()
const
{
return
_enable_ir_optimization
;
}
bool
use_trt
()
const
{
return
_use_trt
;
}
void
set_static_optimization
(
bool
static_optimization
=
false
)
{
_static_optimization
=
static_optimization
;
}
...
...
@@ -86,6 +91,7 @@ class InferEngineCreationParams {
bool
_enable_ir_optimization
;
bool
_static_optimization
;
bool
_force_update_static_cache
;
bool
_use_trt
;
};
class
InferEngine
{
...
...
@@ -172,6 +178,10 @@ class ReloadableInferEngine : public InferEngine {
force_update_static_cache
);
}
if
(
conf
.
has_use_trt
())
{
_infer_engine_params
.
set_use_trt
(
conf
.
use_trt
());
}
if
(
!
check_need_reload
()
||
load
(
_infer_engine_params
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Failed load model_data_path"
<<
_model_data_path
;
return
-
1
;
...
...
paddle_inference/inferencer-fluid-gpu/CMakeLists.txt
浏览文件 @
b4c83b9e
...
...
@@ -2,6 +2,7 @@ FILE(GLOB fluid_gpu_engine_srcs ${CMAKE_CURRENT_LIST_DIR}/src/*.cpp)
add_library
(
fluid_gpu_engine
${
fluid_gpu_engine_srcs
}
)
target_include_directories
(
fluid_gpu_engine PUBLIC
${
CMAKE_BINARY_DIR
}
/Paddle/fluid_install_dir/
)
add_dependencies
(
fluid_gpu_engine pdserving extern_paddle configure
)
target_link_libraries
(
fluid_gpu_engine pdserving paddle_fluid iomp5 mklml_intel -lpthread -lcrypto -lm -lrt -lssl -ldl -lz
)
...
...
paddle_inference/inferencer-fluid-gpu/include/fluid_gpu_engine.h
浏览文件 @
b4c83b9e
...
...
@@ -178,7 +178,7 @@ class FluidGpuNativeCore : public FluidFamilyCore {
}
};
class
Fluid
TRT
AnalysisDirCore
:
public
FluidFamilyCore
{
class
Fluid
Gpu
AnalysisDirCore
:
public
FluidFamilyCore
{
public:
int
create
(
const
predictor
::
InferEngineCreationParams
&
params
)
{
std
::
string
data_path
=
params
.
get_path
();
...
...
@@ -238,14 +238,26 @@ class FluidTRTAnalysisDirCore : public FluidFamilyCore {
analysis_config.SetTRTDynamicShapeInfo(
min_input_shape, max_input_shape, opt_input_shape);
#endif
int
batch
=
8
;
int
min_subgraph_size
=
3
;
if
(
params
.
use_trt
())
{
analysis_config
.
EnableTensorRtEngine
(
1
<<
30
,
batch
,
5
,
min_subgraph_size
,
paddle
::
AnalysisConfig
::
Precision
::
kFloat32
,
true
,
true
);
}
else
{
if
(
params
.
enable_memory_optimization
())
{
analysis_config
.
EnableMemoryOptim
();
}
if
(
params
.
enable_ir_optimization
())
{
analysis_config
.
SwitchIrOptim
(
true
);
}
else
{
analysis_config
.
SwitchIrOptim
(
false
);
}
}
AutoLock
lock
(
GlobalPaddleCreateMutex
::
instance
());
_core
=
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录