Preinstall
Install CUDA
Install cuda by run file
Restart the computer!
Install cuDNN
Step 1. Download cuDNN from Nvidia cuDNN
Step 2. Unzip the package.
tar -xzvf <cudnn-tar-file>.tgz
Step 3. Copy the *.h header files into cuda.
cd ~/Downloads/cuda/include
// Copy into the installation path of cuda
sudo cp *.h /usr/local/cuda-8.0/include/
Step 4. Copy the library files of cuDNN to the cuda directory
cd ~/Downloads/cuda/lib64
sudo cp libcudnn* /usr/local/cuda-8.0/lib64/
Step 5. Set the modify type in the terminal.
sudo chmod a+r /usr/local/cuda-8.0/include/cudnn.h /usr/local/cuda-8.0/lib64/libcudnn*
Install OpenCV
Remove previous installed OpenCV
sudo rm -rf /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*
sudo apt-get purge libopencv-* python-data python-opencv
sudo apt-get –purge remove opencv-doc opencv-data python-opencv
Install
First install it’s dependencies:
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 libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
Then download the latest stable version of OpenCV from Sourceforge.
Now create a temporary directory ~/opencv and extract the zip file you downloaded into it:
mkdir ~/opencv; cd ~/opencv
unzip <open-cv-file>.zip -d .
Finally, we’ll make the file in another directory we create called release:
cd opencv-<version>
mkdir release; cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_IPP=OFF -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install
Test
Compile samples:
$ cd ~/opencv-3.1.0/samples
$ cmake .
$ sudo make -j $(nproc)
Run samples:
$ cd ~/opencv-3.1.0/samples/cpp
$ ./cpp-example-facedetect ~/Lenna.png