Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fonylew/3b45f2136c0c720a5e75bac45279b4fe to your computer and use it in GitHub Desktop.
Save fonylew/3b45f2136c0c720a5e75bac45279b4fe to your computer and use it in GitHub Desktop.
OpenCV CMake for Cuda
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D WITH_CUDA=ON \
-D ENABLE_FAST_MATH=1 \
-D WITH_FFMPEG=ON \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D WITH_MKL=ON \
-D MKL_USE_MULTITHREAD=ON \
-D MKL_WITH_TBB=ON \
-D WITH_TBB=ON \
-D BUILD_opencv_python3=yes \
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D PYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON_INCLUDE_DIR2=$(python3 -c "from os.path import dirname; from distutils.sysconfig import get_config_h_filename; print(dirname(get_config_h_filename()))") \
-D PYTHON_LIBRARY=$(python3 -c "from distutils.sysconfig import get_config_var;from os.path import dirname,join ; print(join(dirname(get_config_var('LIBPC')),get_config_var('LDLIBRARY')))") \
-D PYTHON3_NUMPY_INCLUDE_DIRS=$(python3 -c "import numpy; print(numpy.get_include())") \
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D ENABLE_AVX=ON \
-D WITH_OPENGL=ON \
-D WITH_OPENCL=ON \
-D WITH_IPP=ON \
-D WITH_EIGEN=ON \
-D WITH_NVCUVID=1 \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D CUDNN_LIBRARY=/usr/local/cuda/lib64 ..
@fonylew
Copy link
Author

fonylew commented Sep 23, 2020

Add

-D WITH_MKL=ON \
-D MKL_USE_MULTITHREAD=ON \
-D MKL_WITH_TBB=ON \
-D WITH_TBB=ON \

@fonylew
Copy link
Author

fonylew commented Sep 23, 2020

@fonylew
Copy link
Author

fonylew commented Sep 23, 2020

sudo apt install libv4l-dev v4l-utils

@fonylew
Copy link
Author

fonylew commented Sep 23, 2020

@fonylew
Copy link
Author

fonylew commented Sep 23, 2020

@fonylew
Copy link
Author

fonylew commented Sep 24, 2020

sudo apt install gcc gcc-8

# cmake .. (with options)

sudo mv /usr/bin/gcc /usr/bin/gcc.bk
sudo ln -s /usr/bin/gcc-8 /usr/bin/gcc

# make

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment