2022-06-13 14:30:29 +08:00
|
|
|
|
# Linux GPU/CPU PYTHON 服务化部署测试
|
|
|
|
|
|
2022-06-14 10:51:17 +08:00
|
|
|
|
Linux GPU/CPU PYTHON 服务化部署测试的主程序为`test_serving_infer_cpp.sh`,可以测试基于Python的模型服务化部署功能。
|
2022-06-13 14:30:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 1. 测试结论汇总
|
|
|
|
|
|
|
|
|
|
- 推理相关:
|
|
|
|
|
|
|
|
|
|
| 算法名称 | 模型名称 | device_CPU | device_GPU |
|
|
|
|
|
| :----: | :----: | :----: | :----: |
|
|
|
|
|
| MobileNetV3 | MobileNetV3_large_x1_0 | 支持 | 支持 |
|
|
|
|
|
| PP-ShiTu | PPShiTu_general_rec、PPShiTu_mainbody_det | 支持 | 支持 |
|
|
|
|
|
| PPHGNet | PPHGNet_small | 支持 | 支持 |
|
|
|
|
|
| PPHGNet | PPHGNet_tiny | 支持 | 支持 |
|
|
|
|
|
| PPLCNet | PPLCNet_x0_25 | 支持 | 支持 |
|
|
|
|
|
| PPLCNet | PPLCNet_x0_35 | 支持 | 支持 |
|
|
|
|
|
| PPLCNet | PPLCNet_x0_5 | 支持 | 支持 |
|
|
|
|
|
| PPLCNet | PPLCNet_x0_75 | 支持 | 支持 |
|
|
|
|
|
| PPLCNet | PPLCNet_x1_0 | 支持 | 支持 |
|
|
|
|
|
| PPLCNet | PPLCNet_x1_5 | 支持 | 支持 |
|
|
|
|
|
| PPLCNet | PPLCNet_x2_0 | 支持 | 支持 |
|
|
|
|
|
| PPLCNet | PPLCNet_x2_5 | 支持 | 支持 |
|
|
|
|
|
| PPLCNetV2 | PPLCNetV2_base | 支持 | 支持 |
|
|
|
|
|
| ResNet | ResNet50 | 支持 | 支持 |
|
|
|
|
|
| ResNet | ResNet50_vd | 支持 | 支持 |
|
|
|
|
|
| SwinTransformer | SwinTransformer_tiny_patch4_window7_224 | 支持 | 支持 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 2. 测试流程
|
|
|
|
|
|
|
|
|
|
### 2.1 准备数据
|
|
|
|
|
|
|
|
|
|
分类模型默认使用`./deploy/paddleserving/daisy.jpg`作为测试输入图片,无需下载
|
|
|
|
|
识别模型默认使用`drink_dataset_v1.0/test_images/001.jpeg`作为测试输入图片,在**2.2 准备环境**中会下载好。
|
|
|
|
|
|
|
|
|
|
### 2.2 准备环境
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- 安装PaddlePaddle:如果您已经安装了2.2或者以上版本的paddlepaddle,那么无需运行下面的命令安装paddlepaddle。
|
|
|
|
|
```shell
|
|
|
|
|
# 需要安装2.2及以上版本的Paddle
|
|
|
|
|
# 安装GPU版本的Paddle
|
|
|
|
|
python3.7 -m pip install paddlepaddle-gpu==2.2.0
|
|
|
|
|
# 安装CPU版本的Paddle
|
|
|
|
|
python3.7 -m pip install paddlepaddle==2.2.0
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- 安装依赖
|
|
|
|
|
```shell
|
|
|
|
|
python3.7 -m pip install -r requirements.txt
|
|
|
|
|
```
|
2022-06-13 19:26:51 +08:00
|
|
|
|
- 安装 PaddleServing 相关组件,包括serving_client、serving-app,自动编译并安装带自定义OP的 serving_server 包,以及自动下载并解压推理模型
|
2022-06-13 14:30:29 +08:00
|
|
|
|
```bash
|
2022-06-13 14:37:30 +08:00
|
|
|
|
bash test_tipc/prepare.sh test_tipc/configs/PPLCNet/PPLCNet_x1_0_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt serving_infer
|
2022-06-13 14:30:29 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 2.3 功能测试
|
|
|
|
|
|
|
|
|
|
测试方法如下所示,希望测试不同的模型文件,只需更换为自己的参数配置文件,即可完成对应模型的测试。
|
|
|
|
|
|
|
|
|
|
```bash
|
2022-06-14 10:51:17 +08:00
|
|
|
|
bash test_tipc/test_serving_infer_cpp.sh ${your_params_file}
|
2022-06-13 14:30:29 +08:00
|
|
|
|
```
|
|
|
|
|
|
2022-06-13 14:37:30 +08:00
|
|
|
|
以`PPLCNet_x1_0`的`Linux GPU/CPU C++ 服务化部署测试`为例,命令如下所示。
|
2022-06-13 14:30:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
2022-06-14 10:51:17 +08:00
|
|
|
|
bash test_tipc/test_serving_infer_cpp.sh test_tipc/configs/PPLCNet/PPLCNet_x1_0_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt
|
2022-06-13 14:30:29 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
输出结果如下,表示命令运行成功。
|
|
|
|
|
|
|
|
|
|
```
|
2022-06-13 14:37:30 +08:00
|
|
|
|
Run successfully with command - PPLCNet_x1_0 - python3.7 test_cpp_serving_client.py > ../../test_tipc/output/PPLCNet_x1_0/server_infer_cpp_gpu_pipeline_batchsize_1.log 2>&1 !
|
|
|
|
|
Run successfully with command - PPLCNet_x1_0 - python3.7 test_cpp_serving_client.py > ../../test_tipc/output/PPLCNet_x1_0/server_infer_cpp_cpu_pipeline_batchsize_1.log 2>&1 !
|
2022-06-13 14:30:29 +08:00
|
|
|
|
```
|
|
|
|
|
|
2022-06-13 14:37:30 +08:00
|
|
|
|
预测结果会自动保存在 `./test_tipc/output/PPLCNet_x1_0/server_infer_gpu_pipeline_http_batchsize_1.log` ,可以看到 PaddleServing 的运行结果:
|
2022-06-13 14:30:29 +08:00
|
|
|
|
|
|
|
|
|
```
|
2022-06-13 14:37:30 +08:00
|
|
|
|
WARNING: Logging before InitGoogleLogging() is written to STDERR
|
|
|
|
|
I0612 09:55:16.109890 38303 naming_service_thread.cpp:202] brpc::policy::ListNamingService("127.0.0.1:9292"): added 1
|
|
|
|
|
I0612 09:55:16.172924 38303 general_model.cpp:490] [client]logid=0,client_cost=60.772ms,server_cost=57.6ms.
|
|
|
|
|
prediction: daisy, probability: 0.9099399447441101
|
|
|
|
|
0.06275796890258789
|
2022-06-13 14:30:29 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
如果运行失败,也会在终端中输出运行失败的日志信息以及对应的运行命令。可以基于该命令,分析运行失败的原因。
|