Skip to content

Commit

Permalink
add docs for dcu/ascend/jetson
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiningZhang committed Feb 21, 2022
1 parent b0a5577 commit d9b1001
Show file tree
Hide file tree
Showing 5 changed files with 416 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/C++_Serving/Performance_Tuning_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,17 @@ Server端<mark>**线程数N**</mark>的设置需要结合三个因素来综合

## 4.3 示例
请参考[examples/C++/PaddleOCR/ocr/README_CN.md](../../examples/C++/PaddleOCR/ocr/README_CN.md)`C++ OCR Service服务章节`[Paddle Serving中的集成预测](./Model_Ensemble_CN.md)中的例子。

# 5.请求缓存
当<mark>**您的业务中有较多重复请求**</mark>时,您可以考虑使用C++Serving[Request Cache](./Request_Cache_CN.md)来提升服务性能

## 5.1 优点
服务可以缓存请求结果,将请求数据与结果以键值对的形式保存。当有重复请求到来时,可以根据请求数据直接从缓存中获取结果并返回,而不需要进行模型预测等处理(耗时与请求数据大小有关,在毫秒量级)。

## 5.2 缺点

1) 需要额外的系统内存用于缓存请求结果,具体缓存大小可以通过启动参数进行配置。
2) 对于未命中请求,会增加额外的时间用于根据请求数据检索缓存(耗时增加1%左右)。

## 5.3 示例
请参考[Request Cache](./Request_Cache_CN.md)中的使用方法
95 changes: 95 additions & 0 deletions doc/Prometheus_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
## Paddle Serving使用普罗米修斯监控

Paddle Serving支持普罗米修斯进行性能数据的监控。默认的访问接口为`http://localhost:19393/metrics`。数据形式为文本格式,您可以使用如下命令直观的看到:
```
curl http://localhost:19393/metrics
```

## 配置使用

### C+ Server

对于 C++ Server 来说,启动服务时请添加如下参数

| 参数 | 参数说明 | 备注 |
| :------- | :-------------------------- | :--------------------------------------------------------------- |
| enable_prometheus | 开启Prometheus | 开启Prometheus功能 |
| prometheus_port | Prometheus数据端口 | 默认为19393 |

### Python Pipeline

对于 Python Pipeline 来说,启动服务时请在配置文件config.yml中添加如下参数
```
dag:
#开启Prometheus
enable_prometheus: True
#配置Prometheus数据端口
prometheus_port: 19393
```

### 监控数据类型

监控数据类型如下表

| Metric | Frequency | Description |
| ---------------------------------------------- | ----------- | ----------------------------------------------------- |
| `pd_query_request_success_total` | Per request | Number of successful query requests |
| `pd_query_request_failure_total` | Per request | Number of failed query requests |
| `pd_inference_count_total` | Per request | Number of inferences performed |
| `pd_query_request_duration_us_total` | Per request | Cumulative end-to-end query request handling time |
| `pd_inference_duration_us_total` | Per request | Cumulative time requests spend executing the inference model |

## 监控示例

此处给出一个使用普罗米修斯进行服务监控的简单示例

**1、获取镜像**

```
docker pull prom/node-exporter
docker pull prom/prometheus
```

**2、运行镜像**

```
docker run -d -p 9100:9100 \
-v "/proc:/host/proc:ro" \
-v "/sys:/host/sys:ro" \
-v "/:/rootfs:ro" \
--net="host" \
prom/node-exporter
```

**3、配置**

修改监控服务的配置文件/opt/prometheus/prometheus.yml,添加监控节点信息

```
global:
scrape_interval: 60s
evaluation_interval: 60s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
labels:
instance: prometheus
- job_name: linux
static_configs:
- targets: ['$IP:9100']
labels:
instance: localhost
```

**4、启动监控服务**

```
docker run -d \
-p 9090:9090 \
-v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus
```
访问 `http://serverip:9090/graph` 即可
69 changes: 69 additions & 0 deletions doc/Run_On_DCU_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
## Paddle Serving使用海光芯片部署

Paddle Serving支持使用海光DCU进行预测部署。目前支持的ROCm版本为4.0.1。

## 安装Docker镜像
我们推荐使用docker部署Serving服务,可以直接从Paddle的官方镜像库拉取预先装有ROCm4.0.1的docker镜像。
```
# 拉取镜像
docker pull paddlepaddle/paddle:latest-dev-rocm4.0-miopen2.11
# 启动容器,注意这里的参数,例如shm-size, device等都需要配置
docker run -it --name paddle-rocm-dev --shm-size=128G \
--device=/dev/kfd --device=/dev/dri --group-add video \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
paddlepaddle/paddle:latest-dev-rocm4.0-miopen2.11 /bin/bash
# 检查容器是否可以正确识别海光DCU设备
rocm-smi
# 预期得到以下结果:
======================= ROCm System Management Interface =======================
================================= Concise Info =================================
GPU Temp AvgPwr SCLK MCLK Fan Perf PwrCap VRAM% GPU%
0 50.0c 23.0W 1319Mhz 800Mhz 0.0% auto 300.0W 0% 0%
1 48.0c 25.0W 1319Mhz 800Mhz 0.0% auto 300.0W 0% 0%
2 48.0c 24.0W 1319Mhz 800Mhz 0.0% auto 300.0W 0% 0%
3 49.0c 27.0W 1319Mhz 800Mhz 0.0% auto 300.0W 0% 0%
================================================================================
============================= End of ROCm SMI Log ==============================
```

## 编译、安装
基本环境配置可参考[该文档](Compile_CN.md)进行配置。
### 编译
* 编译server部分
```
cd Serving
mkdir -p server-build-dcu && cd server-build-dcu
cmake -DPYTHON_INCLUDE_DIR=/opt/conda/include/python3.7m/ \
-DPYTHON_LIBRARIES=/opt/conda/lib/libpython3.7m.so \
-DPYTHON_EXECUTABLE=/opt/conda/bin/python \
-DWITH_MKL=ON \
-DWITH_ROCM=ON \
-DSERVER=ON ..
make -j10
```

### 安装wheel包
编译步骤完成后,会在各自编译目录$build_dir/python/dist生成whl包,分别安装即可。例如server步骤,会在server-build-arm/python/dist目录下生成whl包, 使用命令```pip install -u xxx.whl```进行安装。


## 部署使用示例
[resnet50](../examples/C++/PaddleClas/resnet_v2_50/README_CN.md)为例

### 启动rpc服务

启动rpc服务,基于1卡部署
```
python3 -m paddle_serving_server.serve --model resnet_v2_50_imagenet_model --port 9393 --gpu_ids 1
```

## 其他说明

### 模型实例及说明
支持海光芯片部署模型列表见[链接](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/09_hardware_support/rocm_docs/paddle_rocm_cn.html)。不同模型适配上存在差异,可能存在不支持的情况,部署使用存在问题时,欢迎以[Github issue](https://github.com/PaddlePaddle/Serving/issues),我们会实时跟进。

### 昆仑芯片支持相关参考资料
* [海光芯片运行飞桨](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/09_hardware_support/rocm_docs/paddle_install_cn.html)
42 changes: 42 additions & 0 deletions doc/Run_On_JETSON_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## Paddle Serving使用JETSON部署

Paddle Serving支持使用JETSON进行预测部署。目前仅支持Pipeline模式。

### 安装PaddlePaddle

可以参考[NV Jetson部署示例]https://paddleinference.paddlepaddle.org.cn/demo_tutorial/cuda_jetson_demo.html)安装python版本的paddlepaddle


### 安装PaddleServing

安装ARM版本的whl包
```
# paddle-serving-server
https://paddle-serving.bj.bcebos.com/whl/xpu/arm/paddle_serving_server_xpu-0.0.0.post2-py3-none-any.whl
# paddle-serving-client
https://paddle-serving.bj.bcebos.com/whl/xpu/arm/paddle_serving_client-0.0.0-cp36-none-any.whl
# paddle-serving-app
https://paddle-serving.bj.bcebos.com/whl/xpu/arm/paddle_serving_app-0.0.0-py3-none-any.whl
```

### 部署使用

[Uci](../examples/Pipeline/simple_web_service/README_CN.md)为例

启动服务
```
python3 web_service.py &>log.txt &
```
其中修改config.yml中的对应配置项
```
#计算硬件类型: 空缺时由devices决定(CPU/GPU),0=cpu, 1=gpu, 2=tensorRT, 3=arm cpu, 4=kunlun xpu
device_type: 1
#计算硬件ID,优先由device_type决定硬件类型。devices为""或空缺时为CPU预测;当为"0", "0,1,2"时为GPU预测,表示使用的GPU卡
devices: "0,1"
```

## 其他说明

### Jetson支持相关参考资料
* [Jetson运行飞桨](https://paddleinference.paddlepaddle.org.cn/demo_tutorial/cuda_jetson_demo.html)
Loading

0 comments on commit d9b1001

Please sign in to comment.