https://twitter.com/yasnis/status/1406499958413426689
この辺に関連して苦戦した記録。あとでちゃんと書く(かも)。
- RTX 3070
- Game Ready Driver 461.40
- CUDA ToolKit 11.2
- cuDNN
- OpenCV 4.5.1
- opencv_contrib
- Ninja
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat"
set "generator=Ninja"
set "openCvSource=C:/tools/opencv"
set "openCVExtraModules=C:/tools/opencv_contrib-4.5.1/modules"
set "openCvBuild=%openCvSource%/build"
set "buildType=Release"
set "pathToPythonDir=C:/Program Files/Python37"
cmake -B"%openCvBuild%/" -H"%openCvSource%/" -G"%generator%" ^
-DCMAKE_BUILD_TYPE=%buildType% ^
-DOPENCV_EXTRA_MODULES_PATH="%openCVExtraModules%/" ^
-DINSTALL_TESTS=ON -DINSTALL_C_EXAMPLES=ON -DBUILD_EXAMPLES=ON ^
-DBUILD_opencv_world=ON ^
-DWITH_CUDA=ON ^
-DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2" ^
-DCUDA_FAST_MATH=ON ^
-DWITH_CUBLAS=ON ^
-DCUDA_ARCH_PTX=8.6 ^
-DCUDA_ARCH_BIN=8.6 ^
-DWITH_NVCUVID=ON ^
-DWITH_OPENGL=ON ^
-DWITH_MFX=ON ^
-DBUILD_opencv_python3=ON ^
-DPYTHON3_INCLUDE_DIR="%pathToPythonDir%/include" ^
-DPYTHON3_LIBRARY="%pathToPythonDir%/libs/python37.lib" ^
-DPYTHON3_EXECUTABLE="%pathToPythonDir%/python.exe" ^
-DPYTHON3_NUMPY_INCLUDE_DIRS="%pathToPythonDir%/lib/site-packages/numpy/core/include" ^
-DPYTHON3_PACKAGES_PATH="%pathToPythonDir%/Lib/site-packages/" ^
-DOPENCV_SKIP_PYTHON_LOADER=ON
...
# OpenCVのビルド
cmake --build .
# OpenCVのインストール
cmake --build . --target install
この辺が参考になった
https://jamesbowley.co.uk/accelerate-opencv-4-5-0-on-windows-build-with-cuda-and-python-bindings/