Install_CN.md 6.7 KB
Newer Older
T
TeslaZhao 已提交
1 2
# 使用Docker安装Paddle Serving

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

B
bjjwwang 已提交
5
**强烈建议**您在**Docker内构建**Paddle Serving,更多镜像请查看[Docker镜像列表](Docker_Images_CN.md)
T
TeslaZhao 已提交
6

T
fixdoc1  
Thomas Young 已提交
7
**提示-1**:本项目仅支持<mark>**Python3.6/3.7/3.8**</mark>,接下来所有的与Python/Pip相关的操作都需要选择正确的Python版本。
B
bjjwwang 已提交
8

T
fixdoc1  
Thomas Young 已提交
9
**提示-2**:以下示例中GPU环境均为cuda10.2-cudnn7,如果您使用Python Pipeline来部署,并需要Nvidia TensorRT来优化预测性能,请参考[支持的镜像环境和说明](#4支持的镜像环境和说明)来选择其他版本。
T
TeslaZhao 已提交
10

B
bjjwwang 已提交
11

T
fixdoc1  
Thomas Young 已提交
12
## 1.启动开发镜像
T
TeslaZhao 已提交
13
<mark>**同时支持使用Serving镜像和Paddle镜像,1.1和1.2章节中的操作2选1即可。**</mark> 在Paddle docker镜像上部署Serving服务需要安装额外依赖库,因此,我们直接使用Serving开发镜像。
T
fixdoc1  
Thomas Young 已提交
14 15
### 1.1 Serving开发镜像(CPU/GPU 2选1)
**CPU:**
T
TeslaZhao 已提交
16 17
```
# 启动 CPU Docker
T
fixdoc1  
Thomas Young 已提交
18 19
docker pull paddlepaddle/serving:0.7.0-devel
docker run -p 9292:9292 --name test -dit paddlepaddle/serving:0.7.0-devel bash
T
TeslaZhao 已提交
20 21 22
docker exec -it test bash
git clone https://github.com/PaddlePaddle/Serving
```
T
fixdoc1  
Thomas Young 已提交
23
**GPU:**
T
TeslaZhao 已提交
24 25
```
# 启动 GPU Docker
T
fixdoc1  
Thomas Young 已提交
26 27
docker pull paddlepaddle/serving:0.7.0-cuda10.2-cudnn7-devel
nvidia-docker run -p 9292:9292 --name test -dit paddlepaddle/serving:0.7.0-cuda10.2-cudnn7-devel bash
T
TeslaZhao 已提交
28 29
nvidia-docker exec -it test bash
git clone https://github.com/PaddlePaddle/Serving
B
bjjwwang 已提交
30
```
T
fixdoc1  
Thomas Young 已提交
31 32
### 1.2 Paddle开发镜像(CPU/GPU 2选1)
**CPU:**
T
TeslaZhao 已提交
33
```
B
bjjwwang 已提交
34
# 启动 CPU Docker
T
fixdoc1  
Thomas Young 已提交
35 36
docker pull paddlepaddle/paddle:2.2.0
docker run -p 9292:9292 --name test -dit paddlepaddle/paddle:2.2.0 bash
B
bjjwwang 已提交
37 38
docker exec -it test bash
git clone https://github.com/PaddlePaddle/Serving
T
fixdoc1  
Thomas Young 已提交
39 40 41

# Paddle开发镜像需要执行以下脚本增加Serving所需依赖项
bash Serving/tools/paddle_env_install.sh
B
bjjwwang 已提交
42
```
T
fixdoc1  
Thomas Young 已提交
43
**GPU:**
B
bjjwwang 已提交
44 45
```
# 启动 GPU Docker
46 47
docker pull paddlepaddle/paddle:2.2.0-gpu-cuda10.2-cudnn7
nvidia-docker run -p 9292:9292 --name test -dit paddlepaddle/paddle:2.2.0-gpu-cuda10.2-cudnn7 bash
B
bjjwwang 已提交
48 49 50
nvidia-docker exec -it test bash
git clone https://github.com/PaddlePaddle/Serving

T
fixdoc1  
Thomas Young 已提交
51 52 53
# Paddle开发镜像需要执行以下脚本增加Serving所需依赖项
bash Serving/tools/paddle_env_install.sh
```
T
TeslaZhao 已提交
54
## 2.安装Paddle Serving稳定wheel包
T
TeslaZhao 已提交
55 56 57 58 59 60 61 62

安装所需的pip依赖
```
cd Serving
pip3 install -r python/requirements.txt
```

```shell
B
bjjwwang 已提交
63 64 65
pip3 install paddle-serving-client==0.7.0
pip3 install paddle-serving-server==0.7.0 # CPU
pip3 install paddle-serving-app==0.7.0
66
pip3 install paddle-serving-server-gpu==0.7.0.post102 #GPU with CUDA10.2 + Cudnn7 + TensorRT6
T
TeslaZhao 已提交
67
# 其他GPU环境需要确认环境再选择执行哪一条
B
bjjwwang 已提交
68 69
pip3 install paddle-serving-server-gpu==0.7.0.post101 # GPU with CUDA10.1 + TensorRT6
pip3 install paddle-serving-server-gpu==0.7.0.post112 # GPU with CUDA11.2 + TensorRT8
T
TeslaZhao 已提交
70 71 72 73
```

您可能需要使用国内镜像源(例如清华源, 在pip命令中添加`-i https://pypi.tuna.tsinghua.edu.cn/simple`)来加速下载。

H
huangjianhui 已提交
74
如果需要使用develop分支编译的安装包,请从[最新安装包列表](./Latest_Packages_CN.md)中获取下载地址进行下载,使用`pip install`命令进行安装。如果您想自行编译,请参照[Paddle Serving编译文档](./Compile_CN.md)
T
TeslaZhao 已提交
75 76 77 78 79

paddle-serving-server和paddle-serving-server-gpu安装包支持Centos 6/7, Ubuntu 16/18和Windows 10。

paddle-serving-client和paddle-serving-app安装包支持Linux和Windows,其中paddle-serving-client仅支持python3.6/3.7/3.8。

J
Jiawei Wang 已提交
80 81
**如果您之前使用paddle serving 0.5.X 0.6.X的Cuda10.2环境,需要注意在0.7.0版本,paddle-serving-server-gpu==0.7.0.post102的使用Cudnn7和TensorRT6,而0.6.0.post102使用cudnn8和TensorRT7。如果0.6.0的cuda10.2用户需要升级安装,请使用paddle-serving-server-gpu==0.7.0.post1028**

T
fixdoc1  
Thomas Young 已提交
82 83
## 3.安装Paddle相关Python库
**当您使用`paddle_serving_client.convert`命令或者`Python Pipeline框架`时才需要安装。**
T
TeslaZhao 已提交
84 85
```
# CPU环境请执行
B
bjjwwang 已提交
86
pip3 install paddlepaddle==2.2.0
T
TeslaZhao 已提交
87 88

# GPU Cuda10.2环境请执行
B
bjjwwang 已提交
89
pip3 install paddlepaddle-gpu==2.2.0
T
TeslaZhao 已提交
90
```
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
**注意**: 如果您的Cuda版本不是10.2,或者您需要在GPU环境上使用TensorRT,请勿直接执行上述命令,需要参考[Paddle-Inference官方文档-下载安装Linux预测库](https://paddleinference.paddlepaddle.org.cn/master/user_guides/download_lib.html#python)选择相应的GPU环境的url链接并进行安装。举例假设您使用python3.6,请执行如下命令。

```
# Cuda10.1 + Cudnn7 + TensorRT6
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.2.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.1_cudnn7.6.5_trt6.0.1.5/paddlepaddle_gpu-2.2.0.post101-cp36-cp36m-linux_x86_64.whl

# Cuda10.2 + Cudnn7 + TensorRT6, 需要注意的是此环境和Cuda10.1+Cudnn7+TensorRT6使用同一个paddle whl包
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.2.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.1_cudnn7.6.5_trt6.0.1.5/paddlepaddle_gpu-2.2.0.post101-cp36-cp36m-linux_x86_64.whl

# Cuda10.2 + Cudnn8 + TensorRT7
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.2.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.2_cudnn8.1.1_trt7.2.3.4/paddlepaddle_gpu-2.2.0-cp36-cp36m-linux_x86_64.whl

# Cuda11.2 + Cudnn8 + TensorRT8
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.2.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda11.2_cudnn8.2.1_trt8.0.3.4/paddlepaddle_gpu-2.2.0.post112-cp36-cp36m-linux_x86_64.whl
```
T
TeslaZhao 已提交
106

T
fixdoc1  
Thomas Young 已提交
107
例如Cuda 10.1的Python3.6用户,请选择表格当中的`cp36-cp36m``linux-cuda10.1-cudnn7.6-trt6-gcc8.2`对应的url,复制下来并执行
T
TeslaZhao 已提交
108
```
B
bjjwwang 已提交
109
pip3 install https://paddle-inference-lib.bj.bcebos.com/2.2.0/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.1_cudnn7.6.5_trt6.0.1.5/paddlepaddle_gpu-2.2.0.post101-cp36-cp36m-linux_x86_64.whl
T
TeslaZhao 已提交
110
```
T
fixdoc1  
Thomas Young 已提交
111 112 113 114 115
## 4.支持的镜像环境和说明
|  环境                         |   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   | 无                     | 无                 |
116
|  Cuda10.2+Cudnn7             | 0.7.0-cuda10.2-cudnn7-devel       |  Ubuntu 16.04   | 2.2.0-gpu-cuda10.2-cudnn7 | Ubuntu 16.04        |
T
fixdoc1  
Thomas Young 已提交
117
|  Cuda10.2+Cudnn8             | 0.7.0-cuda10.2-cudnn8-devel       |  Ubuntu 16.04   | 无                    |  无                 |
118
|  Cuda11.2+Cudnn8             | 0.7.0-cuda11.2-cudnn8-devel       |  Ubuntu 16.04   | 2.2.0-gpu-cuda11.2-cudnn8 | Ubuntu 18.04        | 
T
TeslaZhao 已提交
119

T
TeslaZhao 已提交
120
对于**Windows 10 用户**,请参考文档[Windows平台使用Paddle Serving指导](Windows_Tutorial_CN.md)