赞
踩
目录
系统环境: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 显卡:RTX 3090
在终端运行: lsb_release -a
在终端运行: lsb_release -a
在终端运行: dpkg -L libcudnn8
在终端运行: watch -n 1 nvidia-smi
在终端运行: pkg-config --modversion opencv
2.1 opencv安装
- 可参考网:Home - OpenCV
- ippicv包:https://github.com/opencv/opencv_3rdparty/tree/ippicv/master_20191018/ippicv
- 编译命令:cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_BUILD_TYPE=Release -D BUILD_TIFF=ON
注:在conda环境中,由于安装pytorch,会自动安装“libtiff”,卸载后导致pytorch不能用,然后导致opencv在编译过程中会报错,具体如下:
/usr/local/lib/libopencv_imgcodecs.so.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.0解决方法:
- opencv源码安装编译时候,保证conda环境没有libtiff包名
- 在cmake 编译过程中开启 BUILD_TIFF
参考链接:
- LIBTIFF_4.0 link errors - OpenCV Q&A Forum
- https://stackoverflow.com/questions/23934386/using-opencv-with-libtiff
- OpenCV LIBTIFF_4.0 link errors - 普兒 - 博客园
- Linux(Ubuntu 18.04)中安装OpenCV + OpenCV_Contrib - 花落未殇 - 博客园
- https://blog.51cto.com/u_14587161/3000682
- https://blog.csdn.net/jiaken2660/article/details/117036606
2.2 TensorRT安装
- 可参考网:https://developer.nvidia.com/zh-cn/tensorrt,有tar包和deb两种安装方,本文选择tar包进行解压安装。
- 根据tar包解压安装:tar -xvf TensorRT-7.2.3.4.Ubuntu-18.04.x86_64-gnu.cuda-11.1.cudnn8.1.tar.gz
- 安装命令:分别进入python、uff和graphsurgeon根据python环境,进行pip安装相应的包
- vi ~/.bashrc 添加 export LD_LIBRARY_PATH=/usr/local/TensorRT-7.2.3.4/lib:/usr/local/cuda/bin:$LD_LIBRARY_PATH
export INCLUDE_PATH=/usr/local/TensorRT-7.2.3.4/include:/usr/local/cuda/lib64:$INCLUDE_PATH- source ~/.bashrc
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。