From f5afeef13fce5c267cab5ecc2eb2d83c547a6993 Mon Sep 17 00:00:00 2001 From: Shang Zhizhou Date: Wed, 2 Dec 2020 16:50:50 +0800 Subject: [PATCH] add compile option WITH_TENSORRT (#29208) (#29264) * add compile option WITH_TENSORRT * add WITH_TENSORRT to ci paddle_buils.sh * add WITH_TENSORRT to paddle_build.sh * change FATAL to WARNING when TensorRT is not found and WITN_TENSORRT=ON, just to pass ci-py3 temporarily --- CMakeLists.txt | 1 + cmake/tensorrt.cmake | 4 ++-- paddle/scripts/paddle_build.sh | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36b33e0eba6..8322b7f378a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ include(generic) # simplify cmake module # TODO(Shibo Tao): remove find_package(CUDA) completely. find_package(CUDA QUIET) option(WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_FOUND}) +option(WITH_TENSORRT "Compile PaddlePaddle with NVIDIA TensorRT" OFF) option(WITH_XPU "Compile PaddlePaddle with BAIDU KUNLUN" OFF) if (WITH_GPU AND WITH_XPU) message(FATAL_ERROR "Error when compile GPU and XPU at the same time") diff --git a/cmake/tensorrt.cmake b/cmake/tensorrt.cmake index d715dfd0dbe..889332fc557 100644 --- a/cmake/tensorrt.cmake +++ b/cmake/tensorrt.cmake @@ -1,4 +1,4 @@ -if(NOT WITH_GPU) +if(NOT WITH_GPU OR NOT WITH_TENSORRT) return() endif() @@ -40,7 +40,7 @@ if(TENSORRT_INCLUDE_DIR AND TENSORRT_LIBRARY) set(TENSORRT_FOUND ON) else() set(TENSORRT_FOUND OFF) - message(STATUS "TensorRT is disabled.") + message(WARNING "TensorRT is disabled. You are compiling PaddlePaddle with option -DWITH_TENSORRT=ON, but TensorRT is not found, please configure path to TensorRT with option -DTENSORRT_ROOT or install it.") endif() if(TENSORRT_FOUND) diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 12077781da5..35c9d581d9f 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -222,6 +222,7 @@ function cmake_base() { -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} ${PYTHON_FLAGS} -DWITH_GPU=${WITH_GPU:-OFF} + -DWITH_TENSORRT=${WITH_TENSORRT:-ON} -DWITH_AMD_GPU=${WITH_AMD_GPU:-OFF} -DWITH_DISTRIBUTE=${distibuted_flag} -DWITH_MKL=${WITH_MKL:-ON} @@ -254,6 +255,7 @@ EOF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} \ ${PYTHON_FLAGS} \ -DWITH_GPU=${WITH_GPU:-OFF} \ + -DWITH_TENSORRT=${WITH_TENSORRT:-ON} \ -DWITH_AMD_GPU=${WITH_AMD_GPU:-OFF} \ -DWITH_DISTRIBUTE=${distibuted_flag} \ -DWITH_MKL=${WITH_MKL:-ON} \ -- GitLab