File tree Expand file tree Collapse file tree 6 files changed +47
-9
lines changed Expand file tree Collapse file tree 6 files changed +47
-9
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ option(WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_F
39
39
option (WITH_AMD_GPU "Compile PaddlePaddle with AMD GPU" OFF )
40
40
option (WITH_AVX "Compile PaddlePaddle with AVX intrinsics" ${AVX_FOUND} )
41
41
option (WITH_MKL "Compile PaddlePaddle with MKL support." ${AVX_FOUND} )
42
- option (WITH_TENSORRT "Compile PaddlePaddle with TensorRT support." OFF )
43
42
option (WITH_DSO "Compile PaddlePaddle with dynamic linked CUDA" ON )
44
43
option (WITH_TESTING "Compile PaddlePaddle with unit testing" OFF )
45
44
option (WITH_SWIG_PY "Compile PaddlePaddle with inference api" ON )
@@ -180,13 +179,9 @@ set(EXTERNAL_LIBS
180
179
181
180
if (WITH_GPU )
182
181
include (cuda )
182
+ include (tensorrt )
183
183
endif (WITH_GPU )
184
184
185
- # TensorRT depends on GPU.
186
- if (NOT WITH_GPU )
187
- set (WITH_TENSORRT OFF )
188
- endif ()
189
-
190
185
if (WITH_AMD_GPU )
191
186
find_package (HIP )
192
187
include (hip )
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ ENV PATH=${PATH}:${GOROOT}/bin:${GOPATH}/bin
46
46
RUN curl -s -q https://glide.sh/get | sh
47
47
48
48
# Install TensorRT
49
- # The unnecessary files has been removed to make the library small.
49
+ # The unnecessary files has been removed to make the library small. It only contains include and lib now.
50
50
RUN wget -qO- http://paddlepaddledeps.bj.bcebos.com/TensorRT-4.0.0.3.Ubuntu-16.04.4.x86_64-gnu.cuda-8.0.cudnn7.0.tar.gz | \
51
51
tar -xz -C /usr/local && \
52
52
cp -rf /usr/local/TensorRT/include /usr && \
Original file line number Diff line number Diff line change @@ -80,6 +80,16 @@ if(WITH_GPU)
80
80
# Include cuda and cudnn
81
81
include_directories (${CUDNN_INCLUDE_DIR} )
82
82
include_directories (${CUDA_TOOLKIT_INCLUDE} )
83
+
84
+ if (TENSORRT_FOUND )
85
+ if (${CUDA_VERSION_MAJOR} VERSION_LESS 8 )
86
+ message (FATAL_ERROR "TensorRT needs CUDA >= 8.0 to compile" )
87
+ endif ()
88
+ if (${CUDNN_MAJOR_VERSION} VERSION_LESS 7 )
89
+ message (FATAL_ERROR "TensorRT needs CUDNN >= 7.0 to compile" )
90
+ endif ()
91
+ include_directories (${TENSORRT_INCLUDE_DIR} )
92
+ endif ()
83
93
elseif (WITH_AMD_GPU )
84
94
add_definitions (-DPADDLE_WITH_HIP )
85
95
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__HIP_PLATFORM_HCC__" )
Original file line number Diff line number Diff line change
1
+ if (NOT WITH_GPU )
2
+ return ()
3
+ endif ()
4
+
5
+ set (TENSORRT_ROOT "/usr" CACHE PATH "TENSORRT ROOT" )
6
+ find_path (TENSORRT_INCLUDE_DIR NvInfer.h
7
+ PATHS ${TENSORRT_ROOT} ${TENSORRT_ROOT} /include
8
+ $ENV{TENSORRT_ROOT} $ENV{TENSORRT_ROOT} /include
9
+ NO_DEFAULT_PATH
10
+ )
11
+
12
+ find_library (TENSORRT_LIBRARY NAMES libnvinfer.so libnvinfer.a
13
+ PATHS ${TENSORRT_ROOT} ${TENSORRT_ROOT} /lib
14
+ $ENV{TENSORRT_ROOT} $ENV{TENSORRT_ROOT} /lib
15
+ NO_DEFAULT_PATH
16
+ DOC "Path to TensorRT library." )
17
+
18
+ if (TENSORRT_INCLUDE_DIR AND TENSORRT_LIBRARY )
19
+ set (TENSORRT_FOUND ON )
20
+ else ()
21
+ set (TENSORRT_FOUND OFF )
22
+ endif ()
23
+
24
+ if (TENSORRT_FOUND )
25
+ file (READ ${TENSORRT_INCLUDE_DIR} /NvInfer.h TENSORRT_VERSION_FILE_CONTENTS )
26
+ string (REGEX MATCH "define NV_TENSORRT_MAJOR +([0-9]+)" TENSORRT_MAJOR_VERSION
27
+ "${TENSORRT_VERSION_FILE_CONTENTS} " )
28
+ string (REGEX REPLACE "define NV_TENSORRT_MAJOR +([0-9]+)" "\\ 1"
29
+ TENSORRT_MAJOR_VERSION "${TENSORRT_MAJOR_VERSION} " )
30
+
31
+ message (STATUS "Current TensorRT header is ${TENSORRT_INCLUDE_DIR} /NvInfer.h. "
32
+ "Current TensorRT version is v${TENSORRT_MAJOR_VERSION} . " )
33
+ endif ()
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ endif()
21
21
22
22
if (WITH_TESTING )
23
23
add_subdirectory (tests/book )
24
- if (WITH_TENSORRT )
24
+ if (TENSORRT_FOUND )
25
25
add_subdirectory (tensorrt )
26
26
endif ()
27
27
endif ()
Original file line number Diff line number Diff line change 1
1
cc_library (dynamic_loader SRCS dynamic_loader.cc DEPS glog gflags enforce )
2
2
3
3
list (APPEND CUDA_SRCS cublas.cc cudnn.cc curand.cc nccl.cc )
4
- if (WITH_TENSORRT )
4
+ if (TENSORRT_FOUND )
5
5
list (APPEND CUDA_SRCS tensorrt.cc )
6
6
endif ()
7
7
You can’t perform that action at this time.
0 commit comments