Last active
September 9, 2021 02:54
-
-
Save WesleyCh3n/1f0bf240223507bea244a4be369e0394 to your computer and use it in GitHub Desktop.
OpenCV Installation with CUDA in Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get upgrade | |
# Installation prerequisite libraries | |
## Compile tools | |
sudo apt-get install build-essential cmake pkg-config unzip git checkinstall | |
## Image I/O | |
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev | |
## Video/Audio | |
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libxvidcore-dev libx264-dev | |
## Camera API | |
sudo apt-get install libv4l-dev v4l-utils | |
## Optimization | |
sudo apt-get install libatlas-base-dev | |
# Compile OpenCV 4.5.0 from source | |
## Get source code | |
cd ~/Downloads/ | |
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.5.0.zip | |
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.5.0.zip | |
unzip opencv.zip | |
unzip opencv_contrib.zip | |
mv opencv-4.5.0 opencv | |
mv opencv_contrib-4.5.0 opencv_contrib | |
mkdir -p opencv/build/ && cd opencv/build | |
## cmake with your configuration | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D INSTALL_PYTHON_EXAMPLES=OFF \ | |
-D INSTALL_C_EXAMPLES=OFF \ | |
-D BUILD_opencv_python3=ON \ | |
-D WITH_CUDA=ON \ | |
-D WITH_CUDNN=ON \ | |
-D OPENCV_DNN_CUDA=ON \ | |
-D ENABLE_FAST_MATH=1 \ | |
-D CUDA_FAST_MATH=1 \ | |
-D CUDA_ARCH_BIN=7.0 \ | |
-D WITH_CUBLAS=1 \ | |
-D OPENCV_ENABLE_NONFREE=ON \ | |
-D OPENCV_GENERATE_PKGCONFIG=ON \ | |
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \ | |
-D BUILD_EXAMPLES=OFF .. | |
## Start compiling | |
## (8 corresponding to number of cpu thread you want to use) | |
make -j8 | |
## Install | |
sudo make install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment