Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
8a5303f7
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看板
未验证
提交
8a5303f7
编写于
4月 25, 2021
作者:
T
TeslaZhao
提交者:
GitHub
4月 25, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1170 from zhangjun/xpu-fix
[doc] fix doc for xpu example
上级
192ba5e4
bc42fad2
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
59 addition
and
42357 deletion
+59
-42357
python/examples/low_precision/resnet50/resnet50_client.py
python/examples/low_precision/resnet50/resnet50_client.py
+1
-1
python/examples/xpu/bert/README.md
python/examples/xpu/bert/README.md
+19
-3
python/examples/xpu/bert/get_data.sh
python/examples/xpu/bert/get_data.sh
+2
-0
python/examples/xpu/bert/vocab.txt
python/examples/xpu/bert/vocab.txt
+0
-21128
python/examples/xpu/ernie/README.md
python/examples/xpu/ernie/README.md
+17
-1
python/examples/xpu/ernie/ernie_client.py
python/examples/xpu/ernie/ernie_client.py
+1
-1
python/examples/xpu/ernie/ernie_web_service.py
python/examples/xpu/ernie/ernie_web_service.py
+0
-0
python/examples/xpu/ernie/get_data.sh
python/examples/xpu/ernie/get_data.sh
+2
-0
python/examples/xpu/ernie/vocab.txt
python/examples/xpu/ernie/vocab.txt
+0
-21128
python/examples/xpu/fit_a_line_xpu/README.md
python/examples/xpu/fit_a_line_xpu/README.md
+3
-10
python/examples/xpu/fit_a_line_xpu/README_CN.md
python/examples/xpu/fit_a_line_xpu/README_CN.md
+2
-4
python/examples/xpu/fit_a_line_xpu/test_multi_process_client.py
.../examples/xpu/fit_a_line_xpu/test_multi_process_client.py
+0
-42
python/examples/xpu/fit_a_line_xpu/test_server.py
python/examples/xpu/fit_a_line_xpu/test_server.py
+0
-37
python/examples/xpu/vgg19/README.md
python/examples/xpu/vgg19/README.md
+12
-2
未找到文件。
python/examples/low_precision/resnet50/resnet50_client.py
浏览文件 @
8a5303f7
...
@@ -19,7 +19,7 @@ from paddle_serving_app.reader import RGB2BGR, Transpose, Div, Normalize
...
@@ -19,7 +19,7 @@ from paddle_serving_app.reader import RGB2BGR, Transpose, Div, Normalize
client
=
Client
()
client
=
Client
()
client
.
load_client_config
(
client
.
load_client_config
(
"serving_client/serving_client_conf.prototxt"
)
"serving_client/serving_client_conf.prototxt"
)
client
.
connect
([
"127.0.0.1:93
0
3"
])
client
.
connect
([
"127.0.0.1:93
9
3"
])
seq
=
Sequential
([
seq
=
Sequential
([
File2Image
(),
Resize
(
256
),
CenterCrop
(
224
),
RGB2BGR
(),
Transpose
((
2
,
0
,
1
)),
File2Image
(),
Resize
(
256
),
CenterCrop
(
224
),
RGB2BGR
(),
Transpose
((
2
,
0
,
1
)),
...
...
python/examples/xpu/bert/README.md
浏览文件 @
8a5303f7
## Prepare
## Prepare
### download model and extract
```
wget https://paddle-inference-dist.cdn.bcebos.com/PaddleLite/models_and_data_for_unittests/bert_base_chinese.tar.gz
tar zxvf bert_base_chinese.tar.gz
```
### convert model
### convert model
```
```
python -m paddle_serving_client.convert --dirname infer_bert-base-chinese_ft_model_4000.pdparams
python3 -m paddle_serving_client.convert --dirname bert_base_chinese --model_filename bert_base_chinese/model.pdmodel --params_filename bert_base_chinese/model.pdiparams
```
### or, you can get the serving saved model directly
```
wget https://paddle-serving.bj.bcebos.com/models/xpu/bert.tar.gz
tar zxvf bert.tar.gz
```
### Getting Dict and Sample Dataset
```
sh get_data.sh
```
```
this script will download Chinese Dictionary File vocab.txt and Chinese Sample Data data-c.txt
## RPC Service
## RPC Service
### Start Service
### Start Service
```
```
pyt
yon
bert_web_service.py serving_server 7703
pyt
hon3
bert_web_service.py serving_server 7703
```
```
### Client Prediction
### Client Prediction
```
```
python bert_client.py
head data-c.txt | python3 bert_client.py --model serving_client/serving_client_conf.prototxt
```
```
python/examples/xpu/bert/get_data.sh
0 → 100644
浏览文件 @
8a5303f7
wget https://paddle-serving.bj.bcebos.com/bert_example/data-c.txt
--no-check-certificate
wget https://paddle-serving.bj.bcebos.com/bert_example/vocab.txt
--no-check-certificate
python/examples/xpu/bert/vocab.txt
已删除
100644 → 0
浏览文件 @
192ba5e4
此差异已折叠。
点击以展开。
python/examples/xpu/ernie/README.md
浏览文件 @
8a5303f7
## Prepare
## Prepare
### download model and extract
```
wget https://paddle-inference-dist.cdn.bcebos.com/PaddleLite/models_and_data_for_unittests/ernie.tar.gz
tar zxvf ernie.tar.gz
```
### convert model
### convert model
```
```
python3 -m paddle_serving_client.convert --dirname erine
python3 -m paddle_serving_client.convert --dirname ernie
```
### or, you can get the serving saved model directly
```
wget https://paddle-serving.bj.bcebos.com/models/xpu/ernie.tar.gz
tar zxvf ernie.tar.gz
```
### Getting Dict and Sample Dataset
```
sh get_data.sh
```
```
this script will download Chinese Dictionary File vocab.txt and Chinese Sample Data data-c.txt
## RPC Service
## RPC Service
...
...
python/examples/xpu/ernie/ernie_client.py
浏览文件 @
8a5303f7
...
@@ -23,7 +23,7 @@ args = benchmark_args()
...
@@ -23,7 +23,7 @@ args = benchmark_args()
reader
=
ChineseErnieReader
({
"max_seq_len"
:
128
})
reader
=
ChineseErnieReader
({
"max_seq_len"
:
128
})
fetch
=
[
"save_infer_model/scale_0"
]
fetch
=
[
"save_infer_model/scale_0"
]
endpoint_list
=
[
'127.0.0.1:
7704
'
]
endpoint_list
=
[
'127.0.0.1:
12000
'
]
client
=
Client
()
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
load_client_config
(
args
.
model
)
client
.
connect
(
endpoint_list
)
client
.
connect
(
endpoint_list
)
...
...
python/examples/xpu/ernie/er
in
e_web_service.py
→
python/examples/xpu/ernie/er
ni
e_web_service.py
浏览文件 @
8a5303f7
文件已移动
python/examples/xpu/ernie/get_data.sh
0 → 100644
浏览文件 @
8a5303f7
wget https://paddle-serving.bj.bcebos.com/bert_example/data-c.txt
--no-check-certificate
wget https://paddle-serving.bj.bcebos.com/bert_example/vocab.txt
--no-check-certificate
python/examples/xpu/ernie/vocab.txt
已删除
100644 → 0
浏览文件 @
192ba5e4
此差异已折叠。
点击以展开。
python/examples/xpu/fit_a_line_xpu/README.md
浏览文件 @
8a5303f7
...
@@ -8,15 +8,10 @@
...
@@ -8,15 +8,10 @@
sh get_data.sh
sh get_data.sh
```
```
## RPC service
## RPC service
### Start server
### Start server
```
shell
You can use the following code to start the RPC service
python test_server.py uci_housing_model/
```
You can alse use the following code to start the RPC service
```
shell
```
shell
python
-m
paddle_serving_server.serve
--model
uci_housing_model
--thread
10
--port
9393
--use_lite
--use_xpu
--ir_optim
python
-m
paddle_serving_server.serve
--model
uci_housing_model
--thread
10
--port
9393
--use_lite
--use_xpu
--ir_optim
```
```
...
@@ -29,19 +24,17 @@ The `paddlepaddle` package is used in `test_client.py`, and you may need to down
...
@@ -29,19 +24,17 @@ The `paddlepaddle` package is used in `test_client.py`, and you may need to down
python test_client.py uci_housing_client/serving_client_conf.prototxt
python test_client.py uci_housing_client/serving_client_conf.prototxt
```
```
## HTTP service
## HTTP service
### Start server
### Start server
Start a web service with default web service hosting modules:
Start a web service with default web service hosting modules:
```
shell
```
shell
python
test_server.py
python
-m
paddle_serving_server.serve
--model
uci_housing_model
--thread
10
--port
9393
--use_lite
--use_xpu
--ir_optim
--name
uci
```
```
### Client prediction
### Client prediction
```
shell
```
shell
curl
-H
"Content-Type:application/json"
-X
POST
-d
'{"feed":[{"x": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332]}], "fetch":["price"]}'
http://127.0.0.1:9
292
/uci/prediction
curl
-H
"Content-Type:application/json"
-X
POST
-d
'{"feed":[{"x": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332]}], "fetch":["price"]}'
http://127.0.0.1:9
393
/uci/prediction
```
```
python/examples/xpu/fit_a_line_xpu/README_CN.md
浏览文件 @
8a5303f7
...
@@ -32,8 +32,6 @@ python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --po
...
@@ -32,8 +32,6 @@ python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --po
python test_client.py uci_housing_client/serving_client_conf.prototxt
python test_client.py uci_housing_client/serving_client_conf.prototxt
```
```
## HTTP服务
## HTTP服务
### 开启服务端
### 开启服务端
...
@@ -41,11 +39,11 @@ python test_client.py uci_housing_client/serving_client_conf.prototxt
...
@@ -41,11 +39,11 @@ python test_client.py uci_housing_client/serving_client_conf.prototxt
通过下面的一行代码开启默认web服务:
通过下面的一行代码开启默认web服务:
```
shell
```
shell
python
test_server.py
python
-m
paddle_serving_server.serve
--model
uci_housing_model
--thread
10
--port
9393
--use_lite
--use_xpu
--ir_optim
--name
uci
```
```
### 客户端预测
### 客户端预测
```
shell
```
shell
curl
-H
"Content-Type:application/json"
-X
POST
-d
'{"feed":[{"x": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332]}], "fetch":["price"]}'
http://127.0.0.1:9
292
/uci/prediction
curl
-H
"Content-Type:application/json"
-X
POST
-d
'{"feed":[{"x": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332]}], "fetch":["price"]}'
http://127.0.0.1:9
393
/uci/prediction
```
```
python/examples/xpu/fit_a_line_xpu/test_multi_process_client.py
已删除
100644 → 0
浏览文件 @
192ba5e4
# 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.
from
paddle_serving_client
import
Client
from
paddle_serving_client.utils
import
MultiThreadRunner
import
paddle
import
numpy
as
np
def
single_func
(
idx
,
resource
):
client
=
Client
()
client
.
load_client_config
(
"./uci_housing_client/serving_client_conf.prototxt"
)
client
.
connect
([
"127.0.0.1:9293"
,
"127.0.0.1:9292"
])
x
=
[
0.0137
,
-
0.1136
,
0.2553
,
-
0.0692
,
0.0582
,
-
0.0727
,
-
0.1583
,
-
0.0584
,
0.6283
,
0.4919
,
0.1856
,
0.0795
,
-
0.0332
]
x
=
np
.
array
(
x
)
for
i
in
range
(
1000
):
fetch_map
=
client
.
predict
(
feed
=
{
"x"
:
x
},
fetch
=
[
"price"
])
if
fetch_map
is
None
:
return
[[
None
]]
return
[[
0
]]
multi_thread_runner
=
MultiThreadRunner
()
thread_num
=
4
result
=
multi_thread_runner
.
run
(
single_func
,
thread_num
,
{})
if
None
in
result
[
0
]:
exit
(
1
)
python/examples/xpu/fit_a_line_xpu/test_server.py
已删除
100644 → 0
浏览文件 @
192ba5e4
# 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.
# pylint: disable=doc-string-missing
from
paddle_serving_server.web_service
import
WebService
import
numpy
as
np
class
UciService
(
WebService
):
def
preprocess
(
self
,
feed
=
[],
fetch
=
[]):
feed_batch
=
[]
is_batch
=
True
new_data
=
np
.
zeros
((
len
(
feed
),
1
,
13
)).
astype
(
"float32"
)
for
i
,
ins
in
enumerate
(
feed
):
nums
=
np
.
array
(
ins
[
"x"
]).
reshape
(
1
,
1
,
13
)
new_data
[
i
]
=
nums
feed
=
{
"x"
:
new_data
}
return
feed
,
fetch
,
is_batch
uci_service
=
UciService
(
name
=
"uci"
)
uci_service
.
load_model_config
(
"uci_housing_model"
)
uci_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9393
,
use_lite
=
True
,
use_xpu
=
True
,
ir_optim
=
True
)
uci_service
.
run_rpc_service
()
uci_service
.
run_web_service
()
python/examples/xpu/vgg19/README.md
浏览文件 @
8a5303f7
## Prepare
## Prepare
### download model and extract
```
wget https://paddle-inference-dist.bj.bcebos.com/PaddleLite/models_and_data_for_unittests/VGG19.tar.gz
tar zxvf VGG19.tar.gz
```
### convert model
### convert model
```
```
python -m paddle_serving_client.convert --dirname VGG19
python3 -m paddle_serving_client.convert --dirname VGG19
```
### or, you can get the serving saved model directly
```
wget https://paddle-serving.bj.bcebos.com/models/xpu/vgg19.tar.gz
tar zxvf vgg19.tar.gz
```
```
## RPC Service
## RPC Service
...
@@ -10,7 +20,7 @@ python -m paddle_serving_client.convert --dirname VGG19
...
@@ -10,7 +20,7 @@ python -m paddle_serving_client.convert --dirname VGG19
### Start Service
### Start Service
```
```
python -m paddle_serving_server.serve --model serving_server --port 7702 --use_lite --use_xpu --ir_optim
python
3
-m paddle_serving_server.serve --model serving_server --port 7702 --use_lite --use_xpu --ir_optim
```
```
### Client Prediction
### Client Prediction
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录