Skip to content

Commit

Permalink
feat(trtexec_vendor): add vendor package for trtexec
Browse files Browse the repository at this point in the history
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>
  • Loading branch information
Daisuke Nishimatsu committed Sep 9, 2022
1 parent edfe616 commit 11cfd53
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/trtexec_vendor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src
96 changes: 96 additions & 0 deletions common/trtexec_vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
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 REQUIRED)
find_package(cudnn_cmake_module REQUIRED)
find_package(CUDNN REQUIRED)
find_package(tensorrt_cmake_module REQUIRED)
find_package(TENSORRT REQUIRED)

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)
set(TENSORRT_BASE_URL https://raw.githubusercontent.com/NVIDIA/TensorRT/${TENSORRT_VERSION})
set(TRTEXEC_SRCS
samples/common/BatchStream.h
samples/common/EntropyCalibrator.h
samples/common/ErrorRecorder.h
samples/common/argsParser.h
samples/common/buffers.h
samples/common/common.h
samples/common/getOptions.cpp
samples/common/getOptions.h
samples/common/half.h
samples/common/logger.cpp
samples/common/logger.h
samples/common/logging.h
samples/common/parseOnnxConfig.h
samples/common/safeCommon.h
samples/common/sampleConfig.h
samples/common/sampleDevice.h
samples/common/sampleEngines.cpp
samples/common/sampleEngines.h
samples/common/sampleInference.cpp
samples/common/sampleInference.h
samples/common/sampleOptions.cpp
samples/common/sampleOptions.h
samples/common/sampleReporting.cpp
samples/common/sampleReporting.h
samples/common/sampleUtils.cpp
samples/common/sampleUtils.h
samples/trtexec/trtexec.cpp
)
foreach(SRC IN LISTS TRTEXEC_SRCS)
file(DOWNLOAD
${TENSORRT_BASE_URL}/${SRC}
${CMAKE_SOURCE_DIR}/src/${SRC}
SHOW_PROGRESS
TIMEOUT 60s
)
endforeach()
cuda_add_executable(trtexec
src/samples/trtexec/trtexec.cpp
src/samples/common/sampleEngines.cpp
src/samples/common/sampleInference.cpp
src/samples/common/sampleOptions.cpp
src/samples/common/sampleReporting.cpp
src/samples/common/sampleUtils.cpp
src/samples/common/logger.cpp
)
target_link_libraries(trtexec
${TENSORRT_LIBRARIES}
)
target_include_directories(trtexec
PRIVATE src/samples/common
)

install(TARGETS trtexec
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
endif()

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_copyright)
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>

0 comments on commit 11cfd53

Please sign in to comment.