Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
311a3cd5
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看板
提交
311a3cd5
编写于
3月 16, 2020
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
差异文件
fix conflict
上级
a4a5704a
37a039ea
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
52 addition
and
15 deletion
+52
-15
doc/demo.gif
doc/demo.gif
+0
-0
python/examples/bert/benchmark.py
python/examples/bert/benchmark.py
+0
-2
python/examples/bert/benchmark_batch.py
python/examples/bert/benchmark_batch.py
+0
-3
python/examples/bert/bert_client.py
python/examples/bert/bert_client.py
+40
-0
python/paddle_serving_server/__init__.py
python/paddle_serving_server/__init__.py
+1
-1
python/paddle_serving_server/web_service.py
python/paddle_serving_server/web_service.py
+1
-1
python/paddle_serving_server_gpu/__init__.py
python/paddle_serving_server_gpu/__init__.py
+1
-1
python/paddle_serving_server_gpu/serve.py
python/paddle_serving_server_gpu/serve.py
+6
-4
python/paddle_serving_server_gpu/web_service.py
python/paddle_serving_server_gpu/web_service.py
+1
-1
tools/cpp_examples/bert-gpu-serving/paddle-gpu-serving/paddle_gpu_serving/run/__init__.py
...ing/paddle-gpu-serving/paddle_gpu_serving/run/__init__.py
+2
-2
未找到文件。
doc/demo.gif
查看替换文件 @
a4a5704a
浏览文件 @
311a3cd5
270.6 KB
|
W:
|
H:
418.8 KB
|
W:
|
H:
2-up
Swipe
Onion skin
python/examples/bert/benchmark.py
浏览文件 @
311a3cd5
...
@@ -68,10 +68,8 @@ def single_func(idx, resource):
...
@@ -68,10 +68,8 @@ def single_func(idx, resource):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
multi_thread_runner
=
MultiThreadRunner
()
multi_thread_runner
=
MultiThreadRunner
()
endpoint_list
=
[
"127.0.0.1:9292"
]
endpoint_list
=
[
"127.0.0.1:9292"
]
#endpoint_list = endpoint_list + endpoint_list + endpoint_list
result
=
multi_thread_runner
.
run
(
single_func
,
args
.
thread
,
result
=
multi_thread_runner
.
run
(
single_func
,
args
.
thread
,
{
"endpoint"
:
endpoint_list
})
{
"endpoint"
:
endpoint_list
})
#result = single_func(0, {"endpoint": endpoint_list})
avg_cost
=
0
avg_cost
=
0
for
i
in
range
(
args
.
thread
):
for
i
in
range
(
args
.
thread
):
avg_cost
+=
result
[
0
][
i
]
avg_cost
+=
result
[
0
][
i
]
...
...
python/examples/bert/benchmark_batch.py
浏览文件 @
311a3cd5
...
@@ -27,7 +27,6 @@ import tokenization
...
@@ -27,7 +27,6 @@ import tokenization
import
requests
import
requests
import
json
import
json
from
bert_reader
import
BertReader
from
bert_reader
import
BertReader
args
=
benchmark_args
()
args
=
benchmark_args
()
...
@@ -63,10 +62,8 @@ def single_func(idx, resource):
...
@@ -63,10 +62,8 @@ def single_func(idx, resource):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
multi_thread_runner
=
MultiThreadRunner
()
multi_thread_runner
=
MultiThreadRunner
()
endpoint_list
=
[
"127.0.0.1:9292"
]
endpoint_list
=
[
"127.0.0.1:9292"
]
#endpoint_list = endpoint_list + endpoint_list + endpoint_list
result
=
multi_thread_runner
.
run
(
single_func
,
args
.
thread
,
result
=
multi_thread_runner
.
run
(
single_func
,
args
.
thread
,
{
"endpoint"
:
endpoint_list
})
{
"endpoint"
:
endpoint_list
})
#result = single_func(0, {"endpoint": endpoint_list})
avg_cost
=
0
avg_cost
=
0
for
i
in
range
(
args
.
thread
):
for
i
in
range
(
args
.
thread
):
avg_cost
+=
result
[
0
][
i
]
avg_cost
+=
result
[
0
][
i
]
...
...
python/examples/bert/bert_client.py
0 → 100644
浏览文件 @
311a3cd5
# coding:utf-8
# pylint: disable=doc-string-missing
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
import
os
import
sys
import
numpy
as
np
import
paddlehub
as
hub
import
ujson
import
random
import
time
from
paddlehub.common.logger
import
logger
import
socket
from
paddle_serving_client
import
Client
from
paddle_serving_client.utils
import
benchmark_args
args
=
benchmark_args
()
fin
=
open
(
"data-c.txt"
)
reader
=
BertReader
(
vocab_file
=
"vocab.txt"
,
max_seq_len
=
128
)
fetch
=
[
"pooled_output"
]
endpoint_list
=
[
"127.0.0.1:9494"
]
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
(
endpoint_list
)
for
line
in
fin
:
feed_dict
=
reader
.
process
(
line
)
result
=
client
.
predict
(
feed
=
feed_dict
,
fetch
=
fetch
)
python/paddle_serving_server/__init__.py
浏览文件 @
311a3cd5
...
@@ -256,7 +256,7 @@ class Server(object):
...
@@ -256,7 +256,7 @@ class Server(object):
def
port_is_available
(
self
,
port
):
def
port_is_available
(
self
,
port
):
with
closing
(
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
))
as
sock
:
with
closing
(
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
))
as
sock
:
sock
.
settimeout
(
2
)
sock
.
settimeout
(
2
)
result
=
sock
.
connect_ex
((
'
127.0.0.1
'
,
port
))
result
=
sock
.
connect_ex
((
'
0.0.0.0
'
,
port
))
if
result
!=
0
:
if
result
!=
0
:
return
True
return
True
else
:
else
:
...
...
python/paddle_serving_server/web_service.py
浏览文件 @
311a3cd5
...
@@ -54,7 +54,7 @@ class WebService(object):
...
@@ -54,7 +54,7 @@ class WebService(object):
client_service
=
Client
()
client_service
=
Client
()
client_service
.
load_client_config
(
client_service
.
load_client_config
(
"{}/serving_server_conf.prototxt"
.
format
(
self
.
model_config
))
"{}/serving_server_conf.prototxt"
.
format
(
self
.
model_config
))
client_service
.
connect
([
"
127.0.0.1
:{}"
.
format
(
self
.
port
+
1
)])
client_service
.
connect
([
"
0.0.0.0
:{}"
.
format
(
self
.
port
+
1
)])
service_name
=
"/"
+
self
.
name
+
"/prediction"
service_name
=
"/"
+
self
.
name
+
"/prediction"
@
app_instance
.
route
(
service_name
,
methods
=
[
'POST'
])
@
app_instance
.
route
(
service_name
,
methods
=
[
'POST'
])
...
...
python/paddle_serving_server_gpu/__init__.py
浏览文件 @
311a3cd5
...
@@ -266,7 +266,7 @@ class Server(object):
...
@@ -266,7 +266,7 @@ class Server(object):
def
port_is_available
(
self
,
port
):
def
port_is_available
(
self
,
port
):
with
closing
(
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
))
as
sock
:
with
closing
(
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
))
as
sock
:
sock
.
settimeout
(
2
)
sock
.
settimeout
(
2
)
result
=
sock
.
connect_ex
((
'
127.0.0.1
'
,
port
))
result
=
sock
.
connect_ex
((
'
0.0.0.0
'
,
port
))
if
result
!=
0
:
if
result
!=
0
:
return
True
return
True
else
:
else
:
...
...
python/paddle_serving_server_gpu/serve.py
浏览文件 @
311a3cd5
...
@@ -17,8 +17,8 @@ Usage:
...
@@ -17,8 +17,8 @@ Usage:
Example:
Example:
python -m paddle_serving_server.serve --model ./serving_server_model --port 9292
python -m paddle_serving_server.serve --model ./serving_server_model --port 9292
"""
"""
import
os
import
argparse
import
argparse
import
os
from
multiprocessing
import
Pool
,
Process
from
multiprocessing
import
Pool
,
Process
from
paddle_serving_server_gpu
import
serve_args
from
paddle_serving_server_gpu
import
serve_args
...
@@ -64,12 +64,14 @@ def start_gpu_card_model(gpuid, args): # pylint: disable=doc-string-missing
...
@@ -64,12 +64,14 @@ def start_gpu_card_model(gpuid, args): # pylint: disable=doc-string-missing
def
start_multi_card
(
args
):
# pylint: disable=doc-string-missing
def
start_multi_card
(
args
):
# pylint: disable=doc-string-missing
gpus
=
""
gpus
=
""
if
args
.
gpu_ids
==
""
:
if
args
.
gpu_ids
==
""
:
import
os
if
"CUDA_VISIBLE_DEVICES"
in
os
.
environ
:
gpus
=
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
gpus
=
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
else
:
gpus
=
[]
else
:
else
:
gpus
=
args
.
gpu_ids
.
split
(
","
)
gpus
=
args
.
gpu_ids
.
split
(
","
)
if
len
(
gpus
)
<=
0
:
if
len
(
gpus
)
<=
0
:
start_gpu_card_model
(
-
1
)
start_gpu_card_model
(
-
1
,
args
)
else
:
else
:
gpu_processes
=
[]
gpu_processes
=
[]
for
i
,
gpu_id
in
enumerate
(
gpus
):
for
i
,
gpu_id
in
enumerate
(
gpus
):
...
...
python/paddle_serving_server_gpu/web_service.py
浏览文件 @
311a3cd5
...
@@ -95,7 +95,7 @@ class WebService(object):
...
@@ -95,7 +95,7 @@ class WebService(object):
client_service
=
Client
()
client_service
=
Client
()
client_service
.
load_client_config
(
client_service
.
load_client_config
(
"{}/serving_server_conf.prototxt"
.
format
(
self
.
model_config
))
"{}/serving_server_conf.prototxt"
.
format
(
self
.
model_config
))
client_service
.
connect
([
"
127.0.0.1
:{}"
.
format
(
self
.
port
+
i
+
1
)])
client_service
.
connect
([
"
0.0.0.0
:{}"
.
format
(
self
.
port
+
i
+
1
)])
client_list
.
append
(
client_service
)
client_list
.
append
(
client_service
)
time
.
sleep
(
1
)
time
.
sleep
(
1
)
service_name
=
"/"
+
self
.
name
+
"/prediction"
service_name
=
"/"
+
self
.
name
+
"/prediction"
...
...
tools/cpp_examples/bert-gpu-serving/paddle-gpu-serving/paddle_gpu_serving/run/__init__.py
浏览文件 @
311a3cd5
...
@@ -80,7 +80,7 @@ class BertServer():
...
@@ -80,7 +80,7 @@ class BertServer():
def
build_server
(
self
):
def
build_server
(
self
):
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
.
bind
((
'
127.0.0.1
'
,
self
.
port
))
sock
.
bind
((
'
0.0.0.0
'
,
self
.
port
))
sock
.
listen
(
5
)
sock
.
listen
(
5
)
print
(
'Main server serving on {} port.'
.
format
(
self
.
port
))
print
(
'Main server serving on {} port.'
.
format
(
self
.
port
))
while
True
:
while
True
:
...
@@ -122,7 +122,7 @@ class BertServer():
...
@@ -122,7 +122,7 @@ class BertServer():
with
closing
(
socket
.
socket
(
socket
.
AF_INET
,
with
closing
(
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
))
as
sock
:
socket
.
SOCK_STREAM
))
as
sock
:
sock
.
settimeout
(
2
)
sock
.
settimeout
(
2
)
result
=
sock
.
connect_ex
((
'
127.0.0.1
'
,
port
))
result
=
sock
.
connect_ex
((
'
0.0.0.0
'
,
port
))
if
result
!=
0
:
if
result
!=
0
:
return
port
return
port
return
-
1
return
-
1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录