Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
ff5fd3cd
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看板
提交
ff5fd3cd
编写于
2月 03, 2020
作者:
G
guru4elephant
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make serving runable
上级
637f710f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
8 deletion
+24
-8
python/paddle_serving/serving_server/__init__.py
python/paddle_serving/serving_server/__init__.py
+24
-8
未找到文件。
python/paddle_serving/serving_server/__init__.py
浏览文件 @
ff5fd3cd
...
...
@@ -12,15 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
from
..proto
import
server_configure_pb2
as
server_sdk
class
OpMaker
(
object
):
def
__init__
(
self
):
self
.
op_dict
=
{
"general_
model"
:
"GeneralModel
Op"
,
self
.
op_dict
=
{
"general_
infer"
:
"GeneralInfer
Op"
,
"general_reader"
:
"GeneralReaderOp"
,
"general_single_kv"
:
"GeneralSingleKVOp"
,
"general_dist_kv"
:
"GeneralDistKVOp"
}
# currently, inputs and outputs are not used
# when we have OpGraphMaker, inputs and outputs are necessary
def
create
(
self
,
name
,
inputs
=
[],
outputs
=
[]):
if
name
not
in
self
.
op_dict
:
raise
Exception
(
"Op name {} is not supported right now"
.
format
(
name
))
...
...
@@ -36,6 +39,11 @@ class OpSeqMaker(object):
self
.
workflow
.
workflow_type
=
"Sequence"
def
add_op
(
self
,
node
):
if
len
(
self
.
workflow
.
nodes
)
>=
1
:
dep
=
server_sdk
.
DAGNodeDependency
()
dep
.
name
=
self
.
workflow
.
nodes
[
-
1
].
name
dep
.
mode
=
"RO"
node
.
dependencies
.
extend
([
dep
])
self
.
workflow
.
nodes
.
extend
([
node
])
def
get_op_sequence
(
self
):
...
...
@@ -48,6 +56,7 @@ class Server(object):
self
.
server_handle_
=
None
self
.
infer_service_conf
=
None
self
.
model_toolkit_conf
=
None
self
.
resource_conf
=
None
self
.
engine
=
None
self
.
workflow_fn
=
"workflow.prototxt"
self
.
resource_fn
=
"resource.prototxt"
...
...
@@ -80,16 +89,20 @@ class Server(object):
if
self
.
engine
==
None
:
self
.
engine
=
server_sdk
.
EngineDesc
()
self
.
engine
.
name
=
"general_model"
self
.
engine
.
reloadable_type
=
"tiemstamp_ne"
self
.
engine
.
reloadable_meta
=
model_config_path
+
"/fluid_time_file"
self
.
engine
.
reloadable_type
=
"timestamp_ne"
self
.
engine
.
runtime_thread_num
=
0
self
.
engine
.
batch_infer_size
=
0
self
.
engine
.
enable_batch_align
=
0
self
.
engine
.
model_data_path
=
model_path
self
.
engine
.
model_data_path
=
model_config_path
self
.
engine
.
enable_memory_optimization
=
True
self
.
engine
.
static_optimization
=
False
self
.
engine
.
force_update_static_cache
=
False
if
device
==
"cpu"
:
self
.
engine
.
type
=
"FLUID_CPU_ANALYSIS_DIR"
elif
device
==
"gpu"
:
self
.
engine
.
type
=
"FLUID_GPU_ANALYSIS_DIR"
self
.
model_toolkit_conf
.
engines
.
extend
([
engine
])
self
.
model_toolkit_conf
.
engines
.
extend
([
self
.
engine
])
def
_prepare_infer_service
(
self
,
port
):
if
self
.
infer_service_conf
==
None
:
...
...
@@ -104,7 +117,7 @@ class Server(object):
if
self
.
resource_conf
==
None
:
self
.
resource_conf
=
server_sdk
.
ResourceConf
()
self
.
resource_conf
.
model_toolkit_path
=
workdir
self
.
resource_conf
.
model_toolkit_file
=
"server_model_toolkit.prototxt"
self
.
resource_conf
.
model_toolkit_file
=
self
.
model_toolkit_fn
def
_write_pb_str
(
self
,
filepath
,
pb_obj
):
with
open
(
filepath
,
"w"
)
as
fout
:
...
...
@@ -112,17 +125,19 @@ class Server(object):
def
load_model_config
(
self
,
path
):
self
.
config_file
=
"{}/inference.conf"
.
format
(
path
)
self
.
model_config_path
=
path
# check config here
def
prepare_server
(
self
,
port
=
9292
,
device
=
"cpu"
,
workdir
=
None
):
def
prepare_server
(
self
,
workdir
=
None
,
port
=
9292
,
device
=
"cpu"
):
if
workdir
==
None
:
workdir
=
"./tmp"
os
.
system
(
"mkdir {}"
.
format
(
workdir
))
else
:
os
.
system
(
"mkdir {}"
.
format
(
workdir
))
os
.
system
(
"touch {}/fluid_time_file"
.
format
(
workdir
))
self
.
_prepare_resource
(
workdir
)
self
.
_prepare_engine
(
self
.
config_file
,
device
)
self
.
_prepare_engine
(
self
.
model_config_path
,
device
)
self
.
_prepare_infer_service
(
port
)
self
.
workdir
=
workdir
...
...
@@ -139,7 +154,8 @@ class Server(object):
def
run_server
(
self
):
# just run server with system command
# currently we do not load cube
command
=
"./pdserving -enable_model_toolkit "
\
command
=
"/home/users/dongdaxiang/github_develop/Serving/examples/demo-serving/serving"
\
" -enable_model_toolkit "
\
"-inferservice_path {} "
\
"-inferservice_file {} "
\
"-max_concurrency {} "
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录