Tensorrt: How can I compile and run it without docker?

Created on 15 Aug 2019  路  7Comments  路  Source: NVIDIA/TensorRT

I run it in Ubuntu shell and without dock like this:

louis@Louis:~/Documents/TensorRTCpp/TensorRT/build$ cmake .. -DTRT_LIB_DIR=$TRT_RELEASE/lib -DTRT_BIN_DIR=`pwd`/out

the result is as follows, but errors occurred!

+++ Debug 1
+++ Debug 2
Building for TensorRT version: 5.1.5.0, library version: 5.1.5
+++ Debug 3
CHECK for CUDA
+++ Debug 4
-- Targeting TRT Platform: x86_64
+++ Debug 5
-- CUDA version set to 10.1
-- cuDNN version set to 7.5
+++ Debug 6
+++ Debug not defined NVINTERNAL
-- Protobuf version set to 3.0.0
+++ Debug 7
-- Checking for one of the modules 'zlib'
CMake Error at /usr/local/share/cmake-3.15/Modules/FindPkgConfig.cmake:696 (message):
  None of the required 'zlib' found
Call Stack (most recent call first):
  third_party/zlib.cmake:18 (pkg_search_module)
  CMakeLists.txt:131 (include)

+++ Debug 8
+++ Debug 10
-- Using libprotobuf /home/louis/Documents/TensorRTCpp/TensorRT/build/third_party.protobuf/lib/libprotobuf.a
+++ Debug 11
-- ========================= Importing and creating target nvinfer ==========================
-- Looking for library nvinfer
-- Library that was found /home/louis/Documents/TensorRTCpp/TensorRT/TensorRT-5.1.5.0/lib/libnvinfer.so
-- ==========================================================================================
 TRT_LIB_DIR:/home/louis/Documents/TensorRTCpp/TensorRT/TensorRT-5.1.5.0/lib
-- ========================= Importing and creating target nvuffparser ==========================
-- Looking for library nvparsers
-- Library that was found /home/louis/Documents/TensorRTCpp/TensorRT/TensorRT-5.1.5.0/lib/libnvparsers.so
-- ==========================================================================================
+++ Debug 12
+++ Debug 13
-- Protobuf proto/trtcaffe.proto -> proto/trtcaffe.pb.cc proto/trtcaffe.pb.h
-- /home/louis/Documents/TensorRTCpp/TensorRT/build/parsers/caffe
-- 
-- ******** Summary ********
--   CMake version         : 3.15.2
--   CMake command         : /usr/local/bin/cmake
--   System                : Linux
--   C++ compiler          : /usr/bin/g++
--   C++ compiler version  : 7.4.0
--   CXX flags             : -Wno-deprecated-declarations  -DBUILD_SYSTEM=cmake_oss -Wall -Wnon-virtual-dtor
--   Build type            : Release
--   Compile definitions   : _PROTOBUF_INSTALL_DIR=/home/louis/Documents/TensorRTCpp/TensorRT/build/third_party.protobuf;ONNX_NAMESPACE=onnx2trt_onnx
--   CMAKE_PREFIX_PATH     : 
--   CMAKE_INSTALL_PREFIX  : /lib/..
--   CMAKE_MODULE_PATH     : 
-- 
--   ONNX version          : 1.3.0
--   ONNX NAMESPACE        : onnx2trt_onnx
--   ONNX_BUILD_TESTS      : OFF
--   ONNX_BUILD_BENCHMARKS : OFF
--   ONNX_USE_LITE_PROTO   : OFF
--   ONNXIFI_DUMMY_BACKEND : OFF
-- 
--   Protobuf compiler     : 
--   Protobuf includes     : 
--   Protobuf libraries    : 
--   BUILD_ONNX_PYTHON     : OFF
-- GPU_ARCH is not defined. Generating CUDA code for default SMs.
-- Found TensorRT headers at /home/louis/Documents/TensorRTCpp/TensorRT/include
-- Find TensorRT libs at /home/louis/Documents/TensorRTCpp/TensorRT/TensorRT-5.1.5.0/lib/libnvinfer.so;/home/louis/Documents/TensorRTCpp/TensorRT/TensorRT-5.1.5.0/lib/libnvinfer_plugin.so
+++BUILD_PARSERS
NVINTERNAL_SUFFIX: 
SAMPLE_NAME_FIXED: sample_mnist_api
-- Adding new sample: sample_mnist_api
--     - Parsers Used: caffe
--     - InferPlugin Used: OFF
--     - Licensing: opensource
SAMPLE_NAME_FIXED: sample_ssd
-- Adding new sample: sample_ssd
--     - Parsers Used: caffe
--     - InferPlugin Used: ON
--     - Licensing: opensource
SAMPLE_NAME_FIXED: trtexec
-- Adding new sample: trtexec
--     - Parsers Used: caffe;uff;onnx
--     - InferPlugin Used: ON
--     - Licensing: opensource
-- Configuring incomplete, errors occurred!
See also "/home/louis/Documents/TensorRTCpp/TensorRT/build/CMakeFiles/CMakeOutput.log".
See also "/home/louis/Documents/TensorRTCpp/TensorRT/build/CMakeFiles/CMakeError.log".
OSS Build 5.x invalid

Most helpful comment

Do you have zlib installed? Did you initialize the submodules git submodule update --init --recursive?

All 7 comments

Performing C++ SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/louis/Documents/TensorRTCpp/TensorRT/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_8857c/fast && /usr/bin/make -f CMakeFiles/cmTC_8857c.dir/build.make CMakeFiles/cmTC_8857c.dir/build
make[1]: Entering directory '/home/louis/Documents/TensorRTCpp/TensorRT/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_8857c.dir/src.cxx.o
/usr/bin/g++    -Wno-deprecated-declarations  -DBUILD_SYSTEM=cmake_oss -DCMAKE_HAVE_LIBC_PTHREAD   -std=c++11 -o CMakeFiles/cmTC_8857c.dir/src.cxx.o -c /home/louis/Documents/TensorRTCpp/TensorRT/build/CMakeFiles/CMakeTmp/src.cxx
Linking CXX executable cmTC_8857c
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8857c.dir/link.txt --verbose=1
/usr/bin/g++  -Wno-deprecated-declarations  -DBUILD_SYSTEM=cmake_oss -DCMAKE_HAVE_LIBC_PTHREAD    CMakeFiles/cmTC_8857c.dir/src.cxx.o  -o cmTC_8857c 
CMakeFiles/cmTC_8857c.dir/src.cxx.o: In function `main':
src.cxx:(.text+0x3e): undefined reference to `pthread_create'
src.cxx:(.text+0x4a): undefined reference to `pthread_detach'
src.cxx:(.text+0x5b): undefined reference to `pthread_join'
src.cxx:(.text+0x6f): undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_8857c.dir/build.make:86: recipe for target 'cmTC_8857c' failed
make[1]: *** [cmTC_8857c] Error 1
make[1]: Leaving directory '/home/louis/Documents/TensorRTCpp/TensorRT/build/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_8857c/fast' failed
make: *** [cmTC_8857c/fast] Error 2

Source file was:

#include <pthread.h>

void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:

Change Dir: /home/louis/Documents/TensorRTCpp/TensorRT/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_902d0/fast && /usr/bin/make -f CMakeFiles/cmTC_902d0.dir/build.make CMakeFiles/cmTC_902d0.dir/build
make[1]: Entering directory '/home/louis/Documents/TensorRTCpp/TensorRT/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_902d0.dir/CheckFunctionExists.cxx.o
/usr/bin/g++    -Wno-deprecated-declarations  -DBUILD_SYSTEM=cmake_oss -DCHECK_FUNCTION_EXISTS=pthread_create   -std=c++11 -o CMakeFiles/cmTC_902d0.dir/CheckFunctionExists.cxx.o -c /home/louis/Documents/TensorRTCpp/TensorRT/build/CMakeFiles/CheckLibraryExists/CheckFunctionExists.cxx
Linking CXX executable cmTC_902d0
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_902d0.dir/link.txt --verbose=1
/usr/bin/g++  -Wno-deprecated-declarations  -DBUILD_SYSTEM=cmake_oss -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTC_902d0.dir/CheckFunctionExists.cxx.o  -o cmTC_902d0 -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_902d0.dir/build.make:86: recipe for target 'cmTC_902d0' failed
make[1]: *** [cmTC_902d0] Error 1
make[1]: Leaving directory '/home/louis/Documents/TensorRTCpp/TensorRT/build/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_902d0/fast' failed
make: *** [cmTC_902d0/fast] Error 2

Do you have zlib installed? Did you initialize the submodules git submodule update --init --recursive?

@dflamand , git submodule update --init --recursive worked for me,
Then, I cmake .. and make -j

After this the README file says, it will generate sample_bert file, however, there were other samples such as sample_char_rnn sample_int8 sample_mnist sample_onnx_mnist sample_uff_mnist sample_fasterRCNN sample_int8_api sample_mnist_api sample_plugin sample_uff_ssd sample_googlenet sample_mlp sample_movielens sample_ssd

but no sample_bert.

Why used -DBUILD_SYSTEM=cmake_oss? No any code use this definition.

I got the same error message when I give TRT_RELEASE the empty directory.
There is a '-DTRT_LIB_DIR=$TRT_RELEASE' among the cmake options.
make sure that you gave the correct directory to that directory.

I downloaded the TensorRT binary and extracted the file.
and set ENV like this '$ export TRT_RELEASE=/mydir/TensorRT-6.0.1.5'
And I got it compiled. Strange!

look at: https://github.com/NVIDIA/TensorRT#download-the-tensorrt-binary-release

@andrew-yang0722 , I was able to solve with @dflamand comment.

The original issue was due to missing zlib package. This is in the prerequisites section of the README: https://github.com/NVIDIA/TensorRT#prerequisites under System Packages

@andrew-yang0722 's issue is because the full TensorRT release is required in order to build the open source components in this repo, this is also mentioned in the README prerequisites section.

Glad you all were able to solve it and help each other! :slightly_smiling_face:

Was this page helpful?
0 / 5 - 0 ratings