0
0

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.

Build OpenCV 4.5.3 for CUDA 11.4

Last updated at Posted at 2021-09-10

業務上の勘違いでビルドに入ったものの結局不要
捨ててしまうのももったいないのでメモとして
2016年07月の拙稿 Build OpenCV 2.4.13 with CUDA 7.5/7.0 and VC12 (Visual Studio 2013)
https://qiita.com/Ohgochi/items/ca3564f5bd69c2c9891d
の続編かな?

作業環境

ハードウェア

三年前のIntel過渡期ノートPC

  • Intel i7-8750H (6 core, 12 thread), 16GB
  • NVIDIA GTX1060 with Max-Q

ソフトウェア

特に組み合わせは考えず、2021年晩夏時点での最新版を並べた
今回は VTK、Lapack、Eigen は端折った

  • Windows 10 Pro 21H1
  • Visual Studio Community 2019 16.11.2
  • CMake 3.21.2
  • Python 3.9.7
  • NumPy 1.21.2
  • OpenCV + Contrib 4.5.3
  • CUDA 11.4.120
  • CuDNN 8.2.2

作業手順

OpenCVDetectPython.cmake ファイルで Python 2/3 系の選択が2系優先になっている分岐三か所を3系優先に書き換えた
当方環境で2系が Google Android Studio 関連だけだったため
CMakeでの生成結果は下記のようになった

-- 
-- General configuration for OpenCV 4.5.3-dev =====================================
--   Version control:               unknown
-- 
--   Extra modules:
--     Location (extra):            D:/DevCV4/opencv_contrib-master/modules
--     Version control (extra):     unknown
-- 
--   Platform:
--     Timestamp:                   2021-09-10T14:06:50Z
--     Host:                        Windows 10.0.19043 AMD64
--     CMake:                       3.21.2
--     CMake generator:             Visual Studio 16 2019
--     CMake build tool:            .. MSBuild/Current/Bin/MSBuild.exe
--     MSVC:                        1929
--     Configuration:               Debug Release
-- 
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (17 files):         + SSSE3 SSE4_1
--       SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (32 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (8 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 
--                                    AVX_512F AVX512_COMMON AVX512_SKX
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ standard:                11
--     C++ Compiler:                .. Hostx64/x64/cl.exe  (ver 19.29.30133.0)
--     C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE 
--                                  /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS 
--                                  /Gy /bigobj /Oi /fp:fast /EHa 
--                                  /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 
--                                  /MP  /MD /O2 /Ob2 /DNDEBUG 
--     C++ flags (Debug):           (略)
--     C Compiler:                  .. MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
--     C flags (Release):           (略)
--     C flags (Debug):             (略)
--     Linker flags (Release):      /machine:x64  /INCREMENTAL:NO 
--     Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL 
--     ccache:                      NO
--     Precompiled headers:         YES
--     Extra dependencies:          cudart_static.lib nppc.lib nppial.lib nppicc.lib nppidei.lib 
--                                  nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib 
--                                  npps.lib cublas.lib cudnn.lib cufft.lib 
--                                  -LIBPATH:D:/DevCUDA/CUDA11.4/lib/x64
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 aruco barcode bgsegm bioinspired calib3d ccalib core cudaarithm 
--                                  cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc 
--                                  cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev 
--                                  datasets dnn dnn_objdetect dnn_superres dpm face features2d flann 
--                                  fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform
--                                  line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot 
--                                  quality rapid reg rgbd saliency shape stereo stitching structured_light 
--                                  superres surface_matching text tracking ts video videoio videostab 
--                                  wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 alphamat cvv freetype hdf java julia matlab ovis python2 python3 sfm viz
--     Applications:                tests perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   Windows RT support:            NO
-- 
--   GUI:                           WIN32UI
--     Win32 UI:                    YES
-- 
--   Media I/O: 
--     ZLib:                        build (ver 1.2.11)
--     JPEG:                        build-libjpeg-turbo (ver 2.1.0-62)
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         build (ver 1.6.37)
--     TIFF:                        build (ver 42 - 4.2.0)
--     JPEG 2000:                   build (ver 2.4.0)
--     OpenEXR:                     build (ver 2.3.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      YES (prebuilt binaries)
--       avcodec:                   YES (58.134.100)
--       avformat:                  YES (58.76.100)
--       avutil:                    YES (56.70.100)
--       swscale:                   YES (5.9.100)
--       avresample:                YES (4.0.0)
--     GStreamer:                   NO
--     DirectShow:                  YES
--     Media Foundation:            YES
--       DXVA:                      YES
-- 
--   Parallel framework:            Concurrency
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Intel IPP:                   2020.0.0 Gold [2020.0.0]
--            at:                   D:/DevCV4/opencv-cuda/3rdparty/ippicv/ippicv_win/icv
--     Intel IPP IW:                sources (2020.0.0)
--               at:                D:/DevCV4/opencv-cuda/3rdparty/ippicv/ippicv_win/iw
--     Lapack:                      NO
--     Eigen:                       NO
--     Custom HAL:                  NO
--     Protobuf:                    build (3.5.1)
-- 
--   NVIDIA CUDA:                   YES (ver 11.4, CUFFT CUBLAS)
--     NVIDIA GPU arch:             61
--     NVIDIA PTX archs:
-- 
--   cuDNN:                         YES (ver 8.2.2)
-- 
--   OpenCL:                        YES (NVD3D11)
--     Include path:                D:/DevCV4/opencv-master/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python (for build):            D:/DevPython/Python39/python.exe
-- 
--   Java:                          
--     ant:                         NO
--     JNI:                         (略)
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Install to:                    D:/DevCV4/opencv-cuda/install
-- -----------------------------------------------------------------
-- 

参考文献

ほぼほぼ、下記稿に沿って進めることができた

追加情報 Samples プログラム群のBuildについて

(cuda_11.4.2_471.41_win10 インストールの VS2019 ソリューションで確認)

VC inc, CUDA inc, LINK lib の各パスのディレクトリ階層が間違っています
"../../xx" を "../../../xx" と一階層増やす必要があります
(2021年9月17日追記)

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?