11# usage:
22# cd build/
3- # cmake -S ../ -B ./ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CUDA_ARCHITECTURES=80 -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -DORT_HOME=/home/lochi/repos/ort -DTENSORRT_HOME=/home/lochi/tensorrt/TensorRT-10.3.0.26 (see the result of "nvidia-smi --query-gpu=compute_cap --format=csv,noheader,nounits")
3+ # cmake -S ../ -B ./ -DCMAKE_BUILD_TYPE=Debug -DORT_HOME=/home/lochi/onnxruntime-win-x64-gpu-1.22.0 - DCMAKE_CUDA_ARCHITECTURES=80 -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -DTENSORRT_HOME=/home/lochi/tensorrt/TensorRT-10.3.0.26 (see the result of "nvidia-smi --query-gpu=compute_cap --format=csv,noheader,nounits")
44# cmake --build ./ --config Debug
55cmake_minimum_required (VERSION 3.26)
66project (TensorRTEp VERSION 1.0)
@@ -13,7 +13,7 @@ add_definitions(-DONNX_NAMESPACE=onnx)
1313add_definitions (-DONNX_ML)
1414add_definitions (-DNV_TENSORRT_MAJOR=10)
1515add_definitions (-DNOMINMAX)
16- file (GLOB tensorrt_src "./*.cc" "./utils/*.cc" "./cuda/unary_elementwise_ops_impl.cu" )
16+ file (GLOB tensorrt_src "./*.cc" "./utils/*.cc" "./cuda/unary_elementwise_ops_impl.cu" "./*.h" )
1717add_library (TensorRTEp SHARED ${tensorrt_src} )
1818
1919if (NOT ORT_HOME)
@@ -32,6 +32,24 @@ endif()
3232# Add dependencies
3333include (FetchContent)
3434
35+ # Add protobuf
36+ FetchContent_Declare(
37+ protobuf
38+ GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
39+ GIT_TAG v21.12 # Use a specific tag or commit
40+ )
41+
42+ FetchContent_MakeAvailable(protobuf)
43+
44+ # Add ONNX
45+ FetchContent_Declare(
46+ onnx
47+ GIT_REPOSITORY https://github.com/onnx/onnx.git
48+ GIT_TAG v1.18.0 # Use a specific tag or commit
49+ )
50+
51+ FetchContent_MakeAvailable(onnx)
52+
3553# Add GSL
3654FetchContent_Declare(
3755 gsl
@@ -50,17 +68,18 @@ FetchContent_Declare(
5068
5169FetchContent_MakeAvailable(flatbuffers)
5270
53- if (WIN32 )
54- set (PLATFORM "Windows" )
55- set (ORT_LIB "${ORT_HOME} /build/${PLATFORM} /${CMAKE_BUILD_TYPE} /${CMAKE_BUILD_TYPE} /onnxruntime.lib" )
56- set (DEPS_PATH "${ORT_HOME} /build/${PLATFORM} /${CMAKE_BUILD_TYPE} /_deps" )
71+ set (DEPS_PATH "${CMAKE_BINARY_DIR} /_deps" )
72+
73+ if (WIN32 ) # Windows
74+ set (ORT_LIB "${ORT_HOME} /lib/onnxruntime.lib" )
75+ #set(ORT_LIB "${ORT_HOME}/lib/onnxruntime.dll")
5776 set (TRT_LIBS "${TENSORRT_HOME} /lib/nvinfer_10.lib"
5877 "${TENSORRT_HOME} /lib/nvinfer_plugin_10.lib"
5978 "${TENSORRT_HOME} /lib/nvonnxparser_10.lib" )
6079 set (DEPS_LIBS "${DEPS_PATH} /flatbuffers-build/${CMAKE_BUILD_TYPE} /flatbuffers.lib"
61- "${DEPS_PATH} /onnx-build/${CMAKE_BUILD_TYPE} /onnx.lib"
62- "${DEPS_PATH} /onnx-build/${CMAKE_BUILD_TYPE} /onnx_proto.lib" )
63-
80+ "${DEPS_PATH} /onnx-build/${CMAKE_BUILD_TYPE} /onnx.lib"
81+ "${DEPS_PATH} /onnx-build/${CMAKE_BUILD_TYPE} /onnx_proto.lib" )
82+
6483 if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
6584 set (DEPS_LIBS ${DEPS_LIBS}
6685 "${DEPS_PATH} /protobuf-build/${CMAKE_BUILD_TYPE} /libprotobufd.lib"
@@ -70,17 +89,15 @@ if (WIN32)
7089 "${DEPS_PATH} /protobuf-build/${CMAKE_BUILD_TYPE} /libprotobuf.lib"
7190 "${DEPS_PATH} /protobuf-build/${CMAKE_BUILD_TYPE} /libprotoc.lib" )
7291 endif ()
73- else ()
74- set (PLATFORM "Linux" )
75- set (ORT_LIB "${ORT_HOME} /build/${PLATFORM} /${CMAKE_BUILD_TYPE} /libonnxruntime.so" )
76- set (DEPS_PATH "${ORT_HOME} /build/${PLATFORM} /${CMAKE_BUILD_TYPE} /_deps" )
92+ else () # Linux
93+ set (ORT_LIB "${ORT_HOME} /lib/libonnxruntime.so" )
7794 set (TRT_LIBS "${TENSORRT_HOME} /lib/libnvinfer.so"
7895 "${TENSORRT_HOME} /lib/libnvinfer_plugin.so"
7996 "${TENSORRT_HOME} /lib/libnvonnxparser.so" )
8097 set (DEPS_LIBS "${DEPS_PATH} /flatbuffers-build/libflatbuffers.a"
8198 "${DEPS_PATH} /onnx-build/libonnx.a"
8299 "${DEPS_PATH} /onnx-build/libonnx_proto.a" )
83-
100+
84101 if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
85102 set (DEPS_LIBS ${DEPS_LIBS}
86103 "${DEPS_PATH} /protobuf-build/libprotobufd.a"
@@ -93,17 +110,14 @@ else()
93110endif ()
94111
95112MESSAGE (STATUS "Looking for following dependencies ..." )
96- MESSAGE (STATUS "Platform : ${PLATFORM} " )
97- MESSAGE (STATUS "ORT home : ${ORT_HOME} " )
98113MESSAGE (STATUS "ORT lib : ${ORT_LIB} " )
99- MESSAGE (STATUS "Deps path: ${DEPS_PATH} " )
100- MESSAGE (STATUS "Deps libs: ${DEPS_LIBS} " )
101114MESSAGE (STATUS "TRT libs : ${TRT_LIBS} " )
115+ MESSAGE (STATUS "Deps libs: ${DEPS_LIBS} " )
102116
103- target_include_directories (TensorRTEp PUBLIC "${ORT_HOME} /include/onnxruntime/core/session/ "
117+ target_include_directories (TensorRTEp PUBLIC "${ORT_HOME} /include"
104118 "./utils"
105119 "/usr/local/cuda/include"
106- ${TENSORRT_HOME} /include
120+ " ${TENSORRT_HOME} /include"
107121 "${DEPS_PATH} /flatbuffers-src/include"
108122 "${DEPS_PATH} /gsl-src/include"
109123 "${DEPS_PATH} /onnx-src"
@@ -114,6 +128,8 @@ target_include_directories(TensorRTEp PUBLIC "${ORT_HOME}/include/onnxruntime/co
114128target_link_libraries (TensorRTEp PUBLIC ${ORT_LIB}
115129 ${TRT_LIBS}
116130 CUDA::cudart
117- ${DEPS_LIBS}
118- GSL
119- flatbuffers)
131+ protobuf
132+ onnx
133+ gsl
134+ flatbuffers
135+ )
0 commit comments