Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
b0b5cce6
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看板
提交
b0b5cce6
编写于
7月 03, 2020
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix imagenet benchmark
上级
84ce1cde
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
10 deletion
+30
-10
python/examples/bert/benchmark.sh
python/examples/bert/benchmark.sh
+1
-1
python/examples/imagenet/benchmark.py
python/examples/imagenet/benchmark.py
+25
-5
python/examples/imagenet/benchmark.sh
python/examples/imagenet/benchmark.sh
+2
-2
python/examples/imdb/benchmark.sh
python/examples/imdb/benchmark.sh
+2
-2
未找到文件。
python/examples/bert/benchmark.sh
浏览文件 @
b0b5cce6
...
...
@@ -3,7 +3,7 @@ export CUDA_VISIBLE_DEVICES=0,1,2,3
export
FLAGS_profile_server
=
1
export
FLAGS_profile_client
=
1
export
FLAGS_serving_latency
=
1
python3
-m
paddle_serving_server_gpu.serve
--model
$1
--port
9292
--thread
4
--gpu_ids
0,1,2,3
--mem_optim
False
--ir_optim
True
2> elog
>
stdlog &
python3
-m
paddle_serving_server_gpu.serve
--model
$1
--port
9292
--thread
4
--gpu_ids
0,1,2,3
--mem_optim
--ir_optim
2> elog
>
stdlog &
hostname
=
`
echo
$(
hostname
)
|awk
-F
'.baidu.com'
'{print $1}'
`
sleep
5
gpu_id
=
0
...
...
python/examples/imagenet/benchmark.py
浏览文件 @
b0b5cce6
...
...
@@ -24,7 +24,7 @@ import json
import
base64
from
paddle_serving_client
import
Client
from
paddle_serving_client.utils
import
MultiThreadRunner
from
paddle_serving_client.utils
import
benchmark_args
from
paddle_serving_client.utils
import
benchmark_args
,
show_latency
from
paddle_serving_app.reader
import
Sequential
,
File2Image
,
Resize
from
paddle_serving_app.reader
import
CenterCrop
,
RGB2BGR
,
Transpose
,
Div
,
Normalize
...
...
@@ -38,7 +38,11 @@ seq_preprocess = Sequential([
def
single_func
(
idx
,
resource
):
file_list
=
[]
turns
=
10
turns
=
resource
[
"turns"
]
latency_flags
=
False
if
os
.
getenv
(
"FLAGS_serving_latency"
):
latency_flags
=
True
latency_list
=
[]
for
file_name
in
os
.
listdir
(
"./image_data/n01440764"
):
file_list
.
append
(
file_name
)
img_list
=
[]
...
...
@@ -56,6 +60,7 @@ def single_func(idx, resource):
start
=
time
.
time
()
for
i
in
range
(
turns
):
if
args
.
batch_size
>=
1
:
l_start
=
time
.
time
()
feed_batch
=
[]
i_start
=
time
.
time
()
for
bi
in
range
(
args
.
batch_size
):
...
...
@@ -69,6 +74,9 @@ def single_func(idx, resource):
int
(
round
(
i_end
*
1000000
))))
result
=
client
.
predict
(
feed
=
feed_batch
,
fetch
=
fetch
)
l_end
=
time
.
time
()
if
latency_flags
:
latency_list
.
append
(
l_end
*
1000
-
l_start
*
1000
)
else
:
print
(
"unsupport batch size {}"
.
format
(
args
.
batch_size
))
...
...
@@ -88,6 +96,8 @@ def single_func(idx, resource):
r
=
requests
.
post
(
server
,
data
=
req
,
headers
=
{
"Content-Type"
:
"application/json"
})
end
=
time
.
time
()
if
latency_flags
:
return
[[
end
-
start
],
latency_list
]
return
[[
end
-
start
]]
...
...
@@ -96,11 +106,21 @@ if __name__ == '__main__':
endpoint_list
=
[
"127.0.0.1:9292"
,
"127.0.0.1:9293"
,
"127.0.0.1:9294"
,
"127.0.0.1:9295"
]
result
=
multi_thread_runner
.
run
(
single_func
,
args
.
thread
,
{
"endpoint"
:
endpoint_list
})
turns
=
100
start
=
time
.
time
()
result
=
multi_thread_runner
.
run
(
single_func
,
args
.
thread
,
{
"endpoint"
:
endpoint_list
,
"turns"
:
turns
})
#result = single_func(0, {"endpoint": endpoint_list})
end
=
time
.
time
()
total_cost
=
end
-
start
avg_cost
=
0
for
i
in
range
(
args
.
thread
):
avg_cost
+=
result
[
0
][
i
]
avg_cost
=
avg_cost
/
args
.
thread
print
(
"average total cost {} s."
.
format
(
avg_cost
))
print
(
"total cost: {}s"
.
format
(
end
-
start
))
print
(
"each thread cost: {}s."
.
format
(
avg_cost
))
print
(
"qps: {}samples/s"
.
format
(
args
.
batch_size
*
args
.
thread
*
turns
/
total_cost
))
if
os
.
getenv
(
"FLAGS_serving_latency"
):
show_latency
(
result
[
1
])
python/examples/imagenet/benchmark.sh
浏览文件 @
b0b5cce6
...
...
@@ -2,14 +2,14 @@ rm profile_log
export
CUDA_VISIBLE_DEVICES
=
0,1,2,3
export
FLAGS_profile_server
=
1
export
FLAGS_profile_client
=
1
python
-m
paddle_serving_server_gpu.serve
--model
$1
--port
9292
--thread
4
--gpu_ids
0,1,2,3 2> elog
>
stdlog &
python
-m
paddle_serving_server_gpu.serve
--model
$1
--port
9292
--thread
4
--gpu_ids
0,1,2,3
--mem_optim
--ir_optim
2> elog
>
stdlog &
sleep
5
#warm up
$PYTHONROOT
/bin/python benchmark.py
--thread
8
--batch_size
1
--model
$2
/serving_client_conf.prototxt
--request
rpc
>
profile 2>&1
for
thread_num
in
4 8 16
for
thread_num
in
1
4 8 16
do
for
batch_size
in
1 4 16 64
do
...
...
python/examples/imdb/benchmark.sh
浏览文件 @
b0b5cce6
...
...
@@ -8,9 +8,9 @@ hostname=`echo $(hostname)|awk -F '.baidu.com' '{print $1}'`
sleep
5
for
thread_num
in
4 8 16
for
thread_num
in
1
4 8 16
do
for
batch_size
in
1 4 16 64
256
for
batch_size
in
1 4 16 64
do
job_bt
=
`
date
'+%Y%m%d%H%M%S'
`
python benchmark.py
--thread
$thread_num
--batch_size
$batch_size
--model
$2
/serving_client_conf.prototxt
--request
rpc
>
profile 2>&1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录