forked from nwesem/mtcnn_facenet_cpp_tensorRT
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
79 lines (66 loc) · 2.33 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
set(PROJECT_NAME mtcnn_facenet_cpp_tensorRT)
project(${PROJECT_NAME})# LANGUAGES CXX CUDA)
set (CMAKE_CXX_STANDARD 11)
# OpenCV
find_package(OpenCV REQUIRED)
find_package(CUDA)
message("-- CUDA version: ${CUDA_VERSION}")
set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
-O3
-gencode arch=compute_53,code=sm_53
-gencode arch=compute_62,code=sm_62
)
if(CUDA_VERSION_MAJOR GREATER 9)
message("-- CUDA ${CUDA_VERSION_MAJOR} detected, enabling SM_72")
set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
-gencode arch=compute_72,code=sm_72
)
endif()
# tensorRT
message("CUDA_TOOLKIT_ROOT_DIR = ${CUDA_TOOLKIT_ROOT_DIR}")
find_path(TENSORRT_INCLUDE_DIR NvInfer.h
HINTS ${TENSORRT_ROOT} ${CUDA_TOOLKIT_ROOT_DIR} /usr/include
PATH_SUFFIXES include)
find_path(TENSORRT_INCLUDE_DIR NvInferPlugin.h
HINTS ${TENSORRT_ROOT} ${CUDA_TOOLKIT_ROOT_DIR}
PATH_SUFFIXES include)
MESSAGE(STATUS "Found TensorRT headers at ${TENSORRT_INCLUDE_DIR}")
find_library(TENSORRT_LIBRARY_INFER nvinfer
HINTS ${TENSORRT_ROOT} ${TENSORRT_BUILD} ${CUDA_TOOLKIT_ROOT_DIR}
PATH_SUFFIXES lib lib64 lib/x64 lib/aarch64-linux-gnu)
find_library(TENSORRT_LIBRARY_INFER_PLUGIN nvinfer_plugin
HINTS ${TENSORRT_ROOT} ${TENSORRT_BUILD} ${CUDA_TOOLKIT_ROOT_DIR}
PATH_SUFFIXES lib lib64 lib/x64 lib/aarch64-linux-gnu)
find_library(TENSORRT_LIBRARY_PARSER nvparsers
HINTS ${TENSORRT_ROOT} ${TENSORRT_BUILD} ${CUDA_TOOLKIT_ROOT_DIR}
PATH_SUFFIXES lib lib64 lib/x64 lib/aarch64-linux-gnu)
set(TENSORRT_LIBRARY ${TENSORRT_LIBRARY_INFER} ${TENSORRT_LIBRARY_INFER_PLUGIN} ${TENSORRT_LIBRARY_PARSER})
message(STATUS "Find TensorRT libs at ${TENSORRT_LIBRARY}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
TENSORRT DEFAULT_MSG TENSORRT_INCLUDE_DIR TENSORRT_LIBRARY)
if(NOT TENSORRT_FOUND)
message(ERROR
"Cannot find TensorRT library.")
endif()
# l2norm_helper plugin
add_subdirectory(trt_l2norm_helper)
include_directories(
trt_l2norm_helper
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
${TENSORRT_INCLUDE_DIR}
)
message("TENSORRT_LIBRARY = ${TENSORRT_LIBRARY}")
AUX_SOURCE_DIRECTORY(./src DIR_SRCS)
message("DIR_SRCS = ${DIR_SRCS}")
cuda_add_executable(${PROJECT_NAME} ${DIR_SRCS})
target_link_libraries(${PROJECT_NAME}
trt_l2norm_helper
${TENSORRT_LIBRARY}
)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})