Skip to content

Instantly share code, notes, and snippets.

@stri8ed
Last active September 11, 2023 14:40
Show Gist options
  • Save stri8ed/38de22fd1bf3ea2cddeb2bd32f2a667e to your computer and use it in GitHub Desktop.
Save stri8ed/38de22fd1bf3ea2cddeb2bd32f2a667e to your computer and use it in GitHub Desktop.
Compile opencv with Cuda on Windows 11 via Cmake CLI
cmake .. -D CMAKE_BUILD_TYPE=RELEASE \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=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.5 \
-D WITH_CUBLAS=1 \
-D BUILD_EXAMPLES=ON \
-D PYTHON_EXECUTABLE=$(which python) \
-D PYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D CMAKE_INSTALL_PREFIX=$(python -c "import sys; print(sys.prefix)") \
-D HAVE_opencv_python3=ON \
-D OPENCV_EXTRA_MODULES_PATH=C:/Users/some_username/Downloads/opencv/opencv_contrib-4.8.0/modules \
-D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_EXAMPLES=OFF \
-D Python3_EXECUTABLE=C:/Python311/python \
-D PYTHON3_PACKAGES_PATH=C:/Python311/Lib/site-packages \
-D PYTHON3_NUMPY_INCLUDE_DIRS=C:/Python311/Lib/site-packages/numpy/core/include \
-D PYTHON_DEFAULT_EXECUTABLE=C:/Python311/python \
-D BUILD_opencv_dnn=ON \
-D BUILD_OPENCV_WORLD=ON
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment