diff --git a/doc/C++_Serving/ABTest_CN.md b/doc/C++_Serving/ABTest_CN.md index d3aa73103ba79f1d55d7b6383f4e7a0233e26146..34054d449b020c695e11e4d9e7212c76bd24fe70 100755 --- a/doc/C++_Serving/ABTest_CN.md +++ b/doc/C++_Serving/ABTest_CN.md @@ -30,7 +30,7 @@ pip install Shapely ### 启动Server端 -这里采用[Docker方式](../Run_In_Docker_CN.md)启动Server端服务。 +这里采用[Docker方式](../Install_CN.md)启动Server端服务。 首先启动BOW Server,该服务启用`8000`端口: diff --git a/doc/C++_Serving/ABTest_EN.md b/doc/C++_Serving/ABTest_EN.md index ac97d139ee03d97b601748967ece8d8560815099..5dc0e2e8e7f65b7777e2eaf0fca7600c1124e926 100755 --- a/doc/C++_Serving/ABTest_EN.md +++ b/doc/C++_Serving/ABTest_EN.md @@ -31,7 +31,7 @@ The Python code in the file will process the data `test_data/part-0` and write t ### Start Server -Here, we [use docker](../Run_In_Docker_EN.md) to start the server-side service. +Here, we [use docker](../Docker_Images_EN.md) to start the server-side service. First, start the BOW server, which enables the `8000` port: diff --git a/doc/C++_Serving/Introduction_CN.md b/doc/C++_Serving/Introduction_CN.md index 17c3f096f6eba10e6abe2c2fcab8e5ee17b83ad4..3f864ab04628b6e707463625d9aafb472917e9db 100755 --- a/doc/C++_Serving/Introduction_CN.md +++ b/doc/C++_Serving/Introduction_CN.md @@ -76,7 +76,7 @@ C++ Serving采用对称加密算法对模型进行加密,在服务加载模型
### 4.2 多语言多协议Client
-BRPC网络框架支持[多种底层通信协议](#1.网络框架(BRPC)),即使用目前的C++ Serving框架的Server端,各种语言的Client端,甚至使用curl的方式,只要按照上述协议(具体支持的协议见[brpc官网](https://github.com/apache/incubator-brpc))封装数据并发送,Server端就能够接收、处理和返回结果。
+BRPC网络框架支持[多种底层通信协议](#1网络框架BRPC),即使用目前的C++ Serving框架的Server端,各种语言的Client端,甚至使用curl的方式,只要按照上述协议(具体支持的协议见[brpc官网](https://github.com/apache/incubator-brpc))封装数据并发送,Server端就能够接收、处理和返回结果。
对于支持的各种协议我们提供了部分的Client SDK示例供用户参考和使用,用户也可以根据自己的需求去开发新的Client SDK,也欢迎用户添加其他语言/协议(例如GRPC-Go、GRPC-C++ HTTP2-Go、HTTP2-Java等)Client SDK到我们的仓库供其他开发者借鉴和参考。
diff --git a/doc/Compile_CN.md b/doc/Compile_CN.md
index aadf9fa5124c8876301c83fd043e686f78a1820c..72a751a03533e57225df9ce62780a121a642e954 100644
--- a/doc/Compile_CN.md
+++ b/doc/Compile_CN.md
@@ -2,7 +2,22 @@
(简体中文|[English](./Compile_EN.md))
-## 编译环境设置
+## 总体概述
+
+编译Paddle Serving一共分以下几步
+
+- 编译环境准备:根据模型和运行环境的需要,选择最合适的镜像
+- 下载代码库:下载Serving代码库,按需要执行初始化操作
+- 环境变量准备:根据运行环境的需要,确定Python各个环境变量,如GPU环境还需要确定Cuda,Cudnn,TensorRT等环境变量。
+- 正式编译: 编译`paddle-serving-server`, `paddle-serving-client`, `paddle-serving-app`相关whl包
+- 安装相关whl包:安装编译出的三个whl包,并设置SERVING_BIN环境变量
+
+此外,针对某些C++二次开发场景,我们也提供了OPENCV的联编方案。
+
+
+
+
+## 编译环境准备
| 组件 | 版本要求 |
| :--------------------------: | :-------------------------------: |
@@ -11,7 +26,7 @@
| gcc-c++ | 5.4.0(Cuda 10.1) and 8.2.0 |
| cmake | 3.2.0 and later |
| Python | 3.6.0 and later |
-| Go | 1.9.2 and later |
+| Go | 1.17.2 and later |
| git | 2.17.1 and later |
| glibc-static | 2.17 |
| openssl-devel | 1.0.2k |
@@ -25,107 +40,149 @@
推荐使用Docker编译,我们已经为您准备好了Paddle Serving编译环境并配置好了上述编译依赖,详见[该文档](Docker_Images_CN.md)。
-## 获取代码
+我们提供了五个环境的开发镜像,分别是CPU, Cuda10.1+Cudnn7, Cuda10.2+Cudnn7,Cuda10.2+Cudnn8, Cuda11.2+Cudnn8。我们提供了Serving开发镜像涵盖以上环境。与此同时,我们也支持Paddle开发镜像。
-``` python
-git clone https://github.com/PaddlePaddle/Serving
-cd Serving && git submodule update --init --recursive
+其中Serving镜像名是 **paddlepaddle/serving:${Serving开发镜像Tag}**(如果网络不佳可以访问**registry.baidubce.com/paddlepaddle/serving:${Serving开发镜像Tag}**), Paddle开发镜像名是 **paddlepaddle/paddle:${Paddle开发镜像Tag}**。为了防止用户对两套镜像出现混淆,我们分别解释一下两套镜像的由来。
+
+Serving开发镜像是Serving套件为了支持各个预测环境提供的用于编译、调试预测服务的镜像,Paddle开发镜像是Paddle在官网发布的用于编译、开发、训练模型使用镜像。为了让Paddle开发者能够在同一个容器内直接使用Serving。对于上个版本就已经使用Serving用户的开发者来说,Serving开发镜像应该不会感到陌生。但对于熟悉Paddle训练框架生态的开发者,目前应该更熟悉已有的Paddle开发镜像。为了适应所有用户的不同习惯,我们对这两套镜像都做了充分的支持。
+
+
+| 环境 | Serving开发镜像Tag | 操作系统 | Paddle开发镜像Tag | 操作系统 |
+| :--------------------------: | :-------------------------------: | :-------------: | :-------------------: | :----------------: |
+| CPU | 0.7.0-devel | Ubuntu 16.04 | 2.2.0 | Ubuntu 18.04. |
+| Cuda10.1+Cudnn7 | 0.7.0-cuda10.1-cudnn7-devel | Ubuntu 16.04 | 无 | 无 |
+| Cuda10.2+Cudnn7 | 0.7.0-cuda10.2-cudnn7-devel | Ubuntu 16.04 | 2.2.0-cuda10.2-cudnn7 | Ubuntu 16.04 |
+| Cuda10.2+Cudnn8 | 0.7.0-cuda10.2-cudnn8-devel | Ubuntu 16.04 | 无 | 无 |
+| Cuda11.2+Cudnn8 | 0.7.0-cuda11.2-cudnn8-devel | Ubuntu 16.04 | 2.2.0-cuda11.2-cudnn8 | Ubuntu 18.04 |
+
+我们首先要针对自己所需的环境拉取相关镜像。上表**环境**一列下,除了CPU,其余(Cuda**+Cudnn**)都属于GPU环境。
+您可以使用Serving开发镜像。
```
+docker pull paddlepaddle/serving:${Serving开发镜像Tag}
-## PYTHONROOT设置
+# 如果是GPU镜像
+nvidia-docker run --rm -it paddlepaddle/serving:${Serving开发镜像Tag} bash
-```shell
-# 例如python的路径为/usr/bin/python,可以设置PYTHONROOT
-export PYTHONROOT=/usr
+# 如果是CPU镜像
+docker run --rm -it paddlepaddle/serving:${Serving开发镜像Tag} bash
```
-如果您使用的是Docker开发镜像,请按照如下,确定好需要编译的Python版本,设置对应的环境变量
+也可以使用Paddle开发镜像。
```
-#Python3.6
-export PYTHONROOT=/usr/local/
-export PYTHON_INCLUDE_DIR=$PYTHONROOT/include/python3.6m
-export PYTHON_LIBRARIES=$PYTHONROOT/lib/libpython3.6m.so
-export PYTHON_EXECUTABLE=$PYTHONROOT/bin/python3.6
-
-#Python3.7
-export PYTHONROOT=/usr/local/
-export PYTHON_INCLUDE_DIR=$PYTHONROOT/include/python3.7m
-export PYTHON_LIBRARIES=$PYTHONROOT/lib/libpython3.7m.so
-export PYTHON_EXECUTABLE=$PYTHONROOT/bin/python3.7
-
-#Python3.8
-export PYTHONROOT=/usr/local/
-export PYTHON_INCLUDE_DIR=$PYTHONROOT/include/python3.8
-export PYTHON_LIBRARIES=$PYTHONROOT/lib/libpython3.8.so
-export PYTHON_EXECUTABLE=$PYTHONROOT/bin/python3.8
+docker pull paddlepaddle/paddle:${Paddle开发镜像Tag}
+# 如果是GPU镜像,需要使用nvidia-docker
+nvidia-docker run --rm -it paddlepaddle/paddle:${Paddle开发镜像Tag} bash
+
+# 如果是CPU镜像
+docker run --rm -it paddlepaddle/paddle:${Paddle开发镜像Tag} bash
```
-## 安装Python依赖
-```shell
-pip install -r python/requirements.txt -i https://mirror.baidu.com/pypi/simple
+## 下载代码库
+**注明: 如果您正在使用Paddle开发镜像,需要在下载代码库后手动运行`bash env_install.sh`(如代码框的第三行所示)**
```
+git clone https://github.com/PaddlePaddle/Serving
+cd Serving && git submodule update --init --recursive
-如果使用其他Python版本,请使用对应版本的`pip`。
+# Paddle开发镜像需要运行如下命令,Serving开发镜像不需要运行
+bash tools/paddle_env_install.sh
+```
-## GOPATH 设置
+## 环境变量准备
-默认 GOPATH 设置为 `$HOME/go`,您也可以设置为其他值。** 如果是Serving提供的Docker环境,可以不需要设置。**
-```shell
-export GOPATH=$HOME/go
-export PATH=$PATH:$GOPATH/bin
+**设置PYTHON环境变量**
+
+如果您使用的是Serving开发镜像,请按照如下,确定好需要编译的Python版本,设置对应的环境变量,一共需要设置三个环境变量,分别是`PYTHON_INCLUDE_DIR`, `PYTHON_LIBRARIES`, `PYTHON_EXECUTABLE`。以下我们以python 3.7为例,介绍如何设置这三个环境变量。
+
+1) 设置`PYTHON_INCLUDE_DIR`
+
+搜索Python.h 所在的目录
```
+find / -name Python.h
+```
+通常会有类似于`**/include/python3.7/Python.h`出现,我们只需要取它的文件夹目录就好,比如找到`/usr/include/python3.7/Python.h`,那么我们只需要`export PYTHON_INCLUDE_DIR=/usr/include/python3.7/`就好。
+如果没有找到。说明 1)没有安装开发版本的Python,需重新安装 2)权限不足无法查看相关系统目录。
-## 获取 Go packages
+2) 设置`PYTHON_LIBRARIES`
-```shell
-go env -w GO111MODULE=on
-go env -w GOPROXY=https://goproxy.cn,direct
-go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.15.2
-go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.15.2
-go get -u github.com/golang/protobuf/protoc-gen-go@v1.4.3
-go get -u google.golang.org/grpc@v1.33.0
-go env -w GO111MODULE=auto
+搜索 libpython3.7.so
```
+find / -name libpython3.7.so
+```
+通常会有类似于`**/lib/libpython3.7.so`或者`**/lib/x86_64-linux-gnu/libpython3.7.so`出现,我们只需要取它的文件夹目录就好,比如找到`/usr/local/lib/libpython3.7.so`,那么我们只需要`export PYTHON_LIBRARIES=/usr/local/lib`就好。
+如果没有找到,说明 1)静态编译Python,需要重新安装动态编译的Python 2)全县不足无法查看相关系统目录。
+3) 设置`PYTHON_EXECUTABLE`
-## 编译Server部分
+直接查看python3.7路径
+```
+which python3.7
+```
+假如结果是`/usr/local/bin/python3.7`,那么直接设置`export PYTHON_EXECUTABLE=/usr/local/bin/python3.7`。
-### 集成CPU版本Paddle Inference Library
+设置好这三个环境变量至关重要,设置完成后,我们便可以执行下列操作(以下是Paddle Cuda 11.2的开发镜像的PYTHON环境,如果是其他镜像,请更改相应的`PYTHON_INCLUDE_DIR`, `PYTHON_LIBRARIES`, `PYTHON_EXECUTABLE`)。
-``` shell
-mkdir server-build-cpu && cd server-build-cpu
-cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR/ \
- -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
- -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
- -DSERVER=ON ..
-make -j10
```
+# 以下三个环境变量是Paddle开发镜像Cuda11.2的环境,如其他镜像可能需要修改
+export PYTHON_INCLUDE_DIR=/usr/include/python3.7m/
+export PYTHON_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython3.7m.so
+export PYTHON_EXECUTABLE=/usr/bin/python3.7
-可以执行`make install`把目标产出放在`./output`目录下,cmake阶段需添加`-DCMAKE_INSTALL_PREFIX=./output`选项来指定存放路径。
+export GOPATH=$HOME/go
+export PATH=$PATH:$GOPATH/bin
-### 集成GPU版本Paddle Inference Library
+python -m install -r python/requirements.txt
+
+go env -w GO111MODULE=on
+go env -w GOPROXY=https://goproxy.cn,direct
+go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.15.2
+go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.15.2
+go install github.com/golang/protobuf/protoc-gen-go@v1.4.3
+go install google.golang.org/grpc@v1.33.0
+go env -w GO111MODULE=auto
+```
-相比CPU环境,GPU环境需要参考以下表格,
-**需要说明的是,以下表格对非Docker编译环境作为参考,Docker编译环境已经配置好相关参数,无需在cmake过程指定。**
+如果您是GPU用户需要额外设置`CUDA_PATH`, `CUDNN_LIBRARY`, `CUDA_CUDART_LIBRARY`和`TENSORRT_LIBRARY_PATH`。
+```
+export CUDA_PATH='/usr/local/cuda'
+export CUDNN_LIBRARY='/usr/local/cuda/lib64/'
+export CUDA_CUDART_LIBRARY="/usr/local/cuda/lib64/"
+export TENSORRT_LIBRARY_PATH="/usr/"
+```
+环境变量的含义如下表所示。
| cmake环境变量 | 含义 | GPU环境注意事项 | Docker环境是否需要 |
|-----------------------|-------------------------------------|-------------------------------|--------------------|
-| CUDA_TOOLKIT_ROOT_DIR | cuda安装路径,通常为/usr/local/cuda | 全部环境都需要 | 否(/usr/local/cuda) |
-| CUDNN_LIBRARY | libcudnn.so.*所在目录,通常为/usr/local/cuda/lib64/ | 全部环境都需要 | 否(/usr/local/cuda/lib64/) |
-| CUDA_CUDART_LIBRARY | libcudart.so.*所在目录,通常为/usr/local/cuda/lib64/ | 全部环境都需要 | 否(/usr/local/cuda/lib64/) |
-| TENSORRT_ROOT | libnvinfer.so.*所在目录的上一级目录,取决于TensorRT安装目录 | Cuda 9.0/10.0不需要,其他需要 | 否(/usr) |
+| CUDA_TOOLKIT_ROOT_DIR | cuda安装路径,通常为/usr/local/cuda | 全部GPU环境都需要 | 否(/usr/local/cuda) |
+| CUDNN_LIBRARY | libcudnn.so.*所在目录,通常为/usr/local/cuda/lib64/ | 全部GPU环境都需要 | 否(/usr/local/cuda/lib64/) |
+| CUDA_CUDART_LIBRARY | libcudart.so.*所在目录,通常为/usr/local/cuda/lib64/ | 全部GPU环境都需要 | 否(/usr/local/cuda/lib64/) |
+| TENSORRT_ROOT | libnvinfer.so.*所在目录的上一级目录,取决于TensorRT安装目录 | 全部GPU环境都需要 | 否(/usr) |
-非Docker环境下,用户可以参考如下执行方式,具体的路径以当时环境为准,代码仅作为参考。TENSORRT_LIBRARY_PATH和TensorRT版本有关,要根据实际情况设置。例如在cuda10.1环境下TensorRT版本是6.0(/usr/local/TensorRT6-cuda10.1-cudnn7/targets/x86_64-linux-gnu/),在cuda10.2和cuda11.0环境下TensorRT版本是7.1(/usr/local/TensorRT-7.1.3.4/targets/x86_64-linux-gnu/)。
-``` shell
-export CUDA_PATH='/usr/local/cuda'
-export CUDNN_LIBRARY='/usr/local/cuda/lib64/'
-export CUDA_CUDART_LIBRARY="/usr/local/cuda/lib64/"
-export TENSORRT_LIBRARY_PATH="/usr/local/TensorRT6-cuda10.1-cudnn7/targets/x86_64-linux-gnu/"
-mkdir server-build-gpu && cd server-build-gpu
+## 正式编译
+
+我们一共需要编译三个目标,分别是`paddle-serving-server`, `paddle-serving-client`, `paddle-serving-app`,其中`paddle-serving-server`需要区分CPU或者GPU版本。如果是CPU版本请运行,
+
+### 编译paddle-serving-server
+
+```
+mkdir build_server
+cd build_server
+cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
+ -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
+ -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
+ -DSERVER=ON \
+ -DWITH_GPU=OFF ..
+make -j20
+cd ..
+```
+
+如果是GPU版本,请运行,
+```
+mkdir build_server
+cd build_server
cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
-DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
@@ -135,83 +192,76 @@ cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
-DTENSORRT_ROOT=${TENSORRT_LIBRARY_PATH} \
-DSERVER=ON \
-DWITH_GPU=ON ..
-make -j10
-```
-
-执行`make install`可以把目标产出放在`./output`目录下。
-
-### 开启WITH_OPENCV选项编译C++ Server
-**注意:** 只有当您需要对Paddle Serving C++部分进行二次开发,且新增的代码依赖于OpenCV库时,您才需要这样做。
+make -j20
+cd ..
+```
-编译Serving C++ Server部分,开启WITH_OPENCV选项时,需要已安装的OpenCV库,若尚未安装,可参考本文档后面的说明编译安装OpenCV库。
+### 编译paddle-serving-client 和 paddle-serving-app
-以开启WITH_OPENCV选项,编译CPU版本Paddle Inference Library为例,在上述编译命令基础上,加入`DOPENCV_DIR=${OPENCV_DIR}` 和 `DWITH_OPENCV=ON`选项。
-``` shell
-OPENCV_DIR=your_opencv_dir #`your_opencv_dir`为opencv库的安装路径。
-mkdir server-build-cpu && cd server-build-cpu
-cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR/ \
- -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
- -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
- -DOPENCV_DIR=${OPENCV_DIR} \
- -DWITH_OPENCV=ON \
- -DSERVER=ON ..
-make -j10
+接下来,我们继续编译client和app就可以了,这两个包的编译命令在所有平台通用,不区分CPU和GPU的版本。
```
-
-**注意:** 编译成功后,需要设置`SERVING_BIN`路径,详见后面的[注意事项](#注意事项)。
-
-
-## 编译Client部分
-
-``` shell
-mkdir client-build && cd client-build
+# 编译paddle-serving-client
+mkdir build_client
+cd build_client
cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
-DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
-DCLIENT=ON ..
make -j10
-```
-
-执行`make install`可以把目标产出放在`./output`目录下。
-
-
-
-## 编译App部分
+cd ..
-```bash
-mkdir app-build && cd app-build
+# 编译paddle-serving-app
+mkdir build_app
+cd build_app
cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
-DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
-DAPP=ON ..
-make
+make -j10
+cd ..
```
+## 安装相关whl包
+```
+pip3.7 install -r build_server/python/dist/*.whl
+pip3.7 install -r build_client/python/dist/*.whl
+pip3.7 install -r build_app/python/dist/*.whl
+export SERVING_BIN=${PWD}/build_server/core/general-server/serving
+```
+## 注意事项
-## 安装wheel包
-
-无论是Client端,Server端还是App部分,编译完成后,安装编译过程临时目录(`server-build-cpu`、`server-build-gpu`、`client-build`、`app-build`)下的`python/dist/` 中的whl包即可。
-例如:cd server-build-cpu/python/dist && pip install -U xxxxx.whl
-
+注意到上一小节的最后一行`export SERVING_BIN`,运行python端Server时,会检查`SERVING_BIN`环境变量,如果想使用自己编译的二进制文件,请将设置该环境变量为对应二进制文件的路径,通常是`export SERVING_BIN=${BUILD_DIR}/core/general-server/serving`。
+其中BUILD_DIR为`build_server`的绝对路径。
+可以cd build_server路径下,执行`export SERVING_BIN=${PWD}/core/general-server/serving`
+## 开启WITH_OPENCV选项编译C++ Server
-## 注意事项
+**注意:** 只有当您需要对Paddle Serving C++部分进行二次开发,且新增的代码依赖于OpenCV库时,您才需要这样做。
-运行python端Server时,会检查`SERVING_BIN`环境变量,如果想使用自己编译的二进制文件,请将设置该环境变量为对应二进制文件的路径,通常是`export SERVING_BIN=${BUILD_DIR}/core/general-server/serving`。
-其中BUILD_DIR为server-build-cpu或server-build-gpu的绝对路径。
-可以cd server-build-cpu路径下,执行`export SERVING_BIN=${PWD}/core/general-server/serving`
+编译Serving C++ Server部分,开启WITH_OPENCV选项时,需要已安装的OpenCV库,若尚未安装,可参考本文档后面的说明编译安装OpenCV库。
+以开启WITH_OPENCV选项,编译CPU版本Paddle Inference Library为例,在上述编译命令基础上,加入`DOPENCV_DIR=${OPENCV_DIR}` 和 `DWITH_OPENCV=ON`选项。
+``` shell
+OPENCV_DIR=your_opencv_dir #`your_opencv_dir`为opencv库的安装路径。
+mkdir build_server && cd build_server
+cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR/ \
+ -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
+ -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
+ -DOPENCV_DIR=${OPENCV_DIR} \
+ -DWITH_OPENCV=ON \
+ -DSERVER=ON ..
+make -j10
+```
+**注意:** 编译成功后,需要设置`SERVING_BIN`路径,详见后面的[注意事项](https://github.com/PaddlePaddle/Serving/blob/develop/doc/COMPILE_CN.md#注意事项)。
-## 如何验证
-请使用 `python/examples` 下的例子进行验证。
-## CMake选项说明
+## 附:CMake选项说明
| 编译选项 | 说明 | 默认 |
| :--------------: | :----------------------------------------: | :--: |
@@ -252,11 +302,11 @@ Paddle Serving通过PaddlePaddle预测库支持在GPU上做预测。WITH_GPU选
| post102 | 10.2 | CuDNN 8.0.5 | 7.1.3 |
| post11 | 11.0 | CuDNN 8.0.4 | 7.1.3 |
-### 如何让Paddle Serving编译系统探测到CuDNN库
+### 附:如何让Paddle Serving编译系统探测到CuDNN库
从NVIDIA developer官网下载对应版本CuDNN并在本地解压后,在cmake编译命令中增加`-DCUDNN_LIBRARY`参数,指定CuDNN库所在路径。
-## 编译安装OpenCV库
+## 附:编译安装OpenCV库
**注意:** 只有当您需要在C++代码中引入OpenCV库时,您才需要这样做。
* 首先需要从OpenCV官网上下载在Linux环境下源码编译的包,以OpenCV3.4.7为例,下载命令如下。
diff --git a/doc/Compile_EN.md b/doc/Compile_EN.md
index 49a42806ad5ce0f8cdccd79fa7c7fa99efdafabc..dd6d483972ab2db4cd51aa9399b3122f9e94532e 100644
--- a/doc/Compile_EN.md
+++ b/doc/Compile_EN.md
@@ -2,7 +2,19 @@
([简体中文](./Compile_CN.md)|English)
-## Compilation environment requirements
+## Overview
+
+Compiling Paddle Serving is divided into the following steps
+
+- Compilation Environment Preparation: According to the needs of the model and operating environment, select the most suitable image
+- Download the Serving Code Repo: Download the Serving code library, and perform initialization operations as needed
+- Environment Variable Preparation: According to the needs of the running environment, determine the various environment variables of Python. For example, the GPU environment also needs to determine the environment variables such as Cuda, Cudnn, TensorRT and so on.
+- Compilation: Compile `paddle-serving-server`, `paddle-serving-client`, `paddle-serving-app` related whl packages
+- Install Related Whl Packages: install the three compiled whl packages, and set the SERVING_BIN environment variable
+
+In addition, for some C++ secondary development scenarios, we also provide OPENCV binding solutions.
+
+## Compilation Environment Requirements
| module | version |
| :--------------------------: | :-------------------------------: |
@@ -11,7 +23,7 @@
| gcc-c++ | 5.4.0(Cuda 10.1) and 8.2.0 |
| cmake | 3.2.0 and later |
| Python | 3.6.0 and later |
-| Go | 1.9.2 and later |
+| Go | 1.17.2 and later |
| git | 2.17.1 and later |
| glibc-static | 2.17 |
| openssl-devel | 1.0.2k |
@@ -23,251 +35,278 @@
| libSM | 1.2.2 |
| libXrender | 0.9.10 |
-It is recommended to use Docker for compilation. We have prepared the Paddle Serving compilation environment for you, see [this document](Docker_Images_EN.md).
+Docker compilation is recommended. We have prepared the Paddle Serving compilation environment for you and configured the above compilation dependencies. For details, please refer to [this document](DOCKER_IMAGES_CN.md).
-## Get Code
+We provide five environment development images, namely CPU, Cuda10.1+Cudnn7, Cuda10.2+Cudnn7, Cuda10.2+Cudnn8, Cuda11.2+Cudnn8. We provide a Serving development image to cover the above environment. At the same time, we also support Paddle development mirroring.
-``` python
-git clone https://github.com/PaddlePaddle/Serving
-cd Serving && git submodule update --init --recursive
+The Serving image name is **paddlepaddle/serving:${Serving development image Tag}** (If the network is not good, you can visit **registry.baidubce.com/paddlepaddle/serving:${Serving development image Tag}**), The name of the Paddle development image is **paddlepaddle/paddle:${Paddle Development Image Tag}**. In order to prevent users from confusing the two sets of mirroring, we explain the origin of the two sets of mirroring separately.
+
+Serving development mirror is the mirror used to compile and debug prediction services provided by Serving suite in order to support various prediction environments. Paddle development mirror is the mirror used for compilation, development, and training models released by Paddle on the official website. In order to allow Paddle developers to use Serving directly in the same container. For developers who have already used Serving users in the previous version, Serving development image should not be unfamiliar. But for developers who are familiar with the Paddle training framework ecology, they should be more familiar with the existing Paddle development mirrors. In order to adapt to the different habits of all users, we have fully supported both sets of mirrors.
+
+| Environment | Serving Dev Image Tag | OS | Paddle Dev Image Tag | OS |
+| :--------------------------: | :-------------------------------: | :-------------: | :-------------------: | :----------------: |
+| CPU | 0.7.0-devel | Ubuntu 16.04 | 2.2.0 | Ubuntu 18.04. |
+| Cuda10.1+Cudnn7 | 0.7.0-cuda10.1-cudnn7-devel | Ubuntu 16.04 | Nan | Nan |
+| Cuda10.2+Cudnn7 | 0.7.0-cuda10.2-cudnn7-devel | Ubuntu 16.04 | 2.2.0-cuda10.2-cudnn7 | Ubuntu 16.04 |
+| Cuda10.2+Cudnn8 | 0.7.0-cuda10.2-cudnn8-devel | Ubuntu 16.04 | Nan | Nan |
+| Cuda11.2+Cudnn8 | 0.7.0-cuda11.2-cudnn8-devel | Ubuntu 16.04 | 2.2.0-cuda11.2-cudnn8 | Ubuntu 18.04 |
+
+We first need to pull related images for the environment we need. Under the **Environment** column in the above table, except for the CPU, the rest (Cuda**+Cudnn**) belong to the GPU environment.
+
+You can use Serving Dev Images.
```
+docker pull paddlepaddle/serving:${Serving Dev Image Tag}
-## PYTHONROOT settings
+# For GPU Image
+nvidia-docker run --rm -it paddlepaddle/serving:${Serving Dev Image Tag} bash
-```shell
-# For example, the path of python is /usr/bin/python, you can set PYTHONROOT
-export PYTHONROOT=/usr
+# For CPU Image
+docker run --rm -it paddlepaddle/serving:${Serving Dev Image Tag} bash
```
-If you are using a Docker development image, please follow the following to determine the Python version to be compiled, and set the corresponding environment variables
+You can also use Paddle Dev Images.
+## Download the Serving Code Repo
+**Note: If you are using Paddle to develop the image, you need to manually run `bash env_install.sh` after downloading the code base (as shown in the third line of the code box)**
```
-#Python3.6
-export PYTHONROOT=/usr/local/
-export PYTHON_INCLUDE_DIR=$PYTHONROOT/include/python3.6m
-export PYTHON_LIBRARIES=$PYTHONROOT/lib/libpython3.6m.so
-export PYTHON_EXECUTABLE=$PYTHONROOT/bin/python3.6
-
-#Python3.7
-export PYTHONROOT=/usr/local/
-export PYTHON_INCLUDE_DIR=$PYTHONROOT/include/python3.7m
-export PYTHON_LIBRARIES=$PYTHONROOT/lib/libpython3.7m.so
-export PYTHON_EXECUTABLE=$PYTHONROOT/bin/python3.7
-
-#Python3.8
-export PYTHONROOT=/usr/local/
-export PYTHON_INCLUDE_DIR=$PYTHONROOT/include/python3.8
-export PYTHON_LIBRARIES=$PYTHONROOT/lib/libpython3.8.so
-export PYTHON_EXECUTABLE=$PYTHONROOT/bin/python3.8
+git clone https://github.com/PaddlePaddle/Serving
+cd Serving && git submodule update --init --recursive
+# Paddle development image needs to run the following commands, Serving development image does not need to run
+bash tools/paddle_env_install.sh
```
-## Install Python dependencies
+## Environment Variables Preparation
-```shell
-pip install -r python/requirements.txt -i https://mirror.baidu.com/pypi/simple
-```
+**Set PYTHON environment variable**
-If you use other Python version, please use the right `pip` accordingly.
+If you are using a Serving development image, please follow the steps below to determine the Python version that needs to be compiled and set the corresponding environment variables. A total of three environment variables need to be set, namely `PYTHON_INCLUDE_DIR`, `PYTHON_LIBRARIES`, `PYTHON_EXECUTABLE`. Below we take python 3.7 as an example to introduce how to set these three environment variables.
-## GOPATH Setting
-The default GOPATH is set to `$HOME/go`, you can also set it to other values. **If it is the Docker environment provided by Serving, you do not need to set up.**
+1) Set `PYTHON_INCLUDE_DIR`
-```shell
-export GOPATH=$HOME/go
-export PATH=$PATH:$GOPATH/bin
+Search the directory where Python.h is located
```
+find / -name Python.h
+```
+Usually there will be something like `**/include/python3.7/Python.h`, we only need to take its folder directory, for example, find `/usr/include/python3.7/Python.h`, Then we only need `export PYTHON_INCLUDE_DIR=/usr/include/python3.7/`.
+If not found. Explanation 1) The development version of Python is not installed and needs to be re-installed. 2) Insufficient permissions cannot view the relevant system directories.
-## Get go packages
+2) Set `PYTHON_LIBRARIES`
-```shell
-go env -w GO111MODULE=on
-go env -w GOPROXY=https://goproxy.cn,direct
-go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.15.2
-go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.15.2
-go get -u github.com/golang/protobuf/protoc-gen-go@v1.4.3
-go get -u google.golang.org/grpc@v1.33.0
-go env -w GO111MODULE=auto
+Search for libpython3.7.so
```
+find / -name libpython3.7.so
+```
+Usually there will be something similar to `**/lib/libpython3.7.so` or `**/lib/x86_64-linux-gnu/libpython3.7.so`, we only need to take its folder directory, For example, find `/usr/local/lib/libpython3.7.so`, then we only need `export PYTHON_LIBRARIES=/usr/local/lib`.
+If it is not found, it means 1) Statically compiling Python, you need to reinstall the dynamically compiled Python 2) The county is not enough to view the relevant system catalogs.
+3) Set `PYTHON_EXECUTABLE`
-## Compile Server
+View the python3.7 path directly
+```
+which python3.7
+```
+If the result is `/usr/local/bin/python3.7`, then directly set `export PYTHON_EXECUTABLE=/usr/local/bin/python3.7`.
-### Integrated CPU version paddle inference library
+It is very important to set these three environment variables. After the settings are completed, we can perform the following operations (the following is the PYTHON environment of the development image of Paddle Cuda 11.2, if it is another image, please change the corresponding `PYTHON_INCLUDE_DIR`, `PYTHON_LIBRARIES` , `PYTHON_EXECUTABLE`).
-``` shell
-mkdir server-build-cpu && cd server-build-cpu
-cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
- -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
- -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
- -DSERVER=ON ..
-make -j10
```
+# The following three environment variables are the environment of Paddle development mirror Cuda11.2, such as other mirrors may need to be modified
+export PYTHON_INCLUDE_DIR=/usr/include/python3.7m/
+export PYTHON_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython3.7m.so
+export PYTHON_EXECUTABLE=/usr/bin/python3.7
-you can execute `make install` to put targets under directory `./output`, you need to add`-DCMAKE_INSTALL_PREFIX=./output`to specify output path to cmake command shown above.
+export GOPATH=$HOME/go
+export PATH=$PATH:$GOPATH/bin
-### Integrated GPU version paddle inference library
+python -m install -r python/requirements.txt
+
+go env -w GO111MODULE=on
+go env -w GOPROXY=https://goproxy.cn,direct
+go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.15.2
+go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.15.2
+go install github.com/golang/protobuf/protoc-gen-go@v1.4.3
+go install google.golang.org/grpc@v1.33.0
+go env -w GO111MODULE=auto
+```
-Compared with CPU environment, GPU environment needs to refer to the following table,
-**It should be noted that the following table is used as a reference for non-Docker compilation environment. The Docker compilation environment has been configured with relevant parameters and does not need to be specified in cmake process. **
+If you are a GPU user, you need to set additional `CUDA_PATH`, `CUDNN_LIBRARY`, `CUDA_CUDART_LIBRARY` and `TENSORRT_LIBRARY_PATH`.
+```
+export CUDA_PATH='/usr/local/cuda'
+export CUDNN_LIBRARY='/usr/local/cuda/lib64/'
+export CUDA_CUDART_LIBRARY="/usr/local/cuda/lib64/"
+export TENSORRT_LIBRARY_PATH="/usr/"
+```
+The meaning of environment variables is shown in the table below.
| cmake environment variable | meaning | GPU environment considerations | whether Docker environment is needed |
|-----------------------|-------------------------------------|-------------------------------|--------------------|
| CUDA_TOOLKIT_ROOT_DIR | cuda installation path, usually /usr/local/cuda | Required for all environments | No (/usr/local/cuda) |
| CUDNN_LIBRARY | The directory where libcudnn.so.* is located, usually /usr/local/cuda/lib64/ | Required for all environments | No (/usr/local/cuda/lib64/) |
| CUDA_CUDART_LIBRARY | The directory where libcudart.so.* is located, usually /usr/local/cuda/lib64/ | Required for all environments | No (/usr/local/cuda/lib64/) |
-| TENSORRT_ROOT | The upper level directory of the directory where libnvinfer.so.* is located, depends on the TensorRT installation directory | Cuda 9.0/10.0 does not need, other needs | No (/usr) |
+| TENSORRT_ROOT | The upper level directory of the directory where libnvinfer.so.* is located, depends on the TensorRT installation directory | Required for all environments | No (/usr) |
-If not in Docker environment, users can refer to the following execution methods. The specific path is subject to the current environment, and the code is only for reference.TENSORRT_LIBRARY_PATH is related to the TensorRT version and should be set according to the actual situation。For example, in the cuda10.1 environment, the TensorRT version is 6.0 (/usr/local/TensorRT6-cuda10.1-cudnn7/targets/x86_64-linux-gnu/),In the cuda10.2 and cuda11.0 environment, the TensorRT version is 7.1 (/usr/local/TensorRT-7.1.3.4/targets/x86_64-linux-gnu/).
-
-``` shell
-export CUDA_PATH='/usr/local/cuda'
-export CUDNN_LIBRARY='/usr/local/cuda/lib64/'
-export CUDA_CUDART_LIBRARY="/usr/local/cuda/lib64/"
-export TENSORRT_LIBRARY_PATH="/usr/local/TensorRT6-cuda10.1-cudnn7/targets/x86_64-linux-gnu/"
-mkdir server-build-gpu && cd server-build-gpu
-cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
- -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
- -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
- -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_PATH} \
- -DCUDNN_LIBRARY=${CUDNN_LIBRARY} \
- -DCUDA_CUDART_LIBRARY=${CUDA_CUDART_LIBRARY} \
- -DTENSORRT_ROOT=${TENSORRT_LIBRARY_PATH} \
- -DSERVER=ON \
- -DWITH_GPU=ON ..
-make -j10
-```
+## Compilation
-Execute `make install` to put the target output in the `./output` directory.
+We need to compile three targets in total, namely `paddle-serving-server`, `paddle-serving-client`, and `paddle-serving-app`, among which `paddle-serving-server` needs to distinguish between CPU or GPU version. If it is a CPU version, please run,
-### Compile C++ Server under the condition of WITH_OPENCV=ON
-**Note:** Only when you need to redevelop the paddle serving C + + part, and the new code depends on the OpenCV library, you need to do so.
+### Compile paddle-serving-server
-First of all , OpenCV library should be installed, if not, please refer to the `Compile and install OpenCV` section later in this article.
+```
+mkdir build_server
+cd build_server
+cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
+ -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
+ -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
+ -DSERVER=ON \
+ -DWITH_GPU=OFF ..
+make -j20
+cd ..
+```
-In the compile command, add `DOPENCV_DIR=${OPENCV_DIR}` and `DWITH_OPENCV=ON`,for example:
-``` shell
-OPENCV_DIR=your_opencv_dir #`your_opencv_dir` is the installation path of OpenCV library。
-mkdir server-build-cpu && cd server-build-cpu
-cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR/ \
- -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
- -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
- -DOPENCV_DIR=${OPENCV_DIR} \
- -DWITH_OPENCV=ON \
- -DSERVER=ON ..
-make -j10
+If it is the GPU version, please run,
+```
+mkdir build_server
+cd build_server
+cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
+ -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
+ -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
+ -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_PATH} \
+ -DCUDNN_LIBRARY=${CUDNN_LIBRARY} \
+ -DCUDA_CUDART_LIBRARY=${CUDA_CUDART_LIBRARY} \
+ -DTENSORRT_ROOT=${TENSORRT_LIBRARY_PATH} \
+ -DSERVER=ON \
+ -DWITH_GPU=ON ..
+make -j20
+cd ..
```
+
**Note:** After the compilation is successful, you need to set the `SERVING_BIN` path, see the following [Notes](Compile_EN.md#Note).
-## Compile Client
+### Compile paddle-serving-client and paddle-serving-app
-``` shell
-mkdir client-build && cd client-build
+Next, we can continue to compile the client and app. The compilation commands for these two packages are common on all platforms, and do not distinguish between CPU and GPU versions.
+```
+# Compile paddle-serving-client
+mkdir build_client
+cd build_client
cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
-DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
-DCLIENT=ON ..
make -j10
-```
-
-execute `make install` to put targets under directory `./output`
-
-
-
-## Compile the App
+cd ..
-```bash
-mkdir app-build && cd app-build
+# Compile paddle-serving-app
+mkdir build_app
+cd build_app
cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
-DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
-DAPP=ON ..
-make
+make -j10
+cd ..
```
+## Install Related Whl Packages
+```
+pip3.7 install -r build_server/python/dist/*.whl
+pip3.7 install -r build_client/python/dist/*.whl
+pip3.7 install -r build_app/python/dist/*.whl
+export SERVING_BIN=${PWD}/build_server/core/general-server/serving
+```
+## Precautions
-## Install wheel package
-
-Regardless of the client, server or App part, after compiling, install the whl package in `python/dist/` in the temporary directory(`server-build-cpu`, `server-build-gpu`, `client-build`,`app-build`) of the compilation process.
-for example:cd server-build-cpu/python/dist && pip install -U xxxxx.whl
+Note the last line `export SERVING_BIN` in the previous section. When running the python server, the `SERVING_BIN` environment variable will be checked. If you want to use the binary file compiled by yourself, please set the environment variable to the path of the corresponding binary file. It is `export SERVING_BIN=${BUILD_DIR}/core/general-server/serving`.
+Where BUILD_DIR is the absolute path of `build_server`.
+You can cd build_server path and execute `export SERVING_BIN=${PWD}/core/general-server/serving`
+## Enable WITH_OPENCV option to compile C++ Server
-## Note
+**Note:** You only need to do this when you need to do secondary development on the Paddle Serving C++ part and the newly added code depends on the OpenCV library.
-When running the python server, it will check the `SERVING_BIN` environment variable. If you want to use your own compiled binary file, set the environment variable to the path of the corresponding binary file, usually`export SERVING_BIN=${BUILD_DIR}/core/general-server/serving`.
-BUILD_DIR is the absolute path of server build CPU or server build GPU。
-for example: cd server-build-cpu && export SERVING_BIN=${PWD}/core/general-server/serving
+To compile the Serving C++ Server part, when the WITH_OPENCV option is turned on, the installed OpenCV library is required. If it has not been installed, you can refer to the instructions at the back of this document to compile and install the OpenCV library.
+Take the WITH_OPENCV option and compile the CPU version Paddle Inference Library as an example. On the basis of the above compilation command, add the `DOPENCV_DIR=${OPENCV_DIR}` and `DWITH_OPENCV=ON` options.
+``` shell
+OPENCV_DIR=your_opencv_dir #`your_opencv_dir` is the installation path of the opencv library.
+mkdir build_server && cd build_server
+cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR/ \
+ -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
+ -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
+ -DOPENCV_DIR=${OPENCV_DIR} \
+ -DWITH_OPENCV=ON \
+ -DSERVER=ON ..
+make -j10
+```
+**Note:** After the compilation is successful, you need to set the `SERVING_BIN` path, see the following [Notes](https://github.com/PaddlePaddle/Serving/blob/develop/doc/COMPILE_CN.md#Notes) ).
-## Verify
-Please use the example under `python/examples` to verify.
-## CMake Option Description
+## Attached: CMake option description
-| Compile Options | Description | Default |
-| :--------------: | :----------------------------------------: | :--: |
-| WITH_AVX | Compile Paddle Serving with AVX intrinsics | OFF |
-| WITH_MKL | Compile Paddle Serving with MKL support | OFF |
-| WITH_GPU | Compile Paddle Serving with NVIDIA GPU | OFF |
-| WITH_OPENCV | Compile Paddle Serving with OPENCV | OFF |
-| CUDNN_LIBRARY | Define CuDNN library and header path | |
-| CUDA_TOOLKIT_ROOT_DIR | Define CUDA PATH | |
-| TENSORRT_ROOT | Define TensorRT PATH | |
-| CLIENT | Compile Paddle Serving Client | OFF |
-| SERVER | Compile Paddle Serving Server | OFF |
-| APP | Compile Paddle Serving App package | OFF |
-| PACK | Compile for whl | OFF |
+| Compilation Options | Description | Default |
+| :--------------: | :------------------------------- ---------: | :--: |
+| WITH_AVX | Compile Paddle Serving with AVX intrinsics | OFF |
+| WITH_MKL | Compile Paddle Serving with MKL support | OFF |
+| WITH_GPU | Compile Paddle Serving with NVIDIA GPU | OFF |
+| WITH_TRT | Compile Paddle Serving with TensorRT | OFF |
+| WITH_OPENCV | Compile Paddle Serving with OPENCV | OFF |
+| CUDNN_LIBRARY | Define CuDNN library and header path | |
+| CUDA_TOOLKIT_ROOT_DIR | Define CUDA PATH | |
+| TENSORRT_ROOT | Define TensorRT PATH | |
+| CLIENT | Compile Paddle Serving Client | OFF |
+| SERVER | Compile Paddle Serving Server | OFF |
+| APP | Compile Paddle Serving App package | OFF |
+| PACK | Compile for whl | OFF |
-### WITH_GPU Option
+### WITH_GPU option
-Paddle Serving supports prediction on the GPU through the PaddlePaddle inference library. The WITH_GPU option is used to detect basic libraries such as CUDA/CUDNN on the system. If an appropriate version is detected, the GPU Kernel will be compiled when PaddlePaddle is compiled.
+Paddle Serving supports prediction on the GPU through the PaddlePaddle prediction library. The WITH_GPU option is used to detect basic libraries such as CUDA/CUDNN on the system. If a suitable version is detected, the GPU version of the OP Kernel will be compiled when the PaddlePaddle is compiled.
To compile the Paddle Serving GPU version on bare metal, you need to install these basic libraries:
-- CUDA
-- CuDNN
+-CUDA
+-CuDNN
To compile the TensorRT version, you need to install the TensorRT library.
-Note here:
-
-1. The basic library versions such as CUDA/CUDNN installed on the system where Serving is compiled, needs to be compatible with the actual GPU device. For example, the Tesla V100 card requires at least CUDA 9.0. If the version of the basic library such as CUDA used during compilation is too low, the generated GPU code is not compatible with the actual hardware device, which will cause the Serving process to fail to start or serious problems such as coredump.
-2. Install the CUDA driver compatible with the actual GPU device on the system running Paddle Serving, and install the basic library compatible with the CUDA/CuDNN version used during compilation. If the version of CUDA/CuDNN installed on the system running Paddle Serving is lower than the version used at compile time, it may cause some cuda function call failures and other problems.
+The things to note here are:
+1. Compile the basic library versions such as CUDA/CUDNN installed on the system where Serving is located, and need to be compatible with the actual GPU device. For example, Tesla V100 card requires at least CUDA 9.0. If the version of basic libraries such as CUDA used during compilation is too low, the Serving process cannot be started due to the incompatibility between the generated GPU code and the actual hardware device, or serious problems such as coredump may occur.
+2. Install the CUDA driver compatible with the actual GPU device on the system running Paddle Serving, and install the basic library compatible with the CUDA/CuDNN version used during compilation. If the version of CUDA/CuDNN installed on the system running Paddle Serving is lower than the version used during compilation, it may cause strange cuda function call failures and other problems.
-The following is the base library version matching relationship used by the PaddlePaddle release version for reference:
+The following is the matching relationship between PaddleServing mirrored Cuda, Cudnn, and TensorRT for reference:
-| | CUDA | CuDNN | TensorRT |
-| :----: | :-----: | :----------: | :----: |
-| post101 | 10.1 | CuDNN 7.6.5 | 6.0.1 |
-| post102 | 10.2 | CuDNN 8.0.5 | 7.1.3 |
-| post11 | 11.0 | CuDNN 8.0.4 | 7.1.3 |
+| | CUDA | CuDNN | TensorRT |
+| :----: | :-----: | :----------: | :----: |
+| post101 | 10.1 | CuDNN 7.6.5 | 6.0.1 |
+| post102 | 10.2 | CuDNN 8.0.5 | 7.1.3 |
+| post11 | 11.0 | CuDNN 8.0.4 | 7.1.3 |
-### How to make the compiler detect the CuDNN library
+### Attachment: How to make the Paddle Serving compilation system detect the CuDNN library
-Download the corresponding CUDNN version from NVIDIA developer official website and decompressing it, add `-DCUDNN_ROOT` to cmake command, to specify the path of CUDNN.
+After downloading the corresponding version of CuDNN from the official website of NVIDIA developer and decompressing it locally, add the `-DCUDNN_LIBRARY` parameter to the cmake compilation command and specify the path of the CuDNN library.
-## Compile and install OpenCV
-**Note:** You need to do this only if you need to import the opencv library into your C + + code.
+## Attachment: Compile and install OpenCV library
+**Note:** You only need to do this when you need to include the OpenCV library in your C++ code.
-* First of all, you need to download the source code compiled package in the Linux environment from the OpenCV official website. Taking OpenCV3.4.7 as an example, the download command is as follows.
+* First, you need to download the package compiled from the source code in the Linux environment from the OpenCV official website. Take OpenCV 3.4.7 as an example. The download command is as follows.
```
wget https://github.com/opencv/opencv/archive/3.4.7.tar.gz
tar -xf 3.4.7.tar.gz
```
-Finally, you can see the folder of `opencv-3.4.7/` in the current directory.
-
-* Compile OpenCV, the OpenCV source path (`root_path`) and installation path (`install_path`) should be set by yourself. Enter the OpenCV source code path and compile it in the following way.
+Finally, you can see the folder `opencv-3.4.7/` in the current directory.
+* Compile OpenCV, set the OpenCV source path (`root_path`) and installation path (`install_path`). Enter the OpenCV source code path and compile in the following way.
```shell
root_path=your_opencv_root_path
@@ -299,11 +338,10 @@ make -j
make install
```
-Among them, `root_path` is the downloaded OpenCV source code path, and `install_path` is the installation path of OpenCV. After `make install` is completed, the OpenCV header file and library file will be generated in this folder for later source code compilation.
-
+Among them, `root_path` is the downloaded OpenCV source path, `install_path` is the installation path of OpenCV, after the completion of `make install`, OpenCV header files and library files will be generated in this folder, which are used to compile the code that references the OpenCV library .
-The final file structure under the OpenCV installation path is as follows.
+The final file structure under the installation path is as follows.
```
opencv3/
diff --git a/doc/Docker_Images_CN.md b/doc/Docker_Images_CN.md
index 183e046e067962842e868a997a7e12433e81ed8e..1d8015ec8e45c388c6161e417cc332b7bb9f4086 100644
--- a/doc/Docker_Images_CN.md
+++ b/doc/Docker_Images_CN.md
@@ -8,10 +8,10 @@
您可以通过两种方式获取镜像。
-1. 通过 TAG 直接从 `registry.baidubce.com ` 或 拉取镜像,具体TAG请参见下文的**镜像说明**章节的表格。
+1. 通过 TAG 直接从 dockerhub 或 `registry.baidubce.com` 拉取镜像,具体TAG请参见下文的**镜像说明**章节的表格。
```shell
- docker pull registry.baidubce.com/paddlepaddle/serving:
Quick Start Example
+| Environment | Serving Development Image Tag | Operating System | Paddle Development Image Tag | Operating System |
+| :--------------------------: | :-------------------------------: | :-------------: | :-------------------: | :----------------: |
+| CPU | 0.7.0-devel | Ubuntu 16.04 | 2.2.0 | Ubuntu 18.04. |
+| Cuda10.1+Cudnn7 | 0.7.0-cuda10.1-cudnn7-devel | Ubuntu 16.04 | 无 | 无 |
+| Cuda10.2+Cudnn7 | 0.7.0-cuda10.2-cudnn7-devel | Ubuntu 16.04 | 2.2.0-cuda10.2-cudnn7 | Ubuntu 16.04 |
+| Cuda10.2+Cudnn8 | 0.7.0-cuda10.2-cudnn8-devel | Ubuntu 16.04 | 无 | 无 |
+| Cuda11.2+Cudnn8 | 0.7.0-cuda11.2-cudnn8-devel | Ubuntu 16.04 | 2.2.0-cuda11.2-cudnn8 | Ubuntu 18.04 |
-This quick start example is mainly for those users who already have a model to deploy, and we also provide a model that can be used for deployment. in case if you want to know how to complete the process from offline training to online service, please refer to the AiStudio tutorial above.
+For **Windows 10 users**, please refer to the document [Paddle Serving Guide for Windows Platform](Windows_Tutorial_CN.md).
diff --git a/doc/Latest_Packages_CN.md b/doc/Latest_Packages_CN.md
index 022ae75ab824ed8462f876f8d57b9097720cc18d..924844013b1e445665b94249f84ee8b89335db35 100644
--- a/doc/Latest_Packages_CN.md
+++ b/doc/Latest_Packages_CN.md
@@ -10,14 +10,15 @@ https://paddle-serving.bj.bcebos.com/test-dev/whl/paddle_serving_server-0.0.0-py
## GPU server
### Python 3
```
-#cuda10.1 with TensorRT 6, Compile by gcc8.2
+#cuda10.1 Cudnn 7 with TensorRT 6, Compile by gcc8.2
https://paddle-serving.bj.bcebos.com/test-dev/whl/paddle_serving_server_gpu-0.0.0.post101-py3-none-any.whl
-#cuda10.2 with TensorRT 7, Compile by gcc8.2
+#cuda10.2 Cudnn 7 with TensorRT 6, Compile by gcc5.4
https://paddle-serving.bj.bcebos.com/test-dev/whl/paddle_serving_server_gpu-0.0.0.post102-py3-none-any.whl
-#cuda11.0 with TensorRT 7 (beta), Compile by gcc8.2
-https://paddle-serving.bj.bcebos.com/test-dev/whl/paddle_serving_server_gpu-0.0.0.post11-py3-none-any.whl
+#cuda10.2 Cudnn 8 with TensorRT 7, Compile by gcc8.2
+https://paddle-serving.bj.bcebos.com/test-dev/whl/paddle_serving_server_gpu-0.0.0.post1028-py3-none-any.whl
+#cuda11.2 Cudnn 8 with TensorRT 8 (beta), Compile by gcc8.2
+https://paddle-serving.bj.bcebos.com/test-dev/whl/paddle_serving_server_gpu-0.0.0.post112-py3-none-any.whl
```
-**Tips:** If you want to use CPU server and GPU server at the same time, you should check the gcc version, only Cuda10.1/10.2/11 can run with CPU server owing to the same gcc version(8.2).
## Client
@@ -48,16 +49,16 @@ for kunlun user who uses arm-xpu or x86-xpu can download the wheel packages as f
for arm kunlun user
```
-https://paddle-serving.bj.bcebos.com/whl/xpu/0.6.0/paddle_serving_server_xpu-0.6.0.post2-cp36-cp36m-linux_aarch64.whl
-https://paddle-serving.bj.bcebos.com/whl/xpu/0.6.0/paddle_serving_client-0.6.0-cp36-cp36m-linux_aarch64.whl
-https://paddle-serving.bj.bcebos.com/whl/xpu/0.6.0/paddle_serving_app-0.6.0-cp36-cp36m-linux_aarch64.whl
+https://paddle-serving.bj.bcebos.com/whl/xpu/0.7.0/paddle_serving_server_xpu-0.7.0.post2-cp36-cp36m-linux_aarch64.whl
+https://paddle-serving.bj.bcebos.com/whl/xpu/0.7.0/paddle_serving_client-0.7.0-cp36-cp36m-linux_aarch64.whl
+https://paddle-serving.bj.bcebos.com/whl/xpu/0.7.0/paddle_serving_app-0.7.0-cp36-cp36m-linux_aarch64.whl
```
for x86 kunlun user
```
-https://paddle-serving.bj.bcebos.com/whl/xpu/0.6.0/paddle_serving_server_xpu-0.6.0.post2-cp36-cp36m-linux_x86_64.whl
-https://paddle-serving.bj.bcebos.com/whl/xpu/0.6.0/paddle_serving_client-0.6.0-cp36-cp36m-linux_x86_64.whl
-https://paddle-serving.bj.bcebos.com/whl/xpu/0.6.0/paddle_serving_app-0.6.0-cp36-cp36m-linux_x86_64.whl
+https://paddle-serving.bj.bcebos.com/whl/xpu/0.7.0/paddle_serving_server_xpu-0.7.0.post2-cp36-cp36m-linux_x86_64.whl
+https://paddle-serving.bj.bcebos.com/whl/xpu/0.7.0/paddle_serving_client-0.7.0-cp36-cp36m-linux_x86_64.whl
+https://paddle-serving.bj.bcebos.com/whl/xpu/0.7.0/paddle_serving_app-0.7.0-cp36-cp36m-linux_x86_64.whl
```
@@ -74,10 +75,12 @@ https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-cpu-avx-openblas-0.0.0
https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-cpu-noavx-openblas-0.0.0.tar.gz
# Cuda 10.1
https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-gpu-101-0.0.0.tar.gz
-# Cuda 10.2
+# Cuda 10.2 + Cudnn 7
https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-gpu-102-0.0.0.tar.gz
-# Cuda 11
-https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-gpu-cuda11-0.0.0.tar.gz
+# Cuda 10.2 + Cudnn 8
+https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-gpu-1028-0.0.0.tar.gz
+# Cuda 11.2
+https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-gpu-cuda112-0.0.0.tar.gz
```
#### How to setup SERVING_BIN offline?
diff --git a/doc/Python_Pipeline/Pipeline_Design_CN.md b/doc/Python_Pipeline/Pipeline_Design_CN.md
index 5d122d747557707260c55af8b87d7aeb7a959dfb..5bb083b2079dca9391fdc61d62ede9145fd7f46a 100644
--- a/doc/Python_Pipeline/Pipeline_Design_CN.md
+++ b/doc/Python_Pipeline/Pipeline_Design_CN.md
@@ -20,7 +20,7 @@ Paddle Serving提供了用户友好的多模型组合服务编程框架,Pipeli
Server端基于RPC服务层和图执行引擎构建,两者的关系如下图所示。
diff --git a/doc/Serving_Design_EN.md b/doc/Serving_Design_EN.md
index d7cd9ac8b5b88a8550f5a74c897bc15dc218b6bc..8a77d7552a33327d172e64e2bf67d604ec42aed9 100644
--- a/doc/Serving_Design_EN.md
+++ b/doc/Serving_Design_EN.md
@@ -53,7 +53,7 @@ Paddle Serving takes into account a series of issues such as different operating
Cross-platform is not dependent on the operating system, nor on the hardware environment. Applications developed under one operating system can still run under another operating system. Therefore, the design should consider not only the development language and the cross-platform components, but also the interpretation differences of the compilers on different systems.
-Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable container, and then publish it to any popular Linux machine or Windows machine. We have packaged a variety of Docker images for the Paddle Serving framework. Refer to the image list《[Docker Images](Docker_Images_EN.md)》, Select mirrors according to user's usage. We provide Docker usage documentation《[How to run PaddleServing in Docker](Run_In_Docker_EN.md)》.Currently, the Python webservice mode can be deployed and run on the native Linux and Windows dual systems.《[Paddle Serving for Windows Users](Windows_Tutorial_EN.md)》
+Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable container, and then publish it to any popular Linux machine or Windows machine. We have packaged a variety of Docker images for the Paddle Serving framework. Refer to the image list《[Docker Images](Docker_Images_EN.md)》, Select mirrors according to user's usage. We provide Docker usage documentation《[How to run PaddleServing in Docker](Install_EN.md)》.Currently, the Python webservice mode can be deployed and run on the native Linux and Windows dual systems.《[Paddle Serving for Windows Users](Windows_Tutorial_EN.md)》
> Support multiple development languages client SDKs
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index 86740ce6033f9dbab490e9b9df21ffd17ebe0cd0..986fd8ee289677234407d7ee2fc4d492933731ba 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -73,7 +73,7 @@ if (SERVER)
set(VERSION_SUFFIX 101)
elseif(CUDA_VERSION EQUAL 10.2)
if(CUDNN_MAJOR_VERSION EQUAL 7)
- set(VERSION_SUFFIX 1027)
+ set(VERSION_SUFFIX 102)
elseif(CUDNN_MAJOR_VERSION EQUAL 8)
set(VERSION_SUFFIX 1028)
endif()
diff --git a/python/paddle_serving_server/server.py b/python/paddle_serving_server/server.py
index 909cb8764bb7572af079e9a51c4f76dbd86441e0..c6446ac2dc61fa7a2123e6713b84624776435863 100755
--- a/python/paddle_serving_server/server.py
+++ b/python/paddle_serving_server/server.py
@@ -429,7 +429,7 @@ class Server(object):
if device_type == "0":
device_version = self.get_device_version()
elif device_type == "1":
- if version_suffix == "101" or version_suffix == "1027" or version_suffix == "1028" or version_suffix == "112":
+ if version_suffix == "101" or version_suffix == "102" or version_suffix == "1028" or version_suffix == "112":
device_version = "gpu-" + version_suffix
else:
device_version = "gpu-cuda" + version_suffix
diff --git a/tools/paddle_env_install.sh b/tools/paddle_env_install.sh
new file mode 100644
index 0000000000000000000000000000000000000000..3f062027b427daaf3cc64612ab5982bdc2c1374c
--- /dev/null
+++ b/tools/paddle_env_install.sh
@@ -0,0 +1,35 @@
+unset GREP_OPTIONS
+
+function install_trt(){
+ CUDA_VERSION=$(nvcc --version | egrep -o "V[0-9]+.[0-9]+" | cut -c2-)
+ if [ $CUDA_VERSION == "10.2" ]; then
+ wget https://paddle-ci.gz.bcebos.com/TRT/TensorRT6-cuda10.2-cudnn7.tar.gz --no-check-certificate
+ tar -zxf TensorRT6-cuda10.2-cudnn7.tar.gz -C /usr/local
+ cp -rf /usr/local/TensorRT-6.0.1.8/include/* /usr/include/ && cp -rf /usr/local/TensorRT-6.0.1.8/lib/* /usr/lib/
+ rm -rf TensorRT6-cuda10.2-cudnn7.tar.gz
+ elif [ $CUDA_VERSION == "11.2" ]; then
+ wget https://paddle-ci.gz.bcebos.com/TRT/TensorRT-8.0.3.4.Linux.x86_64-gnu.cuda-11.3.cudnn8.2.tar.gz --no-check-certificate
+ tar -zxf TensorRT-8.0.3.4.Linux.x86_64-gnu.cuda-11.3.cudnn8.2.tar.gz -C /usr/local
+ cp -rf /usr/local/TensorRT-8.0.3.4/include/* /usr/include/ && cp -rf /usr/local/TensorRT-8.0.3.4/lib/* /usr/lib/
+ rm -rf TensorRT-8.0.3.4.Linux.x86_64-gnu.cuda-11.3.cudnn8.2.tar.gz
+ else
+ echo "No Cuda Found, no need to install TensorRT"
+ fi
+}
+
+function env_install()
+{
+ apt install -y libcurl4-openssl-dev libbz2-dev
+ wget https://paddle-serving.bj.bcebos.com/others/centos_ssl.tar && tar xf centos_ssl.tar && rm -rf centos_ssl.tar && mv libcrypto.so.1.0.2k /usr/lib/libcrypto.so.1.0.2k && mv libssl.so.1.0.2k /usr/lib/libssl.so.1.0.2k && ln -sf /usr/lib/libcrypto.so.1.0.2k /usr/lib/libcrypto.so.10 && ln -sf /usr/lib/libssl.so.1.0.2k /usr/lib/libssl.so.10 && ln -sf /usr/lib/libcrypto.so.10 /usr/lib/libcrypto.so && ln -sf /usr/lib/libssl.so.10 /usr/lib/libssl.so
+ rm -rf /usr/local/go && wget -qO- https://paddle-ci.gz.bcebos.com/go1.15.12.linux-amd64.tar.gz | \
+ tar -xz -C /usr/local && \
+ mkdir /root/go && \
+ mkdir /root/go/bin && \
+ mkdir /root/go/src && \
+ echo "GOROOT=/usr/local/go" >> /root/.bashrc && \
+ echo "GOPATH=/root/go" >> /root/.bashrc && \
+ echo "PATH=/usr/local/go/bin:/root/go/bin:$PATH" >> /root/.bashrc
+ install_trt
+}
+
+env_install