CMAKE can't find TensorRT

I have untar’d TensorRT to /usr/local/cuda/TensorRT and added the following ENV variables in .bashrc

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/TensorRT:/usr/local/cuda/TensorRT/targets/x86_64-linux-gnu/lib/

export CUDNN_INSTALL_DIR=/usr/local/cuda/lib64

Having done so, the sample MNIST builds and runs successfully,

When I try to build another package (pointpillars, autoware) it fails.

I tried creating a dummy cmake project with some extracts from pointpillars to try to understand which part fails:

find_library(NVINFER NAMES
find_library(NVPARSERS NAMES nvparsers)
find_library(NVONNXPARSERS NAMES nvonnxparser)
   message("TensorRT is available!")
   message("NVINFER: ${NVINFER}")
   message("NVPARSERS: ${NVPARSERS}")
   set(TRT_AVAIL ON)
  message("TensorRT is NOT Available")

This fails to find - which I know is located in /usr/local/cuda/TensorRT/targets/x86_64-linux-gnu/lib/

So my question is: What is the best way to let CMake know how to find TensorRT ?

I’m on Ubuntu server 16.04, CUDA 10.0 due to other advice I have received in this forum from Nvidia, I have installed cuda from the .run and CuDNN from the .tgz

Hello! I meet the same problem with you. Could you please tell me that how you access this issue finally? Thanks in advance for the help!

I solved it by adding set(CMAKE_PREFIX_PATH "/myhome/TensorRT-") to CMakeLists.txt

1 Like


You can use below example to find tensorrt using cmake.

list(APPEND PLUGINS "nvinfer")
list(APPEND PLUGINS "nvonnxparser")
list(APPEND PLUGINS "nvparsers")

foreach(libName ${PLUGINS})
    find_library(${libName}_lib NAMES ${libName} "/usr" PATH_SUFFIXES lib)
    list(APPEND PLUGIN_LIBS "${${libName}_lib}")

Hope it will help you


I added also this line and it helped me with the migration from trt5 to trt7
list(APPEND PLUGINS "nvinfer_plugin")

Thank you so much!