directory

I. Environment version

1.1 an overview of the

Ubuntu 1.2 version

1.3 Python, PyTorch, and Tensorrt

Version 1.4 cudnn

1.5 Driver Version

Opencv version 1.6

TensorRT and OpencV environment installation

Opencv installed 2.1

2.2 TensorRT installation

Yolov5 to tensorrt

3.1 Downloading the YoloV5 Project

3.2 Downloading the Tensorrtx project

3.3 Preparing for Compilation

3.4 Obtaining the WTS model

3.5 Compiling Commands

3.6 test


I. Environment version

1.1 an overview of the

System environment: Ubuntu18.04 Python =3.8.5 Torch =1.10.0 TensorRT=7.2.3.4 OpencV =4.5.1

Cuda =11.2 CUDNN =8.2.2 Driver Version: 460.32.03 Graphics card: RTX 3090

Ubuntu 1.2 version

Run on a terminal: lsb_release -a

1.3 Python, PyTorch, and Tensorrt

Run on a terminal: lsb_release -a

Version 1.4 cudnn

Run on terminal: DPKG -l libcudnn8

1.5 Driver Version

Run in terminal: watch -n 1 Nvidia-SMI

Opencv version 1.6

Running on the terminal: pkg-config –modversion opencV

TensorRT and OpencV environment installation

Opencv installed 2.1

  1. Please refer to home-OpencV
  2. Ippicv package: github.com/opencv/open…
  3. Cmake -d CMAKE_INSTALL_PREFIX=/usr/local -d CMAKE_BUILD_TYPE=Release -d BUILD_TIFF=ON

If pyTorch is installed in conda, libtiff will be installed automatically. If PyTorch is installed in Conda, libtiff will be installed automatically.

/ usr/local/lib/libopencv_imgcodecs. So the 4.5.1: Undefined reference to 'TIFFReadRGBAStrip@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFReadDirectory@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFWriteEncodedStrip@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFIsTiled@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFWriteScanline@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFGetField@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFScanlineSize@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFWriteDirectory@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFReadEncodedTile@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFReadRGBATile@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFClose@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFClientOpen@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFRGBAImageOK@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFOpen@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFReadEncodedStrip@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFSetField@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to 'TIFFSetWarningHandler@LIBTIFF_4.0' /usr/local/lib/libopencv_imgcodecs.so.4.5.1: Undefined reference to ` TIFFSetErrorHandler@LIBTIFF_4.0Copy the code

Solutions:

  1. When compiling opencV source code, ensure that conda environment does not have libtiff package name
  2. BUILD_TIFF is enabled during cmake compilation

Reference links:

  1. Libtiff_4. 0 link Errors – OpenCV Q&A Forum
  2. Stackoverflow.com/questions/2…
  3. OpenCV libtiff_4. 0 link errors
  4. Install OpenCV + OpenCV_Contrib in Ubuntu 18.04
  5. Blog.51cto.com/u_14587161/…

2.2 TensorRT installation

  1. Can refer to the network: developer.nvidia.com/zh-cn/tenso… , there are tar package and DEB two installation parties, this paper chooses tar package for decompression installation.
  2. Decompress the tar package and install it: tar -xvf tensorrt-7.2.3.4.ubuntu-18.04.x86_64 -gnu. Cuda-11.1.cudnn8.1.tar. gz
  3. Install the packages in python, uFF, and GraphSurgeon respectively
  4. Vi ~ /. Bashrc add export LD_LIBRARY_PATH = / usr/local/TensorRT – 7.2.3.4 / lib: / usr/local/cuda/bin: LDLIBRARYPATH exportINCLUDEPATH = / usr/local/TensorRT – 7.2.3.4 / include: / usr/local/cuda/lib64: LD_LIBRARY_PATH \ export INCLUDE_PATH = / usr/local/TensorRT – 7.2.3.4 / include: / usr/local/cuda/lib64: LDLIBRARYPATH ExportINCLUDEPATH = / usr/local/TensorRT – 7.2.3.4 / include: / usr/local/cuda/lib64: INCLUDE_PATH
  5. source ~/.bashrc

Yolov5 to tensorrt

3.1 Downloading the YoloV5 Project

Github.com/ultralytics…

3.2 Downloading the Tensorrtx project

Github.com/wang-xinyu/…

3.3 Preparing for Compilation

In the Tensorrx project, go to the yolov5 directory and modify cmakelists.txt:

Modify your tcUDA and TensorRT paths:  # cuda include_directories(/usr/local/cuda/include) link_directories(/usr/local/cuda/lib64) # tensorrt Include_directories (/ usr/local/TensorRT - 7.2.3.4 / include) link_directories (/ usr/local/TensorRT - 7.2.3.4 / lib)Copy the code

3.4 Obtaining the WTS model

Run on a terminal: ****python gen_wts.py

3.5 Compiling Commands

Run on terminal: mkdir build && CD build:

Run on terminal: cmake..

Run on terminal: make-j128

Run on terminal:./ yolov5-s // serialize Model to Plan file i.e. ‘yolov5s.engine’ serialization model

3.6 test

Running on terminal:./ yolov5-d.. /data/images // deserialize plan file and run inference, the images in samples will be processed. The test case

Or run CUDA_VISIBLE_DEVICES=6 Python yolov5_trt.py on a terminal