From 6e5a02facb28a0e636569fe51e9547b1164578b2 Mon Sep 17 00:00:00 2001 From: MRXLT Date: Thu, 22 Oct 2020 12:17:53 +0800 Subject: [PATCH] update setup && doc for trt --- cmake/paddlepaddle.cmake | 7 ++++++- doc/COMPILE.md | 22 +++++++--------------- doc/COMPILE_CN.md | 24 ++++++++---------------- python/CMakeLists.txt | 10 ++++++++++ python/setup.py.server_gpu.in | 8 +++++--- 5 files changed, 36 insertions(+), 35 deletions(-) diff --git a/cmake/paddlepaddle.cmake b/cmake/paddlepaddle.cmake index 13f77662..4b7d3ed1 100644 --- a/cmake/paddlepaddle.cmake +++ b/cmake/paddlepaddle.cmake @@ -130,4 +130,9 @@ SET_PROPERTY(TARGET xxhash PROPERTY IMPORTED_LOCATION ${PADDLE_INSTALL_DIR}/thir LIST(APPEND external_project_dependencies paddle) LIST(APPEND paddle_depend_libs - xxhash nvinfer nvinfer_plugin) + xxhash) + +if(WITH_TRT) +LIST(APPEND paddle_depend_libs + nvinfer nvinfer_plugin) +endif() diff --git a/doc/COMPILE.md b/doc/COMPILE.md index 6554179b..cf0bfdf2 100644 --- a/doc/COMPILE.md +++ b/doc/COMPILE.md @@ -205,7 +205,8 @@ To compile the Paddle Serving GPU version on bare metal, you need to install the - CUDA - CuDNN -- NCCL2 + +To compile the TensorRT version, you need to install the TensorRT library. Note here: @@ -215,21 +216,12 @@ Note here: The following is the base library version matching relationship used by the PaddlePaddle release version for reference: -| | CUDA | CuDNN | NCCL2 | -| :----: | :-----: | :----------------------: | :----: | -| CUDA 8 | 8.0.61 | CuDNN 7.1.2 for CUDA 8.0 | 2.1.4 | -| CUDA 9 | 9.0.176 | CuDNN 7.3.1 for CUDA 9.0 | 2.2.12 | +| | CUDA | CuDNN | TensorRT | +| :----: | :-----: | :----------------------: | :----: | +| post9 | 9.0 | CuDNN 7.3.1 for CUDA 9.0 | | +| post10 | 10.0 | CuDNN 7.5.1 for CUDA 10.0| | +| trt | 10.1 | CuDNN 7.5.1 for CUDA 10.1| 6.0.1.5 | ### How to make the compiler 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. - -### How to make the compiler detect the nccl library - -After downloading the corresponding version of the nccl2 library from the NVIDIA developer official website and decompressing it, add the following environment variables (take nccl2.1.4 as an example): - -```shell -export C_INCLUDE_PATH=/path/to/nccl2/cuda8/nccl_2.1.4-1+cuda8.0_x86_64/include:$C_INCLUDE_PATH -export CPLUS_INCLUDE_PATH=/path/to/nccl2/cuda8/nccl_2.1.4-1+cuda8.0_x86_64/include:$CPLUS_INCLUDE_PATH -export LD_LIBRARY_PATH=/path/to/nccl2/cuda8/nccl_2.1.4-1+cuda8.0_x86_64/lib/:$LD_LIBRARY_PATH -``` diff --git a/doc/COMPILE_CN.md b/doc/COMPILE_CN.md index c49c77b6..b3619d9a 100644 --- a/doc/COMPILE_CN.md +++ b/doc/COMPILE_CN.md @@ -202,7 +202,8 @@ Paddle Serving通过PaddlePaddle预测库支持在GPU上做预测。WITH_GPU选 - CUDA - CuDNN -- NCCL2 + +编译TensorRT版本,需要安装TensorRT库。 这里要注意的是: @@ -211,21 +212,12 @@ Paddle Serving通过PaddlePaddle预测库支持在GPU上做预测。WITH_GPU选 以下是PaddlePaddle发布版本所使用的基础库版本匹配关系,供参考: -| | CUDA | CuDNN | NCCL2 | -| :----: | :-----: | :----------------------: | :----: | -| CUDA 8 | 8.0.61 | CuDNN 7.1.2 for CUDA 8.0 | 2.1.4 | -| CUDA 9 | 9.0.176 | CuDNN 7.3.1 for CUDA 9.0 | 2.2.12 | +| | CUDA | CuDNN | TensorRT | +| :----: | :-----: | :----------------------: | :----: | +| post9 | 9.0 | CuDNN 7.3.1 for CUDA 9.0 | | +| post10 | 10.0 | CuDNN 7.5.1 for CUDA 10.0| | +| trt | 10.1 | CuDNN 7.5.1 for CUDA 10.1| 6.0.1.5 | ### 如何让Paddle Serving编译系统探测到CuDNN库 -从NVIDIA developer官网下载对应版本CuDNN并在本地解压后,在cmake编译命令中增加`-DCUDNN_ROOT`参数,指定CuDNN库所在路径。 - -### 如何让Paddle Serving编译系统探测到nccl库 - -从NVIDIA developer官网下载对应版本nccl2库并解压后,增加如下环境变量 (以nccl2.1.4为例): - -```shell -export C_INCLUDE_PATH=/path/to/nccl2/cuda8/nccl_2.1.4-1+cuda8.0_x86_64/include:$C_INCLUDE_PATH -export CPLUS_INCLUDE_PATH=/path/to/nccl2/cuda8/nccl_2.1.4-1+cuda8.0_x86_64/include:$CPLUS_INCLUDE_PATH -export LD_LIBRARY_PATH=/path/to/nccl2/cuda8/nccl_2.1.4-1+cuda8.0_x86_64/lib/:$LD_LIBRARY_PATH -``` +从NVIDIA developer官网下载对应版本CuDNN并在本地解压后,在cmake编译命令中增加`-DCUDNN_LIBRARY`参数,指定CuDNN库所在路径。 diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 4b20cb20..23e0b6b5 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -80,6 +80,16 @@ if (SERVER) COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel DEPENDS ${SERVING_SERVER_CORE} server_config_py_proto ${PY_FILES}) add_custom_target(paddle_python ALL DEPENDS ${PADDLE_SERVING_BINARY_DIR}/.timestamp) + elseif(WITH_TRT) + add_custom_command( + OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp + COMMAND cp -r + ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_server_gpu/ ${PADDLE_SERVING_BINARY_DIR}/python/ + COMMAND env ${py_env} ${PYTHON_EXECUTABLE} gen_version.py + "server_gpu" trt + COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel + DEPENDS ${SERVING_SERVER_CORE} server_config_py_proto ${PY_FILES}) + add_custom_target(paddle_python ALL DEPENDS ${PADDLE_SERVING_BINARY_DIR}/.timestamp) else() add_custom_command( OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp diff --git a/python/setup.py.server_gpu.in b/python/setup.py.server_gpu.in index 7379bcb8..1303e040 100644 --- a/python/setup.py.server_gpu.in +++ b/python/setup.py.server_gpu.in @@ -19,11 +19,13 @@ from __future__ import print_function from setuptools import setup, Distribution, Extension from setuptools import find_packages from setuptools import setup -from paddle_serving_server_gpu.version import serving_server_version +from paddle_serving_server_gpu.version import serving_server_version, cuda_version import util -max_version, mid_version, min_version = util.python_version() +if cuda_version != "trt": + cuda_version = "post" + cuda_version +max_version, mid_version, min_version = util.python_version() # gen pipeline proto code util.gen_pipeline_code("paddle_serving_server_gpu") @@ -56,7 +58,7 @@ package_data={'paddle_serving_server_gpu': ['pipeline/gateway/libproxy_server.so setup( name='paddle-serving-server-gpu', - version=serving_server_version.replace('-', '') + '.post@CUDA_VERSION_MAJOR@', + version=serving_server_version.replace('-', '') + "." + cuda_version, description= ('Paddle Serving Package for saved model with PaddlePaddle'), url='https://github.com/PaddlePaddle/Serving', -- GitLab