Skip to content

Commit ff631b7

Browse files
DefTruthrootqiuyanjun
authored
[Server] Support encrypt & auth for FD Server (#2018)
* [Server] Support GPU encrypt & auth for FD Triton Server * fix dockerfile proxy env error * update build scrpits * remove some logs --------- Co-authored-by: root <[email protected]> Co-authored-by: qiuyanjun <[email protected]>
1 parent 73f42e3 commit ff631b7

11 files changed

+228
-69
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,7 @@ python/fastdeploy/code_version.py
4747
*.pdmodel
4848
*.pdiparams
4949
*.pdiparams.info
50-
log.txt
50+
log.txt
51+
serving/build
52+
serving/build.encrypt
53+
serving/build.encrypt.auth

CMakeLists.txt

+7-6
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,11 @@ if(ENABLE_TRT_BACKEND)
392392
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib")
393393
file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib")
394394
endif()
395-
find_package(Python COMPONENTS Interpreter Development REQUIRED)
395+
396+
if (NOT Python_EXECUTABLE)
397+
find_package(Python COMPONENTS Interpreter Development REQUIRED)
398+
endif()
399+
396400
message(STATUS "Copying ${TRT_DIRECTORY}/lib to ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib ...")
397401
execute_process(COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/copy_directory.py ${TRT_DIRECTORY}/lib ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib)
398402
file(GLOB_RECURSE TRT_STATIC_LIBS ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib/*.a)
@@ -515,12 +519,9 @@ if(MSVC)
515519
endif()
516520

517521
target_link_libraries(${LIBRARY_NAME} ${DEPEND_LIBS})
518-
# Note(qiuyanjun): Currently, we need to manually link the whole
519-
# leveldb static lib into fastdeploy lib if PADDLEINFERENCE_WITH_ENCRYPT_AUTH
520-
# is 'ON'. Will remove this policy while the bug of paddle inference lib with
521-
# auth & encrypt fixed.
522+
522523
if(ENABLE_PADDLE_BACKEND)
523-
enable_paddle_encrypt_auth_link_policy(${LIBRARY_NAME})
524+
set_paddle_encrypt_auth_link_policy(${LIBRARY_NAME})
524525
endif()
525526

526527
if(ANDROID)

FastDeploy.cmake.in

+17-10
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ set(WITH_ANDROID_JAVA @WITH_ANDROID_JAVA@)
6363
set(WITH_ANDROID_TENSOR_FUNCS @WITH_ANDROID_TENSOR_FUNCS@)
6464

6565
# encryption and auth
66-
set(PADDLEINFERENCE_WITH_ENCRYPT_AUTH @PADDLEINFERENCE_WITH_ENCRYPT_AUTH@)
66+
set(PADDLEINFERENCE_WITH_ENCRYPT @PADDLEINFERENCE_WITH_ENCRYPT@)
67+
set(PADDLEINFERENCE_WITH_AUTH @PADDLEINFERENCE_WITH_AUTH@)
6768

6869
set(FASTDEPLOY_LIBS "")
6970
set(FASTDEPLOY_INCS "")
@@ -152,15 +153,21 @@ if(ENABLE_PADDLE_BACKEND)
152153
else()
153154
set(DNNL_LIB "${CMAKE_CURRENT_LIST_DIR}/third_libs/install/paddle_inference/third_party/install/mkldnn/lib/libmkldnn.so.0")
154155
set(IOMP_LIB "${CMAKE_CURRENT_LIST_DIR}/third_libs/install/paddle_inference/third_party/install/mklml/lib/libiomp5.so")
155-
if(PADDLEINFERENCE_WITH_ENCRYPT_AUTH)
156-
set(FDMODEL_LIB "${CMAKE_CURRENT_LIST_DIR}/third_libs/install/paddle_inference/third_party/install/fdmodel/lib/libfastdeploy_wenxin.so")
157-
set(FDMODEL_AUTH_LIB "${CMAKE_CURRENT_LIST_DIR}/third_libs/install/paddle_inference/third_party/install/fdmodel/lib/libfastdeploy_auth.so")
158-
set(FDMODEL_MODEL_LIB "${CMAKE_CURRENT_LIST_DIR}/third_libs/install/paddle_inference/third_party/install/fdmodel/lib/libfastdeploy_model.so.2.0.0")
159-
set(LEVELDB_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}/third_libs/install/paddle_inference/third_party/install/leveldb/lib/")
160-
list(APPEND FASTDEPLOY_LIBS ${FDMODEL_LIB} ${FDMODEL_AUTH_LIB} ${FDMODEL_MODEL_LIB})
161-
# link_directories(LEVELDB_LIB_DIR)
162-
# list(APPEND FASTDEPLOY_LIBS -lssl -lcrypto -lleveldb)
163-
list(APPEND FASTDEPLOY_LIBS -lssl -lcrypto)
156+
set(FDMODEL_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/fdmodel/lib/libfastdeploy_wenxin.so")
157+
set(FDMODEL_MODEL_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/fdmodel/lib/libfastdeploy_model.so.2.0.0")
158+
set(FDMODEL_AUTH_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/fdmodel/lib/libfastdeploy_auth.so")
159+
if((EXISTS ${FDMODEL_LIB}) AND (EXISTS ${FDMODEL_MODEL_LIB}))
160+
set(PADDLEINFERENCE_WITH_ENCRYPT ON CACHE BOOL "" FORCE)
161+
list(APPEND FASTDEPLOY_LIBS ${FDMODEL_LIB} ${FDMODEL_MODEL_LIB})
162+
endif()
163+
if((EXISTS ${FDMODEL_LIB}) AND (EXISTS ${FDMODEL_AUTH_LIB}))
164+
set(PADDLEINFERENCE_WITH_AUTH ON CACHE BOOL "" FORCE)
165+
list(APPEND FASTDEPLOY_LIBS ${FDMODEL_AUTH_LIB})
166+
endif()
167+
if(PADDLEINFERENCE_WITH_ENCRYPT OR PADDLEINFERENCE_WITH_AUTH)
168+
if(WITH_KUNLUNXIN)
169+
list(APPEND FASTDEPLOY_LIBS -lssl -lcrypto)
170+
endif()
164171
endif()
165172
endif()
166173
list(APPEND FASTDEPLOY_LIBS ${PADDLE_LIB})

cmake/paddle_inference.cmake

+72-48
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ endif()
2222

2323
# Custom options for Paddle Inference backend
2424
option(PADDLEINFERENCE_DIRECTORY "Directory of custom Paddle Inference library" OFF)
25-
option(PADDLEINFERENCE_WITH_ENCRYPT_AUTH "Whether the Paddle Inference is built with FD encryption and auth" OFF)
2625

2726
set(PADDLEINFERENCE_PROJECT "extern_paddle_inference")
2827
set(PADDLEINFERENCE_PREFIX_DIR ${THIRD_PARTY_PATH}/paddle_inference)
@@ -43,44 +42,15 @@ if(PADDLEINFERENCE_DIRECTORY)
4342
endif()
4443

4544
include_directories(${PADDLEINFERENCE_INC_DIR})
46-
if(WIN32)
47-
set(PADDLEINFERENCE_COMPILE_LIB
48-
"${PADDLEINFERENCE_INSTALL_DIR}/paddle/lib/paddle_inference.lib"
49-
CACHE FILEPATH "paddle_inference compile library." FORCE)
50-
set(DNNL_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/mkldnn/lib/mkldnn.lib")
51-
set(OMP_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/mklml/lib/libiomp5md.lib")
52-
set(P2O_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/paddle2onnx/lib/paddle2onnx.lib")
53-
set(ORT_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/onnxruntime/lib/onnxruntime.lib")
54-
elseif(APPLE)
55-
set(PADDLEINFERENCE_COMPILE_LIB
56-
"${PADDLEINFERENCE_INSTALL_DIR}/paddle/lib/libpaddle_inference.dylib"
57-
CACHE FILEPATH "paddle_inference compile library." FORCE)
58-
set(DNNL_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/mkldnn/lib/libdnnl.so.2")
59-
set(OMP_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/mklml/lib/libiomp5.so")
60-
set(P2O_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/paddle2onnx/lib/libpaddle2onnx.dylib")
61-
set(ORT_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/onnxruntime/lib/libonnxruntime.dylib")
62-
else()
63-
set(PADDLEINFERENCE_COMPILE_LIB
64-
"${PADDLEINFERENCE_INSTALL_DIR}/paddle/lib/libpaddle_inference.so"
65-
CACHE FILEPATH "paddle_inference compile library." FORCE)
66-
set(DNNL_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/mkldnn/lib/libdnnl.so.2")
67-
set(OMP_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/mklml/lib/libiomp5.so")
68-
set(P2O_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/paddle2onnx/lib/libpaddle2onnx.so")
69-
set(ORT_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/onnxruntime/lib/libonnxruntime.so")
70-
if(PADDLEINFERENCE_WITH_ENCRYPT_AUTH)
71-
set(FDMODEL_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/fdmodel/lib/libfastdeploy_wenxin.so")
72-
set(FDMODEL_AUTH_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/fdmodel/lib/libfastdeploy_auth.so")
73-
set(FDMODEL_MODEL_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/fdmodel/lib/libfastdeploy_model.so.2.0.0")
74-
set(LEVELDB_LIB_DIR "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/leveldb/lib")
75-
endif()
76-
endif(WIN32)
7745

7846
if(PADDLEINFERENCE_DIRECTORY)
7947
# Use custom Paddle Inference libs.
8048
if(EXISTS "${THIRD_PARTY_PATH}/install/paddle_inference")
8149
file(REMOVE_RECURSE "${THIRD_PARTY_PATH}/install/paddle_inference")
8250
endif()
83-
find_package(Python COMPONENTS Interpreter Development REQUIRED)
51+
if(NOT Python_EXECUTABLE)
52+
find_package(Python COMPONENTS Interpreter Development REQUIRED)
53+
endif()
8454
message(STATUS "Copying ${PADDLEINFERENCE_DIRECTORY} to ${THIRD_PARTY_PATH}/install/paddle_inference ...")
8555
if(WIN32)
8656
execute_process(COMMAND mkdir -p ${THIRD_PARTY_PATH}/install)
@@ -166,6 +136,51 @@ else()
166136

167137
endif(PADDLEINFERENCE_DIRECTORY)
168138

139+
# check libs
140+
set(PADDLEINFERENCE_WITH_AUTH OFF)
141+
set(PADDLEINFERENCE_WITH_ENCRYPT OFF)
142+
if(WIN32)
143+
set(PADDLEINFERENCE_COMPILE_LIB
144+
"${PADDLEINFERENCE_INSTALL_DIR}/paddle/lib/paddle_inference.lib"
145+
CACHE FILEPATH "paddle_inference compile library." FORCE)
146+
set(DNNL_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/mkldnn/lib/mkldnn.lib")
147+
set(OMP_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/mklml/lib/libiomp5md.lib")
148+
set(P2O_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/paddle2onnx/lib/paddle2onnx.lib")
149+
set(ORT_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/onnxruntime/lib/onnxruntime.lib")
150+
elseif(APPLE)
151+
set(PADDLEINFERENCE_COMPILE_LIB
152+
"${PADDLEINFERENCE_INSTALL_DIR}/paddle/lib/libpaddle_inference.dylib"
153+
CACHE FILEPATH "paddle_inference compile library." FORCE)
154+
set(DNNL_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/mkldnn/lib/libdnnl.so.2")
155+
set(OMP_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/mklml/lib/libiomp5.so")
156+
set(P2O_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/paddle2onnx/lib/libpaddle2onnx.dylib")
157+
set(ORT_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/onnxruntime/lib/libonnxruntime.dylib")
158+
else()
159+
set(PADDLEINFERENCE_COMPILE_LIB
160+
"${PADDLEINFERENCE_INSTALL_DIR}/paddle/lib/libpaddle_inference.so"
161+
CACHE FILEPATH "paddle_inference compile library." FORCE)
162+
set(DNNL_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/mkldnn/lib/libdnnl.so.2")
163+
set(OMP_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/mklml/lib/libiomp5.so")
164+
set(P2O_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/paddle2onnx/lib/libpaddle2onnx.so")
165+
set(ORT_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/onnxruntime/lib/libonnxruntime.so")
166+
# Check whether the encrypt and auth tools exists. only support PADDLEINFERENCE_DIRECTORY now.
167+
if(PADDLEINFERENCE_DIRECTORY)
168+
set(FDMODEL_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/fdmodel/lib/libfastdeploy_wenxin.so")
169+
set(FDMODEL_MODEL_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/fdmodel/lib/libfastdeploy_model.so.2.0.0")
170+
set(FDMODEL_AUTH_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/fdmodel/lib/libfastdeploy_auth.so")
171+
set(FDMODEL_LEVELDB_LIB_DIR "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/leveldb")
172+
set(FDMODEL_LEVELDB_LIB_LIB "${PADDLEINFERENCE_INSTALL_DIR}/third_party/install/leveldb/lib/libleveldb.a")
173+
if((EXISTS ${FDMODEL_LIB}) AND (EXISTS ${FDMODEL_MODEL_LIB}))
174+
set(PADDLEINFERENCE_WITH_ENCRYPT ON CACHE BOOL "" FORCE)
175+
message(STATUS "Detected ${FDMODEL_LIB} and ${FDMODEL_MODEL_LIB} exists, fource PADDLEINFERENCE_WITH_ENCRYPT=${PADDLEINFERENCE_WITH_ENCRYPT}")
176+
endif()
177+
if((EXISTS ${FDMODEL_LIB}) AND (EXISTS ${FDMODEL_AUTH_LIB}))
178+
set(PADDLEINFERENCE_WITH_AUTH ON CACHE BOOL "" FORCE)
179+
message(STATUS "Detected ${FDMODEL_LIB} and ${FDMODEL_AUTH_LIB} exists, fource PADDLEINFERENCE_WITH_AUTH=${PADDLEINFERENCE_WITH_AUTH}")
180+
endif()
181+
endif()
182+
endif(WIN32)
183+
169184
# Path Paddle Inference ELF lib file
170185
if(UNIX AND (NOT APPLE) AND (NOT ANDROID))
171186
add_custom_target(patchelf_paddle_inference ALL COMMAND bash -c "PATCHELF_EXE=${PATCHELF_EXE} python ${PROJECT_SOURCE_DIR}/scripts/patch_paddle_inference.py ${PADDLEINFERENCE_INSTALL_DIR}/paddle/lib/libpaddle_inference.so" DEPENDS ${LIBRARY_NAME})
@@ -198,28 +213,37 @@ set_property(TARGET external_omp PROPERTY IMPORTED_LOCATION
198213
add_dependencies(external_omp ${PADDLEINFERENCE_PROJECT})
199214

200215
set(ENCRYPT_AUTH_LIBS )
201-
if(PADDLEINFERENCE_WITH_ENCRYPT_AUTH)
216+
if(PADDLEINFERENCE_WITH_ENCRYPT)
202217
add_library(external_fdmodel STATIC IMPORTED GLOBAL)
203218
set_property(TARGET external_fdmodel PROPERTY IMPORTED_LOCATION
204219
${FDMODEL_LIB})
205-
add_library(external_fdmodel_auth STATIC IMPORTED GLOBAL)
206-
set_property(TARGET external_fdmodel_auth PROPERTY IMPORTED_LOCATION
207-
${FDMODEL_AUTH_LIB})
220+
208221
add_library(external_fdmodel_model STATIC IMPORTED GLOBAL)
209222
set_property(TARGET external_fdmodel_model PROPERTY IMPORTED_LOCATION
210223
${FDMODEL_MODEL_LIB})
211-
add_dependencies(external_fdmodel ${PADDLEINFERENCE_PROJECT})
212-
add_dependencies(external_fdmodel_auth ${PADDLEINFERENCE_PROJECT})
213-
add_dependencies(external_fdmodel_model ${PADDLEINFERENCE_PROJECT})
214-
list(APPEND ENCRYPT_AUTH_LIBS external_fdmodel external_fdmodel_auth external_fdmodel_model)
224+
list(APPEND ENCRYPT_AUTH_LIBS external_fdmodel external_fdmodel_model)
225+
endif()
226+
227+
if(PADDLEINFERENCE_WITH_AUTH)
228+
add_library(external_fdmodel_auth STATIC IMPORTED GLOBAL)
229+
set_property(TARGET external_fdmodel_auth PROPERTY IMPORTED_LOCATION
230+
${FDMODEL_AUTH_LIB})
231+
list(APPEND ENCRYPT_AUTH_LIBS external_fdmodel_auth)
215232
endif()
216233

217-
function(enable_paddle_encrypt_auth_link_policy LIBRARY_NAME)
218-
if(ENABLE_PADDLE_BACKEND AND PADDLEINFERENCE_WITH_ENCRYPT_AUTH)
219-
link_directories(${LEVELDB_LIB_DIR})
220-
target_link_libraries(${LIBRARY_NAME} ${ENCRYPT_AUTH_LIBS} -lssl -lcrypto)
221-
target_link_libraries(${LIBRARY_NAME} ${LEVELDB_LIB_DIR}/libleveldb.a)
222-
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS
223-
"-Wl,--whole-archive ${LEVELDB_LIB_DIR}/libleveldb.a -Wl,-no-whole-archive")
234+
function(set_paddle_encrypt_auth_link_policy LIBRARY_NAME)
235+
if(ENABLE_PADDLE_BACKEND AND (PADDLEINFERENCE_WITH_ENCRYPT OR PADDLEINFERENCE_WITH_AUTH))
236+
target_link_libraries(${LIBRARY_NAME} ${ENCRYPT_AUTH_LIBS})
237+
# Note(qiuyanjun): Currently, for XPU, we need to manually link the whole
238+
# leveldb static lib into fastdeploy lib if PADDLEINFERENCE_WITH_ENCRYPT
239+
# or PADDLEINFERENCE_WITH_AUTH is 'ON'. Will remove this policy while
240+
# the bug of paddle inference lib with auth & encrypt fixed.
241+
if((EXISTS ${FDMODEL_LEVELDB_LIB_LIB}) AND WITH_KUNLUNXIN)
242+
target_link_libraries(${LIBRARY_NAME} -lssl -lcrypto)
243+
link_directories(${FDMODEL_LEVELDB_LIB_DIR})
244+
target_link_libraries(${LIBRARY_NAME} ${FDMODEL_LEVELDB_LIB_LIB})
245+
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS
246+
"-Wl,--whole-archive ${FDMODEL_LEVELDB_LIB_LIB} -Wl,-no-whole-archive")
247+
endif()
224248
endif()
225249
endfunction()

cmake/summary.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ function(fastdeploy_summary)
6262
endif()
6363
if(ENABLE_PADDLE_BACKEND)
6464
message(STATUS " Paddle Inference version : ${PADDLEINFERENCE_VERSION}")
65+
message(STATUS " PADDLE_WITH_ENCRYPT : ${PADDLEINFERENCE_WITH_ENCRYPT}")
66+
message(STATUS " PADDLE_WITH_AUTH : ${PADDLEINFERENCE_WITH_AUTH}")
6567
endif()
6668
if(ENABLE_POROS_BACKEND)
6769
message(STATUS " Poros version : ${POROS_VERSION}")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -e
17+
set +x
18+
19+
# -------------------------------------------------------------------------------
20+
# readonly global variables
21+
# -------------------------------------------------------------------------------
22+
readonly ROOT_PATH=$(pwd)
23+
readonly BUILD_ROOT=build/Linux
24+
readonly BUILD_DIR="${BUILD_ROOT}/x86_64_gpu"
25+
26+
# -------------------------------------------------------------------------------
27+
# tasks
28+
# -------------------------------------------------------------------------------
29+
__make_build_dir() {
30+
if [ ! -d "${BUILD_DIR}" ]; then
31+
echo "-- [INFO] BUILD_DIR: ${BUILD_DIR} not exists, setup manually ..."
32+
if [ ! -d "${BUILD_ROOT}" ]; then
33+
mkdir -p "${BUILD_ROOT}" && echo "-- [INFO] Created ${BUILD_ROOT} !"
34+
fi
35+
mkdir -p "${BUILD_DIR}" && echo "-- [INFO] Created ${BUILD_DIR} !"
36+
else
37+
echo "-- [INFO] Found BUILD_DIR: ${BUILD_DIR}"
38+
fi
39+
}
40+
41+
__check_cxx_envs() {
42+
if [ $LDFLAGS ]; then
43+
echo "-- [INFO] Found LDFLAGS: ${LDFLAGS}, \c"
44+
echo "unset it before crossing compiling ${BUILD_DIR}"
45+
unset LDFLAGS
46+
fi
47+
if [ $CPPFLAGS ]; then
48+
echo "-- [INFO] Found CPPFLAGS: ${CPPFLAGS}, \c"
49+
echo "unset it before crossing compiling ${BUILD_DIR}"
50+
unset CPPFLAGS
51+
fi
52+
if [ $CPLUS_INCLUDE_PATH ]; then
53+
echo "-- [INFO] Found CPLUS_INCLUDE_PATH: ${CPLUS_INCLUDE_PATH}, \c"
54+
echo "unset it before crossing compiling ${BUILD_DIR}"
55+
unset CPLUS_INCLUDE_PATH
56+
fi
57+
if [ $C_INCLUDE_PATH ]; then
58+
echo "-- [INFO] Found C_INCLUDE_PATH: ${C_INCLUDE_PATH}, \c"
59+
echo "unset it before crossing compiling ${BUILD_DIR}"
60+
unset C_INCLUDE_PATH
61+
fi
62+
}
63+
64+
__build_fastdeploy_linux_x86_64_gpu_shared_custom_paddle() {
65+
66+
local FASDEPLOY_INSTALL_DIR="${ROOT_PATH}/${BUILD_DIR}/fastdeploy_install"
67+
cd "${BUILD_DIR}" && echo "-- [INFO] Working Dir: ${PWD}"
68+
69+
cmake -DCMAKE_BUILD_TYPE=Release \
70+
-DWITH_GPU=ON \
71+
-DTRT_DIRECTORY=${TRT_DIRECTORY} \
72+
-DCUDA_DIRECTORY=${CUDA_DIRECTORY} \
73+
-DENABLE_ORT_BACKEND=ON \
74+
-DENABLE_TRT_BACKEND=ON \
75+
-DENABLE_PADDLE_BACKEND=ON \
76+
-DPADDLEINFERENCE_DIRECTORY=${PADDLEINFERENCE_DIRECTORY} \
77+
-DPADDLEINFERENCE_VERSION=${PADDLEINFERENCE_VERSION} \
78+
-DENABLE_OPENVINO_BACKEND=ON \
79+
-DENABLE_PADDLE2ONNX=ON \
80+
-DENABLE_VISION=OFF \
81+
-DENABLE_BENCHMARK=OFF \
82+
-DBUILD_EXAMPLES=OFF \
83+
-DPython_EXECUTABLE=/usr/bin/python3 \
84+
-DCMAKE_INSTALL_PREFIX=${FASDEPLOY_INSTALL_DIR} \
85+
-DLIBRARY_NAME=fastdeploy_runtime \
86+
-Wno-dev ../../.. && make -j8 && make install
87+
88+
echo "-- [INFO][built][x86_64_gpu}][${FASDEPLOY_INSTALL_DIR}]"
89+
echo "-- [INFO][${PADDLEINFERENCE_DIRECTORY}][${PADDLEINFERENCE_VERSION}]"
90+
}
91+
92+
main() {
93+
__make_build_dir
94+
__check_cxx_envs
95+
__build_fastdeploy_linux_x86_64_gpu_shared_custom_paddle
96+
exit 0
97+
}
98+
99+
main
100+
101+
# Usage:
102+
# export PADDLEINFERENCE_DIRECTORY=xxx
103+
# export PADDLEINFERENCE_VERSION=xxx
104+
# export CUDA_DIRECTOY=/usr/local/cuda
105+
# export TRT_DIRECTORY=/home/qiuyanjun/TensorRT-8.5.2.2
106+
# ./scripts/linux/build_linux_x86_64_cpp_gpu_encrypt_runtime.sh

serving/Dockerfile

+6-1
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,9 @@ COPY build/fastdeploy_install/* /opt/fastdeploy/
8080

8181
# Set environment variable
8282
ENV LD_LIBRARY_PATH="/opt/fastdeploy/lib:/opt/fastdeploy/third_libs/install/onnxruntime/lib:/opt/fastdeploy/third_libs/install/paddle2onnx/lib:/opt/fastdeploy/third_libs/install/paddle_inference/paddle/lib:/opt/fastdeploy/third_libs/install/openvino/runtime/lib/:/opt/fastdeploy/third_libs/install/tensorrt/lib/:/opt/fastdeploy/third_libs/install/opencv/lib64/:$LD_LIBRARY_PATH"
83-
ENV PATH="/opt/tritonserver/bin:$PATH"
83+
ENV PATH="/opt/tritonserver/bin:$PATH"
84+
85+
ENV http_proxy=
86+
ENV https_proxy=
87+
ENV no_proxy=
88+
ENV TZ=Asia/Shanghai

serving/Dockerfile_CUDA_11_2_TRT_8_5_PADDLE_2_4_2

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ RUN python3 -m pip install https://paddle-wheel.bj.bcebos.com/2.4.2/linux/linux-
5858
COPY serving/build/libtriton_fastdeploy.so /opt/tritonserver/backends/fastdeploy/
5959
COPY build/fastdeploy_install /opt/fastdeploy/
6060

61-
ENV LD_LIBRARY_PATH="/opt/TensorRT-8.5.2.2/lib/:/opt/fastdeploy/lib:/opt/fastdeploy/third_libs/install/onnxruntime/lib:/opt/fastdeploy/third_libs/install/paddle2onnx/lib:/opt/fastdeploy/third_libs/install/tensorrt/lib:/opt/fastdeploy/third_libs/install/paddle_inference/paddle/lib:/opt/fastdeploy/third_libs/install/paddle_inference/third_party/install/mkldnn/lib:/opt/fastdeploy/third_libs/install/paddle_inference/third_party/install/mklml/lib:/opt/fastdeploy/third_libs/install/openvino/runtime/lib:$LD_LIBRARY_PATH"
61+
ENV LD_LIBRARY_PATH="/opt/fastdeploy/lib:/opt/fastdeploy/third_libs/install/onnxruntime/lib:/opt/fastdeploy/third_libs/install/paddle2onnx/lib:/opt/fastdeploy/third_libs/install/tensorrt/lib:/opt/fastdeploy/third_libs/install/paddle_inference/paddle/lib:/opt/fastdeploy/third_libs/install/paddle_inference/third_party/install/mkldnn/lib:/opt/fastdeploy/third_libs/install/paddle_inference/third_party/install/mklml/lib:/opt/fastdeploy/third_libs/install/openvino/runtime/lib:$LD_LIBRARY_PATH"
6262
ENV PATH="/opt/tritonserver/bin:$PATH"

0 commit comments

Comments
 (0)