Installing OpenCV w/ GPU in Windows: Difference between revisions
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
# Install Cuda from [https://developer.nvidia.com/cuda-downloads here] | # Install Cuda from [https://developer.nvidia.com/cuda-downloads here] | ||
# Install Visual Studio from [https://visualstudio.microsoft.com/downloads/ here] | # Install Visual Studio from [https://visualstudio.microsoft.com/downloads/ here] | ||
# Install cmake | # Install cmake from [https://cmake.org/download/ here] | ||
# Download OpenCV from [https://opencv.org/releases/ here] and extract to dev folder as opencv | # Download OpenCV from [https://opencv.org/releases/ here] and extract to dev folder as opencv | ||
# Download OpenCV Contrib from [https://github.com/opencv/opencv_contrib/releases here] (note that versions should match) and extract to dev folder as opencv-contrib | # Download OpenCV Contrib from [https://github.com/opencv/opencv_contrib/releases here] (note that versions should match) and extract to dev folder as opencv-contrib |
Revision as of 13:17, 21 September 2021
The OpenCV installing via pip does not include GPU support and will significantly reduce performance. This decreases FPS from around 30FPS to under 2FPS in darknet. To enable the GPU, you must compile opencv with CUDA support.
- Create a DEV folder at c:\dev\
- Install Cuda from here
- Install Visual Studio from here
- Install cmake from here
- Download OpenCV from here and extract to dev folder as opencv
- Download OpenCV Contrib from here (note that versions should match) and extract to dev folder as opencv-contrib
- Run cmake-gui and point the sources folder to c:\dev\opencv\sources
- Set the build directory to c:\dev\opencv\build
- Adjust the following flags:
- CMAKE_BUILD_TYPE=RELEASE \
- CMAKE_INSTALL_PREFIX=/usr/local \
- WITH_TBB=ON \
- ENABLE_FAST_MATH=1 \
- CUDA_FAST_MATH=1 \
- WITH_CUBLAS=1 \
- WITH_CUDA=ON \
- BUILD_opencv_cudacodec=OFF \
- WITH_CUDNN=ON \
- OPENCV_DNN_CUDA=ON \
- CUDA_ARCH_BIN=7.5 \
- WITH_V4L=ON \
- WITH_QT=OFF \
- WITH_OPENGL=ON \
- WITH_GSTREAMER=ON \
- OPENCV_GENERATE_PKGCONFIG=ON \
- OPENCV_PC_FILE_NAME=opencv.pc \
- OPENCV_ENABLE_NONFREE=ON \
- OPENCV_PYTHON3_INSTALL_PATH=~/.virtualenvs/cv/lib/python3.8/site-packages \
- PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python \
- OPENCV_EXTRA_MODULES_PATH=~/Downloads/opencv_contrib-4.5.2/modules \
- INSTALL_PYTHON_EXAMPLES=OFF \
- INSTALL_C_EXAMPLES=OFF \
- BUILD_EXAMPLES=OFF
- Click Configure and then Generate. When prompted, select the correct version of Visual Studio
- From the build directory, open the INSTALL.vcxproj project in Visual Studio