opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.33k stars 5.74k forks source link

World module with CUDA build error #2057

Open wickeat opened 5 years ago

wickeat commented 5 years ago
System information (version)
Detailed description

I am trying to build OpenCV master (4.1.0-pre) with CUDA and world module. The configuration with CMake is given below.

General configuration for OpenCV 4.1.0-pre

  Version control:               4.0.1-473-g8c25a8eb7

  Extra modules:
    Location (extra):            C:/opencv_contrib/modules
    Version control (extra):     4.0.1-66-gfd2ca919

  Platform:
    Timestamp:                   2019-03-25T06:29:27Z
    Host:                        Windows 10.0.17763 AMD64
    CMake:                       3.14.0
    CMake generator:             Visual Studio 15 2017
    CMake build tool:            C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe
    MSVC:                        1916

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (15 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 (29 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe  (ver 19.16.27027.1)
    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      /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP32   /MD /O2 /Ob2 /DNDEBUG 
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi      /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP32   /MDd /Zi /Ob0 /Od /RTC1 
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi        /MP32    /MD /O2 /Ob2 /DNDEBUG 
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi        /MP32  /MDd /Zi /Ob0 /Od /RTC1 
    Linker flags (Release):      /machine:x64  /INCREMENTAL:NO 
    Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL 
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:          cudart_static.lib nppc.lib nppial.lib nppicc.lib nppicom.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cufft.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/lib/x64
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python_bindings_generator quality reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab world xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    -
    Disabled by dependency:      -
    Unavailable:                 cnn_3dobj cvv freetype hdf java js matlab ovis python2 python3 sfm viz
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         NO

  Windows RT support:            NO

  GUI: 
    Win32 UI:                    YES
    VTK support:                 NO

  Media I/O: 
    ZLib:                        build (ver 1.2.11)
    JPEG:                        build-libjpeg-turbo (ver 2.0.2-62)
    WEBP:                        build (ver encoder: 0x020e)
    PNG:                         build (ver 1.6.36)
    TIFF:                        build (ver 42 - 4.0.10)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:
    DC1394:                      NO
    FFMPEG:                      YES (prebuilt binaries)
      avcodec:                   YES (58.35.100)
      avformat:                  YES (58.20.100)
      avutil:                    YES (56.22.100)
      swscale:                   YES (5.3.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:                   2019.0.0 Gold [2019.0.0]
           at:                   C:/opencvMaster/buildMaster/3rdparty/ippicv/ippicv_win/icv
    Intel IPP IW:                sources (2019.0.0)
              at:                C:/opencvMaster/buildMaster/3rdparty/ippicv/ippicv_win/iw
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  NVIDIA CUDA:                   YES (ver 10.1, CUFFT CUBLAS)
    NVIDIA GPU arch:             60 61
    NVIDIA PTX archs:

  OpenCL:                        YES (no extra features)
    Include path:                C:/opencvMaster/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python (for build):            C:/Python/Python37/python.exe

  Java:                          
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Install to:                    C:/opencvMaster/buildMaster/install
-----------------------------------------------------------------

` However, upon trying to build the project in Visual Studio 2017, I encounter the over 400 errors, all relating to the opencv_perf_gapi or opencv_test_gapi projects.

Is it not possible to build OpenCV with CUDA enabled and have a world module generated in the current version of OpenCV?

alalek commented 5 years ago

I would be helpful to see "raw" error messages (at least other users can find this issue for the similar problems).

Try to build without G-API module: cmake -DBUILD_opencv_gapi=OFF ...

wickeat commented 5 years ago

A few examples of the error messages are as follow:

51>C:\opencvMaster\modules\gapi\perf\internal\gapi_compiler_perf_tests.cpp(26): error C2039: 'split3': is not a member of 'cv::gapi'
51>C:\opencvMaster\modules\gapi\include\opencv2/gapi/gkernel.hpp(296): note: see declaration of 'cv::gapi'
51>C:\opencvMaster\modules\gapi\perf\internal\gapi_compiler_perf_tests.cpp(26): error C3861: 'split3': identifier not found
51>C:\opencvMaster\modules\gapi\perf\internal\gapi_compiler_perf_tests.cpp(27): error C2039: 'addC': is not a member of 'cv::gapi'
51>C:\opencvMaster\modules\gapi\include\opencv2/gapi/gkernel.hpp(296): note: see declaration of 'cv::gapi'
51>C:\opencvMaster\modules\gapi\perf\internal\gapi_compiler_perf_tests.cpp(27): error C2672: 'std::get': no matching overloaded function found
51>C:\opencvMaster\modules\gapi\perf\internal\gapi_compiler_perf_tests.cpp(27): error C2784: 'tuple_element<_Index,_Tuple>::type &std::get(std::pair<_Ty1,_Ty2> &) noexcept': could not deduce template argument for 'std::pair<_Ty1,_Ty2> &' from 'unknown-type'
51>        with
51>        [
51>            _Tuple=std::pair<_Ty1,_Ty2>
51>        ]

Since the errors are all stemming from the G-API module, building OpenCV without it had been a success. I have also tried an alternative of building it without BUILD_PERF_TESTS and BUILD_TESTS checked (since I don't require it for my application), the Debug build was successful but the Release build has given me this error:

19>CUSTOMBUILD : nvcc error : 'cicc' died with status 0xC0000005 (ACCESS_VIOLATION)
19>CMake Error at cuda_compile_1_generated_bilateral_filter.cu.obj.Release.cmake:279 (message):
19>  Error generating file
19>  C:/opencvMaster/build_noTest/modules/world/CMakeFiles/cuda_compile_1.dir/__/__/__/opencv_contrib/modules/cudaimgproc/src/cuda/Release/cuda_compile_1_generated_bilateral_filter.cu.obj
19>Done building project "opencv_world.vcxproj" -- FAILED.

Subsequent errors in the build are a result of that error:

20>LINK : fatal error LNK1181: cannot open input file '..\..\lib\Release\opencv_world410.lib'
20>Done building project "opencv_version.vcxproj" -- FAILED.
23>LINK : fatal error LNK1181: cannot open input file '..\..\..\..\lib\Release\opencv_world410.lib'
23>Done building project "opencv_waldboost_detector.vcxproj" -- FAILED.
24>LINK : fatal error LNK1181: cannot open input file '..\..\lib\Release\opencv_world410.lib'
24>Done building project "opencv_annotation.vcxproj" -- FAILED.
21>LINK : fatal error LNK1181: cannot open input file '..\..\lib\Release\opencv_world410.lib'
21>Done building project "opencv_version_win32.vcxproj" -- FAILED.
26>LINK : fatal error LNK1181: cannot open input file '..\..\lib\Release\opencv_world410.lib'
26>Done building project "opencv_interactive-calibration.vcxproj" -- FAILED.
25>LINK : fatal error LNK1181: cannot open input file '..\..\lib\Release\opencv_world410.lib'
25>Done building project "opencv_img_hash.vcxproj" -- FAILED.
22>LINK : fatal error LNK1181: cannot open input file '..\..\lib\Release\opencv_world410.lib'
22>Done building project "opencv_visualisation.vcxproj" -- FAILED.
29>CMake Error at apps/annotation/cmake_install.cmake:39 (file):
29>  file INSTALL cannot find
29>  "C:/opencvMaster/build_noTest/bin/Release/opencv_annotation.exe".

Any idea what went wrong?

haxiomic commented 5 years ago

I had the same issue and roughly the same build setup. I found downloading the matching release of opencv_contrib https://github.com/opencv/opencv_contrib/releases and then setting OPENCV_EXTRA_MODULES_PATH to my path:

OPENCV_EXTRA_MODULES_PATH: D:/Downloads/opencv_contrib-4.1.0/opencv_contrib-4.1.0/modules

Resolved the error

KwangEun commented 5 years ago

OPENCV_EXTRA_MODULES_PATH: D:/Downloads/opencv_contrib-4.1.0/opencv_contrib-4.1.0/modules

This helped me in solving a CUDA build error with FATAL_ERROR "CUDA: OpenCV requires enabled 'cudev' module from 'opencv_contrib' repository: https://github.com/opencv/opencv_contrib"

Thanx 💃

TNemes-3141 commented 4 years ago

@KwangEun @haxiomic I did exactly that and the error still persists. Any ideas how to resolve it?

hans-brgs commented 11 months ago

@Totemi1324 After many hours of trying to compile OpenCV 4.x with MediaPipe, I managed to integrate and compile MediaPipe without any errors. I've documented all the steps I took in this tutorial.

https://medium.com/@hans95.bourgeois/tutorial-compiling-and-integrating-opencv-4-x-with-mediapipe-c-framework-on-windows-11-20aba3a02d42

I hope this tutorial will be useful to others.

cudawarped commented 11 months ago

@Totemi1324 After many hours of trying to compile OpenCV 4.x with MediaPipe, I managed to integrate and compile MediaPipe without any errors. I've documented all the steps I took in this tutorial.

As @haxiomic said this is because @Totemi1324 didn't include the path to the OpenCV contrib repo correctly.