Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
558d492f
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
185
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
558d492f
编写于
1月 15, 2021
作者:
H
HexToString
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix encryption and doc
上级
0cef40a5
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
85 addition
and
10 deletion
+85
-10
CMakeLists.txt
CMakeLists.txt
+5
-0
cmake/paddlepaddle.cmake
cmake/paddlepaddle.cmake
+1
-1
doc/COMPILE.md
doc/COMPILE.md
+2
-2
doc/COMPILE_CN.md
doc/COMPILE_CN.md
+2
-2
paddle_inference/inferencer-fluid-gpu/include/fluid_gpu_engine.h
...inference/inferencer-fluid-gpu/include/fluid_gpu_engine.h
+57
-0
paddle_inference/inferencer-fluid-gpu/src/fluid_gpu_engine.cpp
...e_inference/inferencer-fluid-gpu/src/fluid_gpu_engine.cpp
+5
-0
python/paddle_serving_server_gpu/serve.py
python/paddle_serving_server_gpu/serve.py
+11
-4
python/paddle_serving_server_gpu/web_service.py
python/paddle_serving_server_gpu/web_service.py
+2
-1
未找到文件。
CMakeLists.txt
浏览文件 @
558d492f
...
...
@@ -58,7 +58,12 @@ option(APP "Compile Paddle Serving App package" OFF)
option
(
WITH_ELASTIC_CTR
"Compile ELASITC-CTR solution"
OFF
)
option
(
PACK
"Compile for whl"
OFF
)
option
(
WITH_TRT
"Compile Paddle Serving with TRT"
OFF
)
option
(
PADDLE_ON_INFERENCE
"Compile for encryption"
ON
)
if
(
PADDLE_ON_INFERENCE
)
add_definitions
(
-DPADDLE_ON_INFERENCE
)
message
(
STATUS
"Use PADDLE_ON_INFERENCE"
)
endif
()
set
(
WITH_MKLML
${
WITH_MKL
}
)
if
(
NOT DEFINED WITH_MKLDNN
)
if
(
WITH_MKL AND AVX2_FOUND
)
...
...
cmake/paddlepaddle.cmake
浏览文件 @
558d492f
...
...
@@ -124,7 +124,7 @@ LINK_DIRECTORIES(${PADDLE_INSTALL_DIR}/third_party/install/mkldnn/lib)
ADD_LIBRARY
(
openblas STATIC IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET openblas PROPERTY IMPORTED_LOCATION
${
PADDLE_INSTALL_DIR
}
/third_party/install/openblas/lib/libopenblas.a
)
ADD_LIBRARY
(
paddle_fluid S
HARED
IMPORTED GLOBAL
)
ADD_LIBRARY
(
paddle_fluid S
TATIC
IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET paddle_fluid PROPERTY IMPORTED_LOCATION
${
PADDLE_INSTALL_DIR
}
/lib/libpaddle_fluid.a
)
if
(
WITH_TRT
)
...
...
doc/COMPILE.md
浏览文件 @
558d492f
...
...
@@ -104,7 +104,7 @@ you can execute `make install` to put targets under directory `./output`, you ne
### CUDNN_LIBRARY && CUDA_CUDART_LIBRARY is the lib path, it should be /usr/local/cuda/lib64/
```
shell
export
CUDA_PATH
=
'/usr/local'
export
CUDA_PATH
=
'/usr/local
/cuda
'
export
CUDNN_LIBRARY
=
'/usr/local/cuda/lib64/'
export
CUDA_CUDART_LIBRARY
=
"/usr/local/cuda/lib64/"
...
...
@@ -123,7 +123,7 @@ make -j10
### Integrated TRT version paddle inference library
```
export CUDA_PATH='/usr/local'
export CUDA_PATH='/usr/local
/cuda
'
export CUDNN_LIBRARY='/usr/local/cuda/lib64/'
export CUDA_CUDART_LIBRARY="/usr/local/cuda/lib64/"
...
...
doc/COMPILE_CN.md
浏览文件 @
558d492f
...
...
@@ -100,7 +100,7 @@ make -j10
### CUDA_PATH是cuda的安装路径,可以使用命令行whereis cuda命令确认你的cuda安装路径,通常应该是/usr/local/cuda
### CUDNN_LIBRARY CUDA_CUDART_LIBRARY 是cuda库文件的路径,通常应该是/usr/local/cuda/lib64/
```
shell
export
CUDA_PATH
=
'/usr/local'
export
CUDA_PATH
=
'/usr/local
/cuda
'
export
CUDNN_LIBRARY
=
'/usr/local/cuda/lib64/'
export
CUDA_CUDART_LIBRARY
=
"/usr/local/cuda/lib64/"
...
...
@@ -119,7 +119,7 @@ make -j10
### 集成TensorRT版本Paddle Inference Library
```
export CUDA_PATH='/usr/local'
export CUDA_PATH='/usr/local
/cuda
'
export CUDNN_LIBRARY='/usr/local/cuda/lib64/'
export CUDA_CUDART_LIBRARY="/usr/local/cuda/lib64/"
export TENSORRT_LIBRARY_PATH="/usr/local/TensorRT-6.0.1.5/targets/x86_64-linux-gnu/"
...
...
paddle_inference/inferencer-fluid-gpu/include/fluid_gpu_engine.h
浏览文件 @
558d492f
...
...
@@ -283,6 +283,63 @@ class Parameter {
float
*
_params
;
};
class
FluidGpuAnalysisEncryptCore
:
public
FluidFamilyCore
{
public:
void
ReadBinaryFile
(
const
std
::
string
&
filename
,
std
::
string
*
contents
)
{
std
::
ifstream
fin
(
filename
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
fin
.
seekg
(
0
,
std
::
ios
::
end
);
contents
->
clear
();
contents
->
resize
(
fin
.
tellg
());
fin
.
seekg
(
0
,
std
::
ios
::
beg
);
fin
.
read
(
&
(
contents
->
at
(
0
)),
contents
->
size
());
fin
.
close
();
}
int
create
(
const
predictor
::
InferEngineCreationParams
&
params
)
{
std
::
string
data_path
=
params
.
get_path
();
if
(
access
(
data_path
.
c_str
(),
F_OK
)
==
-
1
)
{
LOG
(
ERROR
)
<<
"create paddle predictor failed, path note exits: "
<<
data_path
;
return
-
1
;
}
std
::
string
model_buffer
,
params_buffer
,
key_buffer
;
ReadBinaryFile
(
data_path
+
"encrypt_model"
,
&
model_buffer
);
ReadBinaryFile
(
data_path
+
"encrypt_params"
,
&
params_buffer
);
ReadBinaryFile
(
data_path
+
"key"
,
&
key_buffer
);
VLOG
(
2
)
<<
"prepare for encryption model"
;
auto
cipher
=
paddle
::
MakeCipher
(
""
);
std
::
string
real_model_buffer
=
cipher
->
Decrypt
(
model_buffer
,
key_buffer
);
std
::
string
real_params_buffer
=
cipher
->
Decrypt
(
params_buffer
,
key_buffer
);
Config
analysis_config
;
analysis_config
.
SetModelBuffer
(
&
real_model_buffer
[
0
],
real_model_buffer
.
size
(),
&
real_params_buffer
[
0
],
real_params_buffer
.
size
());
analysis_config
.
EnableUseGpu
(
100
,
FLAGS_gpuid
);
analysis_config
.
SetCpuMathLibraryNumThreads
(
1
);
if
(
params
.
enable_memory_optimization
())
{
analysis_config
.
EnableMemoryOptim
();
}
analysis_config
.
SwitchSpecifyInputNames
(
true
);
AutoLock
lock
(
GlobalPaddleCreateMutex
::
instance
());
VLOG
(
2
)
<<
"decrypt model file sucess"
;
_core
=
CreatePredictor
(
analysis_config
);
if
(
NULL
==
_core
.
get
())
{
LOG
(
ERROR
)
<<
"create paddle predictor failed, path: "
<<
data_path
;
return
-
1
;
}
VLOG
(
2
)
<<
"create paddle predictor sucess, path: "
<<
data_path
;
return
0
;
}
};
}
// namespace fluid_gpu
}
// namespace paddle_serving
}
// namespace baidu
paddle_inference/inferencer-fluid-gpu/src/fluid_gpu_engine.cpp
浏览文件 @
558d492f
...
...
@@ -31,6 +31,11 @@ REGIST_FACTORY_OBJECT_IMPL_WITH_NAME(
FluidGpuAnalysisDirCore
>
,
::
baidu
::
paddle_serving
::
predictor
::
InferEngine
,
"FLUID_GPU_ANALYSIS_DIR"
);
REGIST_FACTORY_OBJECT_IMPL_WITH_NAME
(
::
baidu
::
paddle_serving
::
predictor
::
FluidInferEngine
<
FluidGpuAnalysisEncryptCore
>
,
::
baidu
::
paddle_serving
::
predictor
::
InferEngine
,
"FLUID_GPU_ANALYSIS_ENCRPT"
)
}
// namespace fluid_gpu
}
// namespace paddle_serving
...
...
python/paddle_serving_server_gpu/serve.py
浏览文件 @
558d492f
...
...
@@ -21,6 +21,7 @@ import argparse
import
os
import
json
import
base64
import
time
from
multiprocessing
import
Pool
,
Process
from
paddle_serving_server_gpu
import
serve_args
from
flask
import
Flask
,
request
...
...
@@ -93,6 +94,7 @@ def start_gpu_card_model(index, gpuid, port, args): # pylint: disable=doc-strin
server
.
set_gpuid
(
gpuid
)
server
.
run_server
()
def
start_multi_card
(
args
,
serving_port
=
None
):
# pylint: disable=doc-string-missing
gpus
=
""
if
serving_port
==
None
:
...
...
@@ -121,11 +123,11 @@ def start_multi_card(args, serving_port=None): # pylint: disable=doc-string-mis
gpu_processes
=
[]
for
i
,
gpu_id
in
enumerate
(
gpus
):
p
=
Process
(
target
=
start_gpu_card_model
,
target
=
start_gpu_card_model
,
args
=
(
i
,
gpu_id
,
serving_port
,
serving_port
,
args
,
))
gpu_processes
.
append
(
p
)
for
p
in
gpu_processes
:
...
...
@@ -133,6 +135,7 @@ def start_multi_card(args, serving_port=None): # pylint: disable=doc-string-mis
for
p
in
gpu_processes
:
p
.
join
()
class
MainService
(
BaseHTTPRequestHandler
):
def
get_available_port
(
self
):
default_port
=
12000
...
...
@@ -227,8 +230,12 @@ if __name__ == "__main__":
if
len
(
gpu_ids
)
>
0
:
web_service
.
set_gpus
(
gpu_ids
)
web_service
.
prepare_server
(
workdir
=
args
.
workdir
,
port
=
args
.
port
,
device
=
args
.
device
,
use_lite
=
args
.
use_lite
,
use_xpu
=
args
.
use_xpu
,
ir_optim
=
args
.
ir_optim
)
workdir
=
args
.
workdir
,
port
=
args
.
port
,
device
=
args
.
device
,
use_lite
=
args
.
use_lite
,
use_xpu
=
args
.
use_xpu
,
ir_optim
=
args
.
ir_optim
)
web_service
.
run_rpc_service
()
app_instance
=
Flask
(
__name__
)
...
...
python/paddle_serving_server_gpu/web_service.py
浏览文件 @
558d492f
...
...
@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!flask/bin/python
# pylint: disable=doc-string-missing
from
flask
import
Flask
,
request
,
abort
...
...
@@ -158,7 +159,7 @@ class WebService(object):
self
.
port_list
=
[]
default_port
=
12000
for
i
in
range
(
1000
):
if
port_is_available
(
default_port
+
i
):
if
port_is_available
(
default_port
+
i
):
self
.
port_list
.
append
(
default_port
+
i
)
if
len
(
self
.
port_list
)
>
len
(
self
.
gpus
):
break
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录