diff --git a/cmake/inference_lib.cmake b/cmake/inference_lib.cmake index b3afae79ca3a875932e639ad28ca4772701f794f..20410361f4874aafefbc2fda6dc215d69debf58d 100644 --- a/cmake/inference_lib.cmake +++ b/cmake/inference_lib.cmake @@ -161,7 +161,7 @@ endif () if (TENSORRT_FOUND) set(dst_dir "${FLUID_INFERENCE_INSTALL_DIR}/third_party/install/tensorrt") copy(inference_lib_dist - SRCS ${TENSORRT_ROOT}/include/Nv*.h ${TENSORRT_ROOT}/lib/*nvinfer* + SRCS ${TENSORRT_INCLUDE_DIR}/Nv*.h ${TENSORRT_LIBRARY_DIR}/*nvinfer* DSTS ${dst_dir}/include ${dst_dir}/lib) endif () diff --git a/cmake/tensorrt.cmake b/cmake/tensorrt.cmake index fc97fcbf20a7312afe9667cf735b81357ff2c272..3db8a231ccbd00d95780d31c467089ee6785a071 100644 --- a/cmake/tensorrt.cmake +++ b/cmake/tensorrt.cmake @@ -19,13 +19,23 @@ endif() find_path(TENSORRT_INCLUDE_DIR NvInfer.h PATHS ${TENSORRT_ROOT} ${TENSORRT_ROOT}/include + ${TENSORRT_ROOT}/include/${CMAKE_LIBRARY_ARCHITECTURE} $ENV{TENSORRT_ROOT} $ENV{TENSORRT_ROOT}/include + $ENV{TENSORRT_ROOT}/include/${CMAKE_LIBRARY_ARCHITECTURE} NO_DEFAULT_PATH ) -find_library(TENSORRT_LIBRARY NAMES ${TR_INFER_LIB} ${TR_INFER_RT} +find_path(TENSORRT_LIBRARY_DIR NAMES ${TR_INFER_LIB} ${TR_INFER_RT} PATHS ${TENSORRT_ROOT} ${TENSORRT_ROOT}/lib + ${TENSORRT_ROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE} $ENV{TENSORRT_ROOT} $ENV{TENSORRT_ROOT}/lib + $ENV{TENSORRT_ROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE} + NO_DEFAULT_PATH + DOC "Path to TensorRT library." +) + +find_library(TENSORRT_LIBRARY NAMES ${TR_INFER_LIB} ${TR_INFER_RT} + PATHS ${TENSORRT_LIBRARY_DIR} NO_DEFAULT_PATH DOC "Path to TensorRT library.") @@ -35,12 +45,28 @@ if(TENSORRT_INCLUDE_DIR AND TENSORRT_LIBRARY) endif(WITH_DSO) else() set(TENSORRT_FOUND OFF) + if(WITH_DSO) + message(WARNING "TensorRT is NOT found.") + else(WITH_DSO) + message(WARNING "TensorRT is disabled because WITH_DSO is OFF.") + endif(WITH_DSO) endif() if(TENSORRT_FOUND) file(READ ${TENSORRT_INCLUDE_DIR}/NvInfer.h TENSORRT_VERSION_FILE_CONTENTS) string(REGEX MATCH "define NV_TENSORRT_MAJOR +([0-9]+)" TENSORRT_MAJOR_VERSION "${TENSORRT_VERSION_FILE_CONTENTS}") + + if("${TENSORRT_MAJOR_VERSION}" STREQUAL "") + file(READ ${TENSORRT_INCLUDE_DIR}/NvInferVersion.h TENSORRT_VERSION_FILE_CONTENTS) + string(REGEX MATCH "define NV_TENSORRT_MAJOR +([0-9]+)" TENSORRT_MAJOR_VERSION + "${TENSORRT_VERSION_FILE_CONTENTS}") + endif() + + if("${TENSORRT_MAJOR_VERSION}" STREQUAL "") + message(SEND_ERROR "Failed to detect TensorRT version.") + endif() + string(REGEX REPLACE "define NV_TENSORRT_MAJOR +([0-9]+)" "\\1" TENSORRT_MAJOR_VERSION "${TENSORRT_MAJOR_VERSION}") diff --git a/python/setup.py.in b/python/setup.py.in index 35033683a80766bd1552681ba4bf10e0526c1f37..79edac467f5eae13eea1baa6b6d12b51586d2870 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -173,8 +173,8 @@ package_data['paddle.libs']=[('libwarpctc' if os.name != 'nt' else 'warpctc') + shutil.copy('${WARPCTC_LIBRARIES}', libs_path) if '${TENSORRT_FOUND}' == 'ON' and os.name == 'nt': - shutil.copy(os.path.join('${TENSORRT_ROOT}', 'lib', '${TR_INFER_RT}'), libs_path) - shutil.copy(os.path.join('${TENSORRT_ROOT}', 'lib', '${TR_INFER_PLUGIN_RT}'), libs_path) + shutil.copy(os.path.join('${TENSORRT_LIBRARY_DIR}', '${TR_INFER_RT}'), libs_path) + shutil.copy(os.path.join('${TENSORRT_LIBRARY_DIR}', '${TR_INFER_PLUGIN_RT}'), libs_path) package_data['paddle.libs'] += ['${TR_INFER_RT}', '${TR_INFER_PLUGIN_RT}'] if '${WITH_MKL}' == 'ON':