编译遇到的问题

问题1:

[ 20%] Building NVCC (Device) object CMakeFiles/myplugins.dir/myplugins_generated_yololayer.cu.o
In file included from /home/lh/文档/4.YOLOv5_v5.0_TRT/tensorrtx/yolov5/yololayer.cu:4:0:
/home/lh/文档/4.YOLOv5_v5.0_TRT/tensorrtx/yolov5/yololayer.h:6:10: fatal error: NvInfer.h: 没有那个文件或目录
 #include 
          ^~~~~~~~~~~
compilation terminated.
CMake Error at myplugins_generated_yololayer.cu.o.Debug.cmake:219 (message):
  Error generating
  /home/lh/文档/4.YOLOv5_v5.0_TRT/tensorrtx/yolov5/build/CMakeFiles/myplugins.dir//./myplugins_generated_yololayer.cu.o


CMakeFiles/myplugins.dir/build.make:63: recipe for target 'CMakeFiles/myplugins.dir/myplugins_generated_yololayer.cu.o' failed
make[2]: *** [CMakeFiles/myplugins.dir/myplugins_generated_yololayer.cu.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/myplugins.dir/all' failed
make[1]: *** [CMakeFiles/myplugins.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

解决办法:

         找不到NvInfer.h,这个文件在TensorRT/include中,在编译的CMakeLists.txt文件中加入它的路径,即可解决!

include_directories(/home/lh/TensorRT-7.0.0.11/include/)

重新编译

make clean
make

问题2:

[ 40%] Linking CXX shared library libmyplugins.so
/usr/bin/ld: 找不到 -lnvinfer
collect2: error: ld returned 1 exit status
CMakeFiles/myplugins.dir/build.make:78: recipe for target 'libmyplugins.so' failed
make[2]: *** [libmyplugins.so] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/myplugins.dir/all' failed
make[1]: *** [CMakeFiles/myplugins.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

主要问题就是/usr/bin/ld: 找不到 -lnvinfer, 这是表示找不到库文件nvinfer.so

解决办法:

① 找打它的位置

locate libnvinfer.so

② 软连接到usr/ lib/中

sudo ln -s /home/lh/TensorRT-7.0.0.11/targets/x86_64-linux-gnu/lib/libnvinfer.so /usr/lib/libnvinfer.so

然后将编译的build中的内容删掉后,重新编译

sudo rm -rf *
cmake ..
make

编译遇到的问题_第1张图片

问题3:

运行 sudo ./yolov5 -s yolov5s.wts yolov5s.engine s 遇到的问题

./yolov5: error while loading shared libraries: libmyelin.so.1: cannot open shared object file: No such file or directory
./yolov5: error while loading shared libraries: libnvinfer.so.7: cannot open shared object file: No such file or directory

解决办法:

万能解决法,同问题2 (我感觉是,目前遇到的这类问题都可以用这个方法解决!)

sudo ln -s /home/lh/TensorRT-7.0.0.11/targets/x86_64-linux-gnu/lib/libnvinfer.so.7 /usr/lib/libnvinfer.so.7

sudo ln -s /home/lh/TensorRT-7.0.0.11/targets/x86_64-linux-gnu/lib/libmyelin.so.1 /usr/lib/libmyelin.so.1

编译遇到的问题_第2张图片

 

你可能感兴趣的:(python,深度学习,linux,ubuntu)