Install_EN.md 14.8 KB
Newer Older
T
TeslaZhao 已提交
1 2
# Install Paddle Serving with Docker

H
huangjianhui 已提交
3
([简体中文](./Install_CN.md)|English)
T
TeslaZhao 已提交
4

T
TeslaZhao 已提交
5 6
- [1.Use devel docker](#1)
    - [Serving devel images](#1.1)
T
TeslaZhao 已提交
7 8 9
        - [CPU images](#1.1.1)
        - [GPU images](#1.1.2)
        - [ARM & XPU images](#1.1.3)
T
TeslaZhao 已提交
10
    - [Paddle devel images](#1.2)
T
TeslaZhao 已提交
11 12
        - [CPU images](#1.2.1)
        - [GPU images](#1.2.2)
T
TeslaZhao 已提交
13 14 15
- [2.Install Wheel Packages](#2)
    - [Online Install](#2.1)
    - [Offline Install](#2.2)
T
TeslaZhao 已提交
16
    - [ARM & XPU Install](#2.3)
T
TeslaZhao 已提交
17 18
- [3.Installation Check](#3)

B
bjjwwang 已提交
19
**Strongly recommend** you build **Paddle Serving** in Docker. For more images, please refer to [Docker Image List](Docker_Images_CN.md).
T
TeslaZhao 已提交
20

T
TeslaZhao 已提交
21
**Tip-1**: This project only supports <mark>**Python3.6/3.7/3.8/3.9**</mark>, all subsequent operations related to Python/Pip need to select the correct Python version.
T
TeslaZhao 已提交
22

T
TeslaZhao 已提交
23
**Tip-2**: The GPU environments in the following examples are all cuda11.2-cudnn8. If you use Python Pipeline to deploy and need Nvidia TensorRT to optimize prediction performance, please refer to [Supported Mirroring Environment and Instructions](#4.-Supported-Docker-Images-and-Instruction) to choose other versions.
T
TeslaZhao 已提交
24

T
TeslaZhao 已提交
25 26 27
<a name="1"></a>

## 1.Use devel docker
T
TeslaZhao 已提交
28
<mark>**Both Serving Dev Image and Paddle Dev Image are supported at the same time. You can choose 1 from the operation 2 in chapters 1.1 and 1.2.**</mark>Deploying the Serving service on the Paddle docker image requires the installation of additional dependency libraries. Therefore, we directly use the Serving development image.
B
bjjwwang 已提交
29

T
TeslaZhao 已提交
30 31
| Environment | Serving Development Image Tag | Operating System | Paddle Development Image Tag | Operating System |
| :--------------------------: | :-------------------------------: | :-------------: | :-------------------: | :----------------: |
32 33 34 35 36
|  CPU                         | 0.9.0-devel                       |  Ubuntu 16    | 2.3.0                    | Ubuntu 18       |
|  CUDA10.1 + cuDNN 7           | 0.9.0-cuda10.1-cudnn7-devel       |  Ubuntu 16   | None                       | None                 |
|  CUDA10.2 + cuDNN 7           | 0.9.0-cuda10.2-cudnn7-devel       |  Ubuntu 16   | 2.3.0-gpu-cuda10.2-cudnn7 | Ubuntu 18
|  CUDA10.2 + cuDNN 8           | 0.9.0-cuda10.2-cudnn8-devel       |  Ubuntu 16   | None                   | None |
|  CUDA11.2 + cuDNN 8           | 0.9.0-cuda11.2-cudnn8-devel       |  Ubuntu 16   | 2.3.0-gpu-cuda11.2-cudnn8 | Ubuntu 18   | 
T
TeslaZhao 已提交
37
|  ARM + XPU                    | xpu-arm                           |  CentOS 8.3  | None                         | None           |
T
TeslaZhao 已提交
38 39 40 41 42 43 44 45

For **Windows 10 users**, please refer to the document [Paddle Serving Guide for Windows Platform](Windows_Tutorial_CN.md).


<a name="1.1"></a>

### 1.1 Serving Devel Images (CPU/GPU 2 choose 1)

T
TeslaZhao 已提交
46 47
<a name="1.1.1"></a>

B
bjjwwang 已提交
48
**CPU:**
T
TeslaZhao 已提交
49
```
B
bjjwwang 已提交
50
# Start CPU Docker Container
T
TeslaZhao 已提交
51
docker pull registry.baidubce.com/paddlepaddle/serving:0.9.0-devel
T
TeslaZhao 已提交
52 53
docker run -p 9292:9292 --name test_cpu -dit registry.baidubce.com/paddlepaddle/serving:0.9.0-devel bash
docker exec -it test_cpu bash
T
TeslaZhao 已提交
54 55
git clone https://github.com/PaddlePaddle/Serving
```
T
TeslaZhao 已提交
56 57 58

<a name="1.1.2"></a>

B
bjjwwang 已提交
59
**GPU:**
T
TeslaZhao 已提交
60
```
B
bjjwwang 已提交
61
# Start GPU Docker Container
T
TeslaZhao 已提交
62
docker pull registry.baidubce.com/paddlepaddle/serving:0.9.0-cuda11.2-cudnn7-devel
T
TeslaZhao 已提交
63 64 65 66 67 68 69 70 71 72 73 74
nvidia-docker run -p 9292:9292 --name test_gpu -dit docker pull registry.baidubce.com/paddlepaddle/serving:0.9.0-cuda11.2-cudnn7-devel bash
nvidia-docker exec -it test_gpu bash
git clone https://github.com/PaddlePaddle/Serving
```

<a name="1.1.3"></a>

**ARM & XPU: **
```
docker pull registry.baidubce.com/paddlepaddle/serving:xpu-arm
docker run -p 9292:9292 --name test_arm_xpu -dit registry.baidubce.com/paddlepaddle/serving:xpu-arm bash
docker exec -it test_arm_xpu bash
T
TeslaZhao 已提交
75 76
git clone https://github.com/PaddlePaddle/Serving
```
T
TeslaZhao 已提交
77 78 79 80

<a name="1.2"></a>

### 1.2 Paddle Devel Images (choose any codeblock of CPU/GPU)
T
TeslaZhao 已提交
81 82 83

<a name="1.2.1"></a>

B
bjjwwang 已提交
84
**CPU:**
T
TeslaZhao 已提交
85
```shell
B
bjjwwang 已提交
86
# Start CPU Docker Container
T
TeslaZhao 已提交
87
docker pull registry.baidubce.com/paddlepaddle/paddle:2.3.0
T
TeslaZhao 已提交
88 89
docker run -p 9292:9292 --name test_cpu -dit registry.baidubce.com/paddlepaddle/paddle:2.3.0 bash
docker exec -it test_cpu bash
B
bjjwwang 已提交
90
git clone https://github.com/PaddlePaddle/Serving
T
TeslaZhao 已提交
91

T
TeslaZhao 已提交
92
### Paddle dev image needs to run the following script to increase the dependencies required by Serving
B
bjjwwang 已提交
93 94
bash Serving/tools/paddle_env_install.sh
```
T
TeslaZhao 已提交
95 96 97

<a name="1.2.2"></a>

B
bjjwwang 已提交
98
**GPU:**
T
TeslaZhao 已提交
99 100 101

```shell
### Start GPU Docker
T
TeslaZhao 已提交
102
nvidia-docker pull registry.baidubce.com/paddlepaddle/paddle:2.3.0-gpu-cuda11.2-cudnn8
T
TeslaZhao 已提交
103 104
nvidia-docker run -p 9292:9292 --name test_gpu -dit registry.baidubce.com/paddlepaddle/paddle:2.3.0-gpu-cuda11.2-cudnn8 bash
nvidia-docker exec -it test_gpu bash
B
bjjwwang 已提交
105
git clone https://github.com/PaddlePaddle/Serving
T
TeslaZhao 已提交
106

T
TeslaZhao 已提交
107
### Paddle development image needs to execute the following script to increase the dependencies required by Serving
B
bjjwwang 已提交
108 109
bash Serving/tools/paddle_env_install.sh
```
T
TeslaZhao 已提交
110

T
TeslaZhao 已提交
111 112 113
<a name="2"></a>

## 2. Install wheel packages
T
TeslaZhao 已提交
114

B
bjjwwang 已提交
115 116 117 118 119
Install the required pip dependencies
```
cd Serving
pip3 install -r python/requirements.txt
```
T
TeslaZhao 已提交
120

T
TeslaZhao 已提交
121
Install the service whl package. There are three types of client, app and server. The server is divided into CPU and GPU. Choose one installation according to the environment. 
T
TeslaZhao 已提交
122
- post112 = CUDA11.2 + cuDNN8 + TensorRT8(Recommanded)
T
TeslaZhao 已提交
123
- post101 = CUDA10.1 + cuDNN7 + TensorRT6
124
- post102 = CUDA10.2 + cuDNN7 + TensorRT6 (The same with paddle docker images)
T
TeslaZhao 已提交
125
- post1028 = CUDA10.2 + cuDNN8 + TensorRT7
T
TeslaZhao 已提交
126

T
TeslaZhao 已提交
127 128 129
<a name="2.1"></a>

### 2.1 Online Install
T
TeslaZhao 已提交
130
Online installation uses `pypi` to download and install.
T
TeslaZhao 已提交
131

B
bjjwwang 已提交
132
```shell
T
TeslaZhao 已提交
133 134
pip3 install paddle-serving-client==0.9.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install paddle-serving-app==0.9.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
T
TeslaZhao 已提交
135 136

# CPU Server
T
TeslaZhao 已提交
137
pip3 install paddle-serving-server==0.9.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
T
TeslaZhao 已提交
138 139

# GPU environments need to confirm the environment before choosing which one to execute
T
TeslaZhao 已提交
140 141 142
pip3 install paddle-serving-server-gpu==0.9.0.post112 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install paddle-serving-server-gpu==0.9.0.post102 -i https://pypi.tuna.tsinghua.edu.cn/simple 
pip3 install paddle-serving-server-gpu==0.9.0.post101 -i https://pypi.tuna.tsinghua.edu.cn/simple
B
bjjwwang 已提交
143
```
T
TeslaZhao 已提交
144

T
TeslaZhao 已提交
145
By default, the domestic Tsinghua mirror source is turned on to speed up the download. If you use a proxy, you can turn it off(`-i https://pypi.tuna.tsinghua.edu.cn/simple`).
T
TeslaZhao 已提交
146

147
If you need to use the installation package compiled by the develop branch, please download the download address from [Download wheel packages](./Latest_Packages_EN.md), and use the `pip install` command to install. If you want to compile by yourself, please refer to [Paddle Serving Compilation Document](./Compile_CN.md).
T
TeslaZhao 已提交
148

B
bjjwwang 已提交
149
The paddle-serving-server and paddle-serving-server-gpu installation packages support Centos 6/7, Ubuntu 16/18 and Windows 10.
T
TeslaZhao 已提交
150

T
TeslaZhao 已提交
151
The paddle-serving-client and paddle-serving-app installation packages support Linux and Windows, and paddle-serving-client only supports python3.6/3.7/3.8/3.9.
T
TeslaZhao 已提交
152

B
bjjwwang 已提交
153
**You only need to install it when you use the `paddle_serving_client.convert` command or the `Python Pipeline framework`. **
T
TeslaZhao 已提交
154
```
B
bjjwwang 已提交
155
# CPU environment please execute
T
TeslaZhao 已提交
156
pip3 install paddlepaddle==2.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
T
TeslaZhao 已提交
157

T
TeslaZhao 已提交
158 159
# GPU CUDA 11.2 environment please execute
pip3 install paddlepaddle-gpu==2.3.0.post112 -i https://pypi.tuna.tsinghua.edu.cn/simple
T
TeslaZhao 已提交
160
```
T
TeslaZhao 已提交
161
**Note**: If you want to use other versions, please do not execute the above commands directly, you need to refer to [Paddle-Inference official document-download and install the Linux prediction library](https://paddleinference.paddlepaddle.org.cn/master/user_guides/download_lib.html#python) Select the URL link of the corresponding GPU environment and install it. Assuming that you use Python3.6, please follow the codeblock.
T
TeslaZhao 已提交
162 163

```
T
TeslaZhao 已提交
164 165 166 167 168
# CUDA11.2 + CUDNN8 + TensorRT8 + Python(3.6-3.9)
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.3.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda11.2_cudnn8.2.1_trt8.0.3.4/paddlepaddle_gpu-2.3.0.post112-cp36-cp36m-linux_x86_64.whl
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.3.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda11.2_cudnn8.2.1_trt8.0.3.4/paddlepaddle_gpu-2.3.0.post112-cp37-cp37m-linux_x86_64.whl
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.3.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda11.2_cudnn8.2.1_trt8.0.3.4/paddlepaddle_gpu-2.3.0.post112-cp38-cp38-linux_x86_64.whl
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.3.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda11.2_cudnn8.2.1_trt8.0.3.4/paddlepaddle_gpu-2.3.0.post112-cp39-cp39-linux_x86_64.whl
169

T
TeslaZhao 已提交
170 171 172 173 174
# CUDA10.1 + CUDNN7 + TensorRT6 + Python(3.6-3.9)
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.3.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.1_cudnn7.6.5_trt6.0.1.5/paddlepaddle_gpu-2.3.0.post101-cp36-cp36m-linux_x86_64.whl
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.3.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.1_cudnn7.6.5_trt6.0.1.5/paddlepaddle_gpu-2.3.0.post101-cp37-cp37m-linux_x86_64.whl
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.3.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.1_cudnn7.6.5_trt6.0.1.5/paddlepaddle_gpu-2.3.0.post101-cp38-cp38-linux_x86_64.whl
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.3.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.1_cudnn7.6.5_trt6.0.1.5/paddlepaddle_gpu-2.3.0.post101-cp39-cp39-linux_x86_64.whl
175

T
TeslaZhao 已提交
176 177 178 179 180
# CUDA10.2 + CUDNN8 + TensorRT7 + Python(3.6-3.9)
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.3.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.2_cudnn8.1.1_trt7.2.3.4/paddlepaddle_gpu-2.3.0-cp36-cp36m-linux_x86_64.whl
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.3.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.2_cudnn8.1.1_trt7.2.3.4/paddlepaddle_gpu-2.3.0-cp37-cp37m-linux_x86_64.whl
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.3.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.2_cudnn8.1.1_trt7.2.3.4/paddlepaddle_gpu-2.3.0-cp38-cp38-linux_x86_64.whl
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.3.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.2_cudnn8.1.1_trt7.2.3.4/paddlepaddle_gpu-2.3.0-cp39-cp39-linux_x86_64.whl
T
TeslaZhao 已提交
181
```
T
TeslaZhao 已提交
182
<a name="2.2"></a>
183

T
TeslaZhao 已提交
184
### 2.2 Offline Install
T
TeslaZhao 已提交
185
Offline installation is to download all Paddle and Serving packages and dependent libraries, and install them in a no-network or weak-network environment.
T
TeslaZhao 已提交
186

T
TeslaZhao 已提交
187
**1.Install offline wheel packages**
T
TeslaZhao 已提交
188

189 190 191 192 193 194 195 196
The independent dependencies of the Serving and Paddle Wheel packages are downloaded by four links.

```
wget https://paddle-serving.bj.bcebos.com/offline_wheels/0.9.0/py36_offline_whl_packages.tar
wget https://paddle-serving.bj.bcebos.com/offline_wheels/0.9.0/py37_offline_whl_packages.tar
wget https://paddle-serving.bj.bcebos.com/offline_wheels/0.9.0/py38_offline_whl_packages.tar
wget https://paddle-serving.bj.bcebos.com/offline_wheels/0.9.0/py39_offline_whl_packages.tar
```
T
TeslaZhao 已提交
197

T
TeslaZhao 已提交
198 199 200 201 202 203
The Serving and Paddle Wheel packages can be installed locally by running the `install.py` script. The parameter list for the `install.py` script is as follows:
```
python3 install.py
  --python_version : Python version for installing wheels, one of [py36, py37, py38, py39], py37 default.
  --device : Type of devices, one of [cpu, gpu], cpu default.
  --cuda_version : CUDA version for GPU, one of [101, 102, 112, empty], empty default.
204 205
  --serving_version : Verson of Serving, one of [0.9.0, no_install], 0.9.0 default.
  --paddle_version Verson of Paddle, one of [2.3.0, no_install], 2.3.0 default.
T
TeslaZhao 已提交
206 207 208 209 210 211 212 213 214 215 216 217
```

**2.Specify the `SERVING_BIN` path in the environment variable**
After completing step 1 of the installation, you can ignore this step if you only use the python pipeline mode.

If you use C++ Serving to start the service using the command line, the example is as follows. Then you need to export the environment variable `SERVING_BIN` in the command line window or service launcher, and use the local serving binary to run the service.
C++ Serving command line start service example:
```
python3 -m paddle_serving_server.serve --model serving_model --thread 10 --port 9292 --gpu_ids 0,1,2
```
Since the binary package for all versions has 20 GB, it is very large. Therefore, multiple versions of download links are provided. Manually `wget` downloads the specified version to the `serving_bin` directory, decompresses it and exports it to the environment variable.

218 219 220 221 222 223 224
- cpu-avx-mkl: https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-cpu-avx-mkl-0.9.0.tar.gz
- cpu-avx-openblas: https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-cpu-avx-openblas-0.9.0.tar.gz
- cpu-noavx-openblas: https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-cpu-noavx-openblas-0.9.0.tar.gz
- cuda10.1-cudnn7-TensorRT6: https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-gpu-101-0.9.0.tar.gz
- cuda10.2-cudnn7-TensorRT6: https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-gpu-102-0.9.0.tar.gz
- cuda10.2-cudnn8-TensorRT7: https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-gpu-1028-0.9.0.tar.gz
- cuda11.2-cudnn8-TensorRT8: https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-gpu-112-0.9.0.tar.gz
T
TeslaZhao 已提交
225 226 227 228 229 230 231

Taking GPU CUDA 10.2 as an example, set the environment variables on the command line or in the launcher as follows:

**3.Run `install.py` to install wheel packages**

1. Install the py38 version GPU wheel package of Serving and Paddle at the same time:
```
232
python3 install.py --cuda_version="102" --python_version="py38" --device="GPU" --serving_version="0.9.0" --paddle_version="2.3.0"
T
TeslaZhao 已提交
233 234 235 236
```

2.Only install the py39 version of the Serving CPU wheel package, set `--paddle_version="no_install"` to not install the Paddle prediction library, set `--device="cpu"` to indicate the cpu version
```
237
python3 install.py --cuda_version="" --python_version="py39" --device="cpu" --serving_version="0.9.0" --paddle_version="no_install"
T
TeslaZhao 已提交
238 239 240
```
3. Install only the GPU wheel package of Paddle's py36 version `cuda=11.2`
```
241
python3 install.py --cuda_version="112" --python_version="py36" --device="GPU" --serving_version="no_install" --paddle_version="2.3.0"
T
TeslaZhao 已提交
242 243
```

T
TeslaZhao 已提交
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
<a name="2.3"></a>

### 2.3 ARM & XPU Install

Since there are few users using ARM and XPU, the Wheel for installing this environment is provided separately as follows, among which `paddle_serving_client` only provides the `py36` version, if you need other versions, please contact us.
```
pip3.6 install https://paddle-serving.bj.bcebos.com/test-dev/whl/arm/paddle_serving_app-0.9.0-py3-none-any.whl
pip3.6 install https://paddle-serving.bj.bcebos.com/test-dev/whl/arm/paddle_serving_client-0.9.0-cp36-none-any.whl
pip3.6 install https://paddle-serving.bj.bcebos.com/test-dev/whl/arm/paddle_serving_server_xpu-0.9.0.post2-py3-none-any.whl
```

Download binary package address:
```
wget https://paddle-serving.bj.bcebos.com/test-dev/bin/serving-xpu-aarch64-0.9.0.tar.gz
```

T
TeslaZhao 已提交
260
<a name="3"></a>
T
TeslaZhao 已提交
261

T
TeslaZhao 已提交
262
## 3.Installation Check
T
TeslaZhao 已提交
263 264 265 266
When the above steps are completed, you can use the command line to run the environment check function to automatically run the Paddle Serving related examples to verify the environment-related configuration.
```
python3 -m paddle_serving_server.serve check
```
T
TeslaZhao 已提交
267
For more information, please see[Installation Check](./Check_Env_CN.md)