Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(trtexec_vendor): add vendor package for trtexec #1821

Merged
merged 5 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions common/trtexec_vendor/CMakeLists.txt
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()
wep21 marked this conversation as resolved.
Show resolved Hide resolved
if(${TENSORRT_VERSION} VERSION_EQUAL 8.2.4)
set(TENSORRT_VERSION 8.2.1)
endif()
fetchcontent_declare(tensorrt
wep21 marked this conversation as resolved.
Show resolved Hide resolved
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()
5 changes: 5 additions & 0 deletions common/trtexec_vendor/env-hooks/trtexec_vendor.sh.in
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
20 changes: 20 additions & 0 deletions common/trtexec_vendor/package.xml
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>