forked from tier4/autoware.universe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(trtexec_vendor): add vendor package for trtexec (autowarefoundat…
…ion#1821) * feat(trtexec_vendor): add vendor package for trtexec Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp> * support the previous CUDA environemt Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com> * remove required for nvidia libraries Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com> * add sampleUtils.cpp if trt version is greater than 8.4 Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp> * do not install trt submodules Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp> Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp> Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com>
- Loading branch information
1 parent
ec173ab
commit 7f4a810
Showing
3 changed files
with
109 additions
and
0 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,84 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
project(trtexec_vendor) | ||
|
||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
endif() | ||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
find_package(ament_cmake REQUIRED) | ||
find_package(CUDA) | ||
find_package(cudnn_cmake_module REQUIRED) | ||
find_package(CUDNN) | ||
find_package(tensorrt_cmake_module REQUIRED) | ||
find_package(TENSORRT) | ||
|
||
if(NOT (${CUDA_FOUND} AND ${CUDNN_FOUND} AND ${TENSORRT_FOUND})) | ||
message(WARNING "cuda, cudnn, tensorrt libraries are not found") | ||
return() | ||
endif() | ||
|
||
set(TRTEXEC_DEFAULT_BIN /usr/src/tensorrt/bin/trtexec) | ||
if(NOT EXISTS TRTEXEC_DEFAULT_BIN) | ||
include(FetchContent) | ||
if(${TENSORRT_VERSION} VERSION_EQUAL 8.4.2) | ||
set(TENSORRT_VERSION 8.4.1) | ||
endif() | ||
if(${TENSORRT_VERSION} VERSION_EQUAL 8.2.4) | ||
set(TENSORRT_VERSION 8.2.1) | ||
endif() | ||
fetchcontent_declare(tensorrt | ||
GIT_REPOSITORY https://github.com/NVIDIA/TensorRT | ||
GIT_TAG ${TENSORRT_VERSION} | ||
GIT_SUBMODULES "" | ||
) | ||
fetchcontent_getproperties(tensorrt) | ||
if(NOT tensorrt_POPULATED) | ||
fetchcontent_populate(tensorrt) | ||
endif() | ||
set(TRTEXEC_SOURCES | ||
${tensorrt_SOURCE_DIR}/samples/trtexec/trtexec.cpp | ||
${tensorrt_SOURCE_DIR}/samples/common/sampleEngines.cpp | ||
${tensorrt_SOURCE_DIR}/samples/common/sampleInference.cpp | ||
${tensorrt_SOURCE_DIR}/samples/common/sampleOptions.cpp | ||
${tensorrt_SOURCE_DIR}/samples/common/sampleReporting.cpp | ||
${tensorrt_SOURCE_DIR}/samples/common/logger.cpp | ||
) | ||
if(${TENSORRT_VERSION} VERSION_GREATER_EQUAL 8.4) | ||
list(APPEND TRTEXEC_SOURCES | ||
${tensorrt_SOURCE_DIR}/samples/common/sampleUtils.cpp | ||
) | ||
endif() | ||
cuda_add_executable(${PROJECT_NAME} | ||
${TRTEXEC_SOURCES} | ||
) | ||
target_link_libraries(${PROJECT_NAME} | ||
${TENSORRT_LIBRARIES} | ||
) | ||
target_include_directories(${PROJECT_NAME} | ||
PRIVATE ${tensorrt_SOURCE_DIR}/samples/common | ||
) | ||
|
||
set_target_properties(${PROJECT_NAME} | ||
PROPERTIES OUTPUT_NAME trtexec | ||
) | ||
|
||
install(TARGETS ${PROJECT_NAME} | ||
ARCHIVE DESTINATION lib | ||
LIBRARY DESTINATION lib | ||
RUNTIME DESTINATION bin | ||
) | ||
endif() | ||
|
||
if(BUILD_TESTING) | ||
find_package(ament_lint_auto REQUIRED) | ||
ament_lint_auto_find_test_dependencies() | ||
endif() | ||
|
||
ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/env-hooks/${PROJECT_NAME}.sh.in") | ||
|
||
ament_package() |
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,5 @@ | ||
TRTEXEC_DEFAULT_BIN_DIR=/usr/src/tensorrt/bin | ||
TRTEXEC_DEFAULT_BIN=$TRTEXEC_DEFAULT_BIN_DIR/trtexec | ||
if [ -f $TRTEXEC_DEFAULT_BIN ]; then | ||
ament_prepend_unique_value PATH $TRTEXEC_DEFAULT_BIN_DIR | ||
fi |
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,20 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>trtexec_vendor</name> | ||
<version>0.1.0</version> | ||
<description>The vendor package of trtexec</description> | ||
<maintainer email="daisuke.nishimatsu@tier4.jp">Daisuke Nishimatsu</maintainer> | ||
<license>Apache 2.0</license> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
<buildtool_depend>cudnn_cmake_module</buildtool_depend> | ||
<buildtool_depend>tensorrt_cmake_module</buildtool_depend> | ||
|
||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>autoware_lint_common</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |