Cuda10+cudnn7.3+Ubuntu16.0下安装源码opencv3.4.0

安装依赖
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran pylint
下载文件版本要对应
wget https://github.com/opencv/opencv/archive/3.4.0.zip -O opencv-3.4.0.zip
wget https://github.com/opencv/opencv_contrib/archive/3.4.0.zip -O opencv_contrib-3.4.0.zip
unzip opencv-3.4.0.zip
unzip opencv_contrib-3.4.0.zip

cd opencv-3.4.0 && mkdir build && cd build

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DOPENCV_EXTRA_MODULES_PATH=…/…/opencv_contrib-3.4.0/modules -DOPENCV_ENABLE_NONFREE=True …
这里遇到错误
fatal error: opencv2/xfeatures2d/cuda.hpp: No such file or directory
加上cmake -DBUILD_opencv_xfeatures2d=OFF
编译成功
nproc
输出内核个数
24
make -j24
sudo make install
#sudo make -j"$(nproc)" install
查看opencv安装的地方
find /usr/local/lib/ -type f -name “cv2*.so”
find /usr/local/lib/ -type f -name “cv2*.so”
我的显示如上
import cv2
cv2.version
用python查看安装的opencv版本

你可能感兴趣的:(Cuda10+cudnn7.3+Ubuntu16.0下安装源码opencv3.4.0)