0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WindowsのOpenCVでCUDAを使うためにビルドするメモ

Last updated at Posted at 2021-06-20

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/

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?