-
Notifications
You must be signed in to change notification settings - Fork 892
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
186 lines (165 loc) · 5.56 KB
/
CMakeLists.txt
File metadata and controls
186 lines (165 loc) · 5.56 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
cmake_minimum_required(VERSION 3.14)
project(autoware_tensorrt_plugins)
find_package(autoware_cmake REQUIRED)
autoware_package()
add_compile_options(-Wno-deprecated-declarations)
option(CUDA_VERBOSE "Verbose output of CUDA modules" OFF)
# set flags for CUDA availability
option(CUDA_AVAIL "CUDA available" OFF)
find_package(CUDA)
if(CUDA_FOUND)
find_library(CUBLAS_LIBRARIES cublas HINTS
${CUDA_TOOLKIT_ROOT_DIR}/lib64
${CUDA_TOOLKIT_ROOT_DIR}/lib
)
if(CUDA_VERBOSE)
message("CUDA is available!")
message("CUDA Libs: ${CUDA_LIBRARIES}")
message("CUDA Headers: ${CUDA_INCLUDE_DIRS}")
endif()
# Note: cublas_device was depreciated in CUDA version 9.2
# https://forums.developer.nvidia.com/t/where-can-i-find-libcublas-device-so-or-libcublas-device-a/67251/4
# In LibTorch, CUDA_cublas_device_LIBRARY is used.
unset(CUDA_cublas_device_LIBRARY CACHE)
set(CUDA_AVAIL ON)
else()
message("CUDA NOT FOUND")
set(CUDA_AVAIL OFF)
endif()
# set flags for TensorRT availability
option(TRT_AVAIL "TensorRT available" OFF)
# try to find the tensorRT modules
find_library(NVINFER nvinfer)
find_library(NVONNXPARSER nvonnxparser)
if(NVINFER AND NVONNXPARSER)
if(CUDA_VERBOSE)
message("TensorRT is available!")
message("NVINFER: ${NVINFER}")
message("NVONNXPARSER: ${NVONNXPARSER}")
endif()
set(TRT_AVAIL ON)
else()
message("TensorRT is NOT available")
set(TRT_AVAIL OFF)
endif()
# set flags for spconv availability
option(SPCONV_AVAIL "spconv available" OFF)
# try to find spconv
find_package(cumm)
find_package(spconv)
if(${cumm_FOUND} AND ${spconv_FOUND})
message(STATUS "spconv is available!")
set(SPCONV_AVAIL ON)
else()
message(WARNING "spconv is NOT available")
set(SPCONV_AVAIL OFF)
endif()
if(TRT_AVAIL AND CUDA_AVAIL AND SPCONV_AVAIL)
find_package(tensorrt_cmake_module REQUIRED)
find_package(TENSORRT)
if(TENSORRT_VERSION VERSION_LESS 10.0)
message(WARNING "Unsupported version TensorRT ${TENSORRT_VERSION} detected. This package requires TensorRT 10.0 or later.")
return()
endif()
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()
include_directories(
include
${CUDA_INCLUDE_DIRS}
)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CUDA_FLAGS ${CMAKE_CUDA_FLAGS} "-g -G")
endif()
add_definitions("-DTV_CUDA")
# cSpell:ignore expt
list(APPEND CUDA_NVCC_FLAGS "--expt-relaxed-constexpr -diag-suppress 1675 --extended-lambda")
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_75,code=sm_75")
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_86,code=sm_86")
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_87,code=sm_87")
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_89,code=sm_89")
if(CUDA_VERSION VERSION_GREATER_EQUAL "12.8")
if(CUDA_VERSION VERSION_LESS "13.0")
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_101,code=sm_101")
else() # CUDA 13.0 renamed SM101 to SM110
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_110,code=sm_110")
endif()
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_120,code=sm_120")
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_120,code=compute_120")
else()
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_89,code=compute_89")
endif()
cuda_add_library(cuda_ops SHARED
src/argsort_ops/argsort.cu
src/bev_ops/bev_pool_cuda.cu
src/scatter_ops/segment_csr.cu
src/unique_ops/unique.cu
src/multi_scale_deform_attn_ops/ms_deform_attn_kernel.cu
src/rotate_ops/rotate_kernel.cu
src/select_and_pad_ops/select_and_pad_kernel.cu
)
add_library(${PROJECT_NAME} SHARED
src/argsort_plugin.cpp
src/argsort_plugin_creator.cpp
src/quick_cumsum_cuda_plugin.cpp
src/quick_cumsum_cuda_plugin_creator.cpp
src/get_indices_pairs_implicit_gemm_plugin_creator.cpp
src/get_indices_pairs_implicit_gemm_plugin.cpp
src/get_indices_pairs_plugin_creator.cpp
src/get_indices_pairs_plugin.cpp
src/implicit_gemm_plugin_creator.cpp
src/implicit_gemm_plugin.cpp
src/indice_conv_plugin_creator.cpp # cSpell:ignore indice
src/indice_conv_plugin.cpp
src/multi_scale_deformable_attention_plugin.cpp
src/multi_scale_deformable_attention_plugin_creator.cpp
src/rotate_plugin.cpp
src/rotate_plugin_creator.cpp
src/segment_csr_plugin_creator.cpp
src/segment_csr_plugin.cpp
src/select_and_pad_plugin.cpp
src/select_and_pad_plugin_creator.cpp
src/unique_plugin.cpp
src/unique_plugin_creator.cpp
src/plugin_registration.cpp
src/plugin_utils.cpp
)
target_compile_definitions(${PROJECT_NAME} PRIVATE _GLIBCXX_USE_CXX11_ABI=1)
target_link_libraries(${PROJECT_NAME} PRIVATE
${NVINFER}
CUDA::cudart
cuda_ops
spconv::spconv
)
if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
ament_add_gtest(reference_kernels_test
test/argsort_kernel_test.cpp
test/unique_kernel_test.cpp
)
if(TARGET reference_kernels_test)
target_link_libraries(reference_kernels_test
CUDA::cudart
cuda_ops
)
target_include_directories(reference_kernels_test PRIVATE
include
test
${autoware_cuda_utils_INCLUDE_DIRS}
${CUDA_INCLUDE_DIRS}
)
target_compile_definitions(reference_kernels_test PRIVATE _GLIBCXX_USE_CXX11_ABI=1)
endif()
endif()
install(
TARGETS ${PROJECT_NAME}
DESTINATION share/${PROJECT_NAME}/plugins
)
install(
TARGETS cuda_ops
LIBRARY DESTINATION lib
)
ament_auto_package()
else()
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()
endif()