Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
36508885
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看板
提交
36508885
编写于
12月 07, 2020
作者:
T
TeslaZhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Predicting on multi-devices in local predictor
上级
4d6feecc
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
22 addition
and
6 deletion
+22
-6
python/pipeline/local_service_handler.py
python/pipeline/local_service_handler.py
+19
-4
python/pipeline/operator.py
python/pipeline/operator.py
+3
-2
未找到文件。
python/pipeline/local_service_handler.py
浏览文件 @
36508885
...
...
@@ -105,18 +105,33 @@ class LocalServiceHandler(object):
def
get_port_list
(
self
):
return
self
.
_port_list
def
get_client
(
self
):
def
get_client
(
self
,
concurrency_idx
):
"""
Function get_client is only used for local predictor case, creates one
LocalPredictor object, and initializes the paddle predictor by function
load_model_config.
load_model_config.
The concurrency_idx is used to select running devices.
Args:
None
concurrency_idx: process/thread index
Returns:
_local_predictor_client
"""
#checking the legality of concurrency_idx.
device_num
=
len
(
self
.
_devices
)
if
device_num
<=
0
:
_LOGGER
.
error
(
"device_num must be not greater than 0. devices({})"
.
format
(
self
.
_devices
))
raise
ValueError
(
"The number of self._devices error"
)
if
concurrency_idx
<=
0
:
_LOGGER
.
error
(
"concurrency_idx({}) must be one positive number"
.
format
(
concurrency_idx
))
concurrency_idx
=
0
elif
concurrency_idx
>=
device_num
:
concurrency_idx
=
concurrency_idx
%
device_num
from
paddle_serving_app.local_predict
import
LocalPredictor
if
self
.
_local_predictor_client
is
None
:
self
.
_local_predictor_client
=
LocalPredictor
()
...
...
@@ -126,7 +141,7 @@ class LocalServiceHandler(object):
self
.
_local_predictor_client
.
load_model_config
(
model_path
=
self
.
_model_config
,
use_gpu
=
use_gpu
,
gpu_id
=
self
.
_devices
[
0
],
gpu_id
=
self
.
_devices
[
concurrency_idx
],
use_profile
=
self
.
_use_profile
,
thread_num
=
self
.
_thread_num
,
mem_optim
=
self
.
_mem_optim
,
...
...
python/pipeline/operator.py
浏览文件 @
36508885
...
...
@@ -574,7 +574,7 @@ class Op(object):
#Init cuda env in main thread
if
self
.
client_type
==
"local_predictor"
:
_LOGGER
.
info
(
"Init cuda env in main thread"
)
self
.
local_predictor
=
self
.
_local_service_handler
.
get_client
()
self
.
local_predictor
=
self
.
_local_service_handler
.
get_client
(
0
)
threads
=
[]
for
concurrency_idx
in
range
(
self
.
concurrency
):
...
...
@@ -1034,7 +1034,8 @@ class Op(object):
_LOGGER
.
info
(
"Init cuda env in process {}"
.
format
(
concurrency_idx
))
self
.
local_predictor
=
self
.
service_handler
.
get_client
()
self
.
local_predictor
=
self
.
service_handler
.
get_client
(
concurrency_idx
)
# check all ops initialized successfully.
profiler
=
self
.
_initialize
(
is_thread_op
,
concurrency_idx
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录