tensorRT的cmake写法
时间: 2023-05-24 09:05:42 浏览: 458
TensorRT的CMake写法如下所示:
```cmake
cmake_minimum_required(VERSION 3.14)
project(my_tensorrt_project)
# set your TensorRT root path
set(TENSORRT_ROOT /path/to/tensorrt)
# find required packages
find_package(CUDA REQUIRED)
find_package(OpenCV REQUIRED)
# set include directories
include_directories(${TENSORRT_ROOT}/include)
include_directories(${CUDA_INCLUDE_DIRS})
include_directories(${OpenCV_INCLUDE_DIRS})
# set link libraries
link_directories(${TENSORRT_ROOT}/lib)
link_libraries(nvinfer)
link_libraries(nvinfer_plugin)
link_libraries(cublas)
link_libraries(cudart)
link_libraries(curand)
link_libraries(${OpenCV_LIBS})
# set source files
set(SOURCES src/main.cpp
src/trt_engine.cpp
src/trt_utils.cpp
src/trt_infer.cpp)
# set executable
add_executable(my_tensorrt_app ${SOURCES})
```
此示例中,需要设置TensorRT的安装路径,并根据需要设置其他库的路径和文件名。然后,需要找到所需的CUDA和OpenCV库,并设置要链接的库。接下来,指定源文件,设置可执行文件。最后使用cmake编译即可。
阅读全文