Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
c3c195b6
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看板
提交
c3c195b6
编写于
8月 15, 2021
作者:
J
Jiawei Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix rpc port
上级
edf67e4b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
12 deletion
+29
-12
python/examples/encryption/test_client.py
python/examples/encryption/test_client.py
+2
-2
python/paddle_serving_server/serve.py
python/paddle_serving_server/serve.py
+9
-2
python/paddle_serving_server/server.py
python/paddle_serving_server/server.py
+18
-8
未找到文件。
python/examples/encryption/test_client.py
浏览文件 @
c3c195b6
...
...
@@ -28,5 +28,5 @@ test_reader = paddle.batch(
batch_size
=
1
)
for
data
in
test_reader
():
fetch_map
=
client
.
predict
(
feed
=
{
"x"
:
data
[
0
][
0
]},
fetch
=
[
"
price
"
])
print
(
"{} {}"
.
format
(
fetch_map
[
"
price
"
][
0
],
data
[
0
][
1
][
0
]))
fetch_map
=
client
.
predict
(
feed
=
{
"x"
:
data
[
0
][
0
]},
fetch
=
[
"
save_infer_model/scale_0
"
])
print
(
"{} {}"
.
format
(
fetch_map
[
"
save_infer_model/scale_0
"
][
0
],
data
[
0
][
1
][
0
]))
python/paddle_serving_server/serve.py
浏览文件 @
c3c195b6
...
...
@@ -61,6 +61,8 @@ def serve_args():
default
=
False
,
action
=
"store_true"
,
help
=
"Use TensorRT Calibration"
)
parser
.
add_argument
(
"--encryption_rpc_port"
,
type
=
int
,
required
=
False
,
default
=
9292
,
help
=
"Port of encryption model, only valid for arg.use_encryption_model"
)
parser
.
add_argument
(
"--mem_optim_off"
,
default
=
False
,
...
...
@@ -114,6 +116,7 @@ def start_standard_model(serving_port): # pylint: disable=doc-string-missing
max_body_size
=
args
.
max_body_size
use_mkl
=
args
.
use_mkl
use_encryption_model
=
args
.
use_encryption_model
encryption_rpc_port
=
args
.
encryption_rpc_port
use_multilang
=
args
.
use_multilang
if
model
==
""
:
...
...
@@ -160,6 +163,7 @@ def start_standard_model(serving_port): # pylint: disable=doc-string-missing
server
.
set_precision
(
args
.
precision
)
server
.
set_use_calib
(
args
.
use_calib
)
server
.
use_encryption_model
(
use_encryption_model
)
server
.
encryption_rpc_port
(
encryption_rpc_port
)
if
args
.
product_name
!=
None
:
server
.
set_product_name
(
args
.
product_name
)
if
args
.
container_id
!=
None
:
...
...
@@ -246,7 +250,8 @@ def start_gpu_card_model(index, gpuid, port, args): # pylint: disable=doc-strin
workdir
=
workdir
,
port
=
port
,
device
=
device
,
use_encryption_model
=
args
.
use_encryption_model
)
use_encryption_model
=
args
.
use_encryption_model
,
encryption_rpc_port
=
args
.
encryption_rpc_port
)
if
gpuid
>=
0
:
server
.
set_gpuid
(
gpuid
)
server
.
run_server
()
...
...
@@ -293,7 +298,8 @@ def start_multi_card(args, serving_port=None): # pylint: disable=doc-string-mis
class
MainService
(
BaseHTTPRequestHandler
):
def
get_available_port
(
self
):
default_port
=
12000
global
encryption_rpc_port
default_port
=
encryption_rpc_port
for
i
in
range
(
1000
):
if
port_is_available
(
default_port
+
i
):
return
default_port
+
i
...
...
@@ -381,6 +387,7 @@ if __name__ == "__main__":
if
args
.
name
==
"None"
:
from
.web_service
import
port_is_available
if
args
.
use_encryption_model
:
encryption_rpc_port
=
args
.
encryption_rpc_port
p_flag
=
False
p
=
None
serving_port
=
0
...
...
python/paddle_serving_server/server.py
浏览文件 @
c3c195b6
...
...
@@ -430,6 +430,7 @@ class Server(object):
port
=
9292
,
device
=
"cpu"
,
use_encryption_model
=
False
,
encryption_rpc_port
=
9293
,
cube_conf
=
None
):
if
workdir
==
None
:
workdir
=
"./tmp"
...
...
@@ -442,7 +443,7 @@ class Server(object):
if
not
self
.
port_is_available
(
port
):
raise
SystemExit
(
"Port {} is already used"
.
format
(
port
))
print
(
"set brpc port here: {}"
.
format
(
port
))
self
.
set_port
(
port
)
self
.
_prepare_resource
(
workdir
,
cube_conf
)
self
.
_prepare_engine
(
self
.
model_config_paths
,
device
,
...
...
@@ -588,6 +589,9 @@ class MultiLangServer(object):
def
use_encryption_model
(
self
,
flag
=
False
):
self
.
encryption_model
=
flag
def
encryption_rpc_port
(
self
,
port
=
9293
):
self
.
encryption_rpc_port
=
port
def
set_port
(
self
,
port
):
self
.
gport_
=
port
...
...
@@ -673,16 +677,22 @@ class MultiLangServer(object):
port
=
9292
,
device
=
"cpu"
,
use_encryption_model
=
False
,
encryption_rpc_port
=
9293
,
cube_conf
=
None
):
if
not
self
.
_port_is_available
(
port
):
raise
SystemExit
(
"Port {} is already used"
.
format
(
port
))
default_port
=
12000
self
.
port_list_
=
[]
for
i
in
range
(
1000
):
if
default_port
+
i
!=
port
and
self
.
_port_is_available
(
default_port
+
i
):
self
.
port_list_
.
append
(
default_port
+
i
)
break
if
use_encryption_model
is
True
and
self
.
_port_is_available
(
encryption_rpc_port
)
is
False
:
raise
SystemExit
(
"Encryption Rpc Port {} is already used"
.
format
(
encryption_rpc_port
))
if
use_encryption_model
is
False
:
default_port
=
12000
self
.
port_list_
=
[]
for
i
in
range
(
1000
):
if
default_port
+
i
!=
port
and
self
.
_port_is_available
(
default_port
+
i
):
self
.
port_list_
.
append
(
default_port
+
i
)
break
else
:
self
.
port_list_
=
[]
self
.
port_list_
.
append
(
encryption_rpc_port
)
self
.
bserver_
.
prepare_server
(
workdir
=
workdir
,
port
=
self
.
port_list_
[
0
],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录