Last active
April 23, 2022 10:26
-
-
Save ultrafunkamsterdam/02a209120b44565ff3a878fb2d8dd662 to your computer and use it in GitHub Desktop.
opencv / cv2 with CUDA and Python (3.10 tested) bindings on windows
This file contains hidden or 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
:::::::::::::::::::::::::::::::::::::::::::::::::::: | |
:: | |
:: this script is adapted do personal preferences / installation paths / folders | |
:: if you want to use it, make sure to modify all variables to reflect your own installation paths | |
:: | |
:: required: | |
:: - Cuda Toolkit | |
:: - Cuda CUDNN (place folders in Cuda Toolkit installation directory by hand, overwrite/merge directories with same name) | |
:: - cmake | |
:: - visual studio (with c++ enabled) | |
:: - python/anaconda/miniconda/pip | |
:: - clone of https://github.com/opencv/opencv | |
:: - clone of https://github.com/opencv/opencv_contrib ( do not clone inside the above folder, clone in seperate folder) | |
:: - probably forgot something | |
:: - recommended to run this script in a VS Developer command prompt | |
:: - Some path's have forward slashes, this is on purpose! | |
set "pyVer=310" | |
set "pathToAnaconda=C:/Program Files/Python310" | |
set "openCvSource=c:\users\leon\DEV\imageml\opencv" | |
set "openCVExtraModules=c:\users\leon\DEV\imageml\opencv-contrib\modules" | |
set "openCvBuild=%openCvSource%\build" | |
set "buildType=Release" | |
cd %openCvSource% | |
mkdir %openCvBuild% >nul | |
cd %openCvBuild% | |
cmake .. -DBUILD_opencv_python3=ON ^ | |
-DPYTHON3_INCLUDE_DIR="%pathToAnaconda%/include" ^ | |
-DPYTHON3_LIBRARY="%pathToAnaconda%/libs/python%pyVer%.lib" ^ | |
-DPYTHON3_EXECUTABLE="%pathToAnaconda%/python.exe" ^ | |
-DPYTHON3_NUMPY_INCLUDE_DIRS="%pathToAnaconda%/lib/site-packages/numpy/core/include" ^ | |
-DPYTHON3_PACKAGES_PATH="%pathToAnaconda%/Lib/site-packages/" ^ | |
-DCUDA_TOOLKIT_ROOT_DIR=c:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6 ^ | |
-DOPENCV_EXTRA_MODULES_PATH=%openCVExtraModules% ^ | |
-DWITH_CUBLAS=ON ^ | |
-DCUDA_ARCH_PTX=8.0 ^ | |
-DWITH_NVCUVID=ON ^ | |
-DWITH_CUDA=ON ^ | |
-DWITH_OPENGL=ON ^ | |
-DBUILD_opencv_world=ON ^ | |
-DCUDA_FAST_MATH=ON ^ | |
-DOPENCV_SKIP_PYTHON_LOADER=ON | |
cmake.exe --build %openCvBuild% --target install --config Release |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment