-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Refactor] refactor 2 basic demos and all related documents
- Loading branch information
Showing
20 changed files
with
835 additions
and
1,267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
project( | ||
tensorrtx | ||
VERSION 0.1 | ||
LANGUAGES C CXX CUDA) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CUDA_STANDARD 17) | ||
set(CMAKE_CUDA_STANDARD_REQUIRED ON) | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
set(CMAKE_BUILD_TYPE | ||
"Debug" | ||
CACHE STRING "build type" FORCE) | ||
|
||
option(CUDA_USE_STATIC_CUDA_RUNTIME "use static cuda runtime lib" OFF) | ||
|
||
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) | ||
set(CMAKE_CUDA_ARCHITECTURES | ||
60 | ||
70 | ||
72 | ||
75 | ||
80 | ||
86 | ||
89) | ||
endif() | ||
|
||
find_package(Threads REQUIRED) | ||
find_package(CUDAToolkit REQUIRED) | ||
|
||
include(cmake/FindTensorRT.cmake) | ||
|
||
set(TensorRT_7_TARGETS mlp lenet) | ||
|
||
set(TensorRT_8_TARGETS) | ||
|
||
set(TensorRT_10_TARGETS) | ||
|
||
set(ALL_TARGETS ${TensorRT_7_TARGETS} ${TensorRT_8_TARGETS} | ||
${TensorRT_10_TARGETS}) | ||
|
||
foreach(sub_dir ${ALL_TARGETS}) | ||
message(STATUS "Add subdirectory: ${sub_dir}") | ||
add_subdirectory(${sub_dir}) | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
cmake_minimum_required(VERSION 3.17.0) | ||
|
||
set(TRT_VERSION | ||
$ENV{TRT_VERSION} | ||
CACHE STRING | ||
"TensorRT version, e.g. \"8.6.1.6\" or \"8.6.1.6+cuda12.0.1.011\"") | ||
|
||
# process for different TensorRT version | ||
if(DEFINED TRT_VERSION AND NOT TRT_VERSION STREQUAL "") | ||
string(REGEX MATCH "([0-9]+)" _match ${TRT_VERSION}) | ||
set(TRT_MAJOR_VERSION "${_match}") | ||
set(_modules nvinfer nvinfer_plugin) | ||
|
||
if(TRT_MAJOR_VERSION GREATER_EQUAL 8) | ||
list(APPEND _modules nvinfer_vc_plugin nvinfer_dispatch nvinfer_lean) | ||
endif() | ||
else() | ||
message(FATAL_ERROR "Please set a environment variable \"TRT_VERSION\"") | ||
endif() | ||
|
||
if(NOT TensorRT_INCLUDE_DIR) | ||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") | ||
set(_trt_inc_dir "/usr/local/cuda/targets/aarch64-linux/include") | ||
else() | ||
set(_trt_inc_dir "/usr/include/x86_64-linux-gnu") | ||
endif() | ||
set(TensorRT_INCLUDE_DIR | ||
${_trt_inc_dir} | ||
CACHE PATH "TensorRT_INCLUDE_DIR") | ||
message(STATUS "TensorRT: ${TensorRT_INCLUDE_DIR}") | ||
endif() | ||
|
||
if(NOT TensorRT_LIBRARY_DIR) | ||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") | ||
set(_trt_lib_dir "/usr/local/cuda/targets/aarch64-linux/lib") | ||
else() | ||
set(_trt_lib_dir "/usr/include/x86_64-linux-gnu") | ||
endif() | ||
set(TensorRT_LIBRARY_DIR | ||
${_trt_lib_dir} | ||
CACHE PATH "TensorRT_LIBRARY_DIR") | ||
message(STATUS "TensorRT: ${TensorRT_LIBRARY_DIR}") | ||
endif() | ||
|
||
set(TensorRT_LIBRARIES) | ||
|
||
foreach(lib IN LISTS _modules) | ||
find_library( | ||
TensorRT_${lib}_LIBRARY | ||
NAMES ${lib} | ||
HINTS ${TensorRT_LIBRARY_DIR}) | ||
|
||
list(APPEND TensorRT_LIBRARIES ${TensorRT_${lib}_LIBRARY}) | ||
endforeach() | ||
|
||
message(STATUS "Found TensorRT lib: ${TensorRT_LIBRARIES}") | ||
|
||
if(NOT TARGET TensorRT::TensorRT) | ||
add_library(TensorRT IMPORTED INTERFACE) | ||
add_library(TensorRT::TensorRT ALIAS TensorRT) | ||
endif() | ||
|
||
target_link_libraries(TensorRT INTERFACE ${TensorRT_LIBRARIES}) | ||
|
||
set_target_properties( | ||
TensorRT | ||
PROPERTIES C_STANDARD 17 | ||
CXX_STANDARD 17 | ||
POSITION_INDEPENDENT_CODE ON | ||
SKIP_BUILD_RPATH TRUE | ||
BUILD_WITH_INSTALL_RPATH TRUE | ||
INSTALL_RPATH "$\{ORIGIN\}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${TensorRT_INCLUDE_DIR}") | ||
|
||
unset(TRT_MAJOR_VERSION) | ||
unset(_modules) |
Oops, something went wrong.