Skip to content

Commit 017f305

Browse files
authored
[Serving] Compile on CentOS without docker tutorial (#1440)
serving compile doc
1 parent be313a8 commit 017f305

File tree

4 files changed

+433
-0
lines changed

4 files changed

+433
-0
lines changed

serving/docs/EN/compile-en.md

+2
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,5 @@ docker build -t paddlepaddle/fastdeploy:x.y.z-ipu-only-21.10 -f serving/Dockerfi
6767
```
6868

6969
## Compilation without Docker containers
70+
71+
- [FastDeploy Serving CentOS Compilation Tutorial](./compile_without_docker_centos-en.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
English | [中文](../zh_CN/compile_without_docker_centos.md)
2+
3+
# FastDeploy Serving CentOS Compilation Tutorial
4+
5+
This tutorial introduces how to install dependencies, compile and package FastDeploy Serving in the CentOS environment, and the user can finally install the deployment package into the CentOS system without relying on the docker container.
6+
7+
If the deployment environment has `sudo` permission, it can be compiled and packaged directly in the deployment environment. If you do not have `sudo` permission and cannot use `yum` to install, you can create a docker container which has the same environment as the deployment machine to compile and package, and finally upload the package to the deployment environment.
8+
9+
This tutorial is for GPU environment. For CPU-Only enviroment, you can tailor it according to the content of this tutorial, mainly including:
10+
11+
- No need for CUDA, TensorRT, datacenter-gpu-manager and other GPU dependencies
12+
- When compiling tritonserver, remove --enable-gpu and --enable-gpu-metrics
13+
- Disable GPU-related options such as WITH_GPU and ENABLE_TRT_BACKEND when compiling FastDeploy Runtime
14+
15+
## 1. Environments
16+
17+
* CentOS Linux release 7.9.2009
18+
* CUDA 11.2 (consistent with the deployment env)
19+
* Python 3.8 (prefer to use conda)
20+
* GCC 9.4.0
21+
22+
## 2. Compile GCC
23+
24+
Follow the steps below to compile GCC 9.4.0. After `make install`, you can package the /opt/gcc-9.4.0/ directory for backup, which can be reused later.
25+
26+
```
27+
wget http://gnu.mirror.constant.com/gcc/gcc-9.4.0/gcc-9.4.0.tar.gz
28+
tar xvf gcc-9.4.0.tar.gz
29+
cd gcc-9.4.0
30+
mkdir build
31+
cd build
32+
../configure --enable-languages=c,c++ --disable-multilib --prefix=/opt/gcc-9.4.0/
33+
make -j8
34+
make install
35+
```
36+
37+
## 3. Install dependencies for tritonserver
38+
39+
Dependencies which can be installed by `yum`:
40+
41+
```
42+
yum install numactl-devel
43+
yum install libarchive-devel
44+
yum install re2-devel
45+
46+
wget http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/libb64-libs-1.2.1-2.1.el7.art.x86_64.rpm
47+
wget http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/libb64-devel-1.2.1-2.1.el7.art.x86_64.rpm
48+
rpm -ivh libb64-libs-1.2.1-2.1.el7.art.x86_64.rpm
49+
rpm -ivh libb64-devel-1.2.1-2.1.el7.art.x86_64.rpm
50+
```
51+
52+
Install rapidjson:
53+
54+
```
55+
git clone https://github.com/Tencent/rapidjson.git
56+
cd rapidjson
57+
git submodule update --init
58+
mkdir build && cd build
59+
CC=/opt/gcc-9.4.0/bin/gcc CXX=
60+
/opt/gcc-9.4.0/bin/g++
61+
cmake ..
62+
make install
63+
```
64+
65+
Install boost 1.70:
66+
67+
```
68+
wget https://boostorg.jfrog.io/artifactory/main/release/1.70.0/source/boost_1_70_0_rc2.tar.gz
69+
tar xvf boost_1_70_0_rc2.tar.gz
70+
cd boost_1_70_0
71+
./bootstrap.sh --prefix=/opt/boost
72+
./b2 install --prefix=/opt/boost --with=all
73+
```
74+
75+
Install datacenter-gpu-manager:
76+
77+
```
78+
dnf config-manager \
79+
--add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
80+
dnf clean expire-cache
81+
dnf install -y datacenter-gpu-manager
82+
```
83+
84+
## 4. Compile tritonserver
85+
86+
```
87+
cd /workspace
88+
git clone https://github.com/triton-inference-server/server.git -b r21.10
89+
cd server
90+
mkdir -p build/tritonserver/install
91+
CC=/opt/gcc-9.4.0/bin/gcc CXX=/opt/gcc-9.4.0/bin/g++ \
92+
BOOST_LIBRARYDIR=/opt/boost/lib BOOST_INCLUDEDIR=/opt/boost/include \
93+
python build.py \
94+
--build-dir `pwd`/build \
95+
--no-container-build \
96+
--backend=ensemble \
97+
--enable-gpu \
98+
--endpoint=grpc \
99+
--endpoint=http \
100+
--enable-stats \
101+
--enable-tracing \
102+
--enable-logging \
103+
--enable-stats \
104+
--enable-metrics \
105+
--enable-gpu-metrics \
106+
--cmake-dir `pwd`/build \
107+
--repo-tag=common:r21.10 \
108+
--repo-tag=core:r21.10 \
109+
--repo-tag=backend:r21.10 \
110+
--repo-tag=thirdparty:r21.10 \
111+
--backend=python:r21.10
112+
```
113+
114+
## 5. Compile FastDeploy Runtime and Serving
115+
116+
FastDeploy Runtime depends on TensorRT for GPU serving, so TRT_DIRECTORY is required.
117+
118+
```
119+
cd /workspace/
120+
git clone https://github.com/PaddlePaddle/FastDeploy.git
121+
cd FastDeploy
122+
mkdir build && cd build
123+
CC=/opt/gcc-9.4.0/bin/gcc CXX=/opt/gcc-9.4.0/bin/g++ cmake .. \
124+
-DENABLE_TRT_BACKEND=ON \
125+
-DCMAKE_INSTALL_PREFIX=${PWD}/fastdeploy_install \
126+
-DWITH_GPU=ON \
127+
-DTRT_DIRECTORY=/workspace/TensorRT-8.4.3.1 \
128+
-DENABLE_PADDLE_BACKEND=ON \
129+
-DENABLE_ORT_BACKEND=ON \
130+
-DENABLE_OPENVINO_BACKEND=ON \
131+
-DENABLE_VISION=ON \
132+
-DBUILD_FASTDEPLOY_PYTHON=OFF \
133+
-DENABLE_PADDLE2ONNX=ON \
134+
-DENABLE_TEXT=OFF \
135+
-DLIBRARY_NAME=fastdeploy_runtime
136+
make -j8
137+
make install
138+
```
139+
140+
Compile FastDeploy Serving:
141+
142+
```
143+
cd /workspace/FastDeploy/serving/
144+
mkdir build && cd build
145+
CC=/opt/gcc-9.4.0/bin/gcc CXX=/opt/gcc-9.4.0/bin/g++ cmake .. \
146+
-DFASTDEPLOY_DIR=/workspace/FastDeploy/build/fastdeploy_install \
147+
-DTRITON_COMMON_REPO_TAG=r21.10 \
148+
-DTRITON_CORE_REPO_TAG=r21.10 \
149+
-DTRITON_BACKEND_REPO_TAG=r21.10
150+
make -j8
151+
```
152+
153+
## 6. Package
154+
155+
Put the executable files, scripts, dependent libraries, etc. required for Serving to run inti one directory, and compress it into a tar.gz package.
156+
157+
```
158+
# Put everything under /workspace/opt/
159+
cd /workspace/
160+
mkdir /workspace/opt
161+
162+
# triton server
163+
mkdir -p opt/tritonserver
164+
cp -r /workspace/server/build/tritonserver/install/* opt/tritonserver
165+
166+
# python backend
167+
mkdir -p opt/tritonserver/backends/python
168+
cp -r /workspace/server/build/python/install/backends/python opt/tritonserver/backends/
169+
170+
# fastdeploy backend
171+
mkdir -p opt/tritonserver/backends/fastdeploy
172+
cp /workspace/FastDeploy/serving/build/libtriton_fastdeploy.so opt/tritonserver/backends/fastdeploy/
173+
174+
# rename tritonserver to fastdeployserver
175+
mv opt/tritonserver/bin/tritonserver opt/tritonserver/bin/fastdeployserver
176+
177+
# fastdeploy runtime
178+
cp -r /workspace/FastDeploy/build/fastdeploy_install/ opt/fastdeploy/
179+
180+
# GCC
181+
cp -r /opt/gcc-9.4.0/ opt/
182+
```
183+
184+
For some dependent libraries installed by yum, if the deployment environment does not have them, they also need to be packaged together and placed under opt/third_libs, including:
185+
186+
* /lib64/libdcgm.so.3
187+
* /lib64/libnuma.so.1
188+
* /lib64/libre2.so.0
189+
* /lib64/libb64.so.0
190+
* /lib64/libarchive.so.13
191+
192+
The final opt/ directory structure is as follows. README.md and init.sh need to be added by the packager. README.md needs to explain how to use the installation package, etc. init.sh is responsible for setting the environment variables required for FastDeploy Serving to run.
193+
194+
```
195+
opt/
196+
├── fastdeploy
197+
├── gcc-9.4.0
198+
├── init.sh
199+
├── README.md
200+
└── tritonserver
201+
└── third_libs
202+
```
203+
204+
init.sh example:
205+
206+
```
207+
CURRENT_DIR=$(dirname $(readlink -f "${BASH_SOURCE}"))
208+
echo $CURRENT_DIR
209+
source $CURRENT_DIR/fastdeploy/fastdeploy_init.sh
210+
export PATH=$CURRENT_DIR/tritonserver/bin:$PATH
211+
export LD_LIBRARY_PATH=$CURRENT_DIR/gcc-9.4.0/lib64:$LD_LIBRARY_PATH
212+
export LD_LIBRARY_PATH=$CURRENT_DIR/tritonserver/backends/python/:$LD_LIBRARY_PATH
213+
export LD_LIBRARY_PATH=$CURRENT_DIR/third_libs:$LD_LIBRARY_PATH
214+
unset CURRENT_DIR
215+
```

serving/docs/zh_CN/compile.md

+1
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,4 @@ docker build -t paddlepaddle/fastdeploy:x.y.z-ipu-only-21.10 -f serving/Dockerfi
6767

6868
## 非镜像方式编译
6969

70+
- [FastDeploy Serving CentOS编译教程](./compile_without_docker_centos.md)

0 commit comments

Comments
 (0)