Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need clear instructions on how to build opencvsharp with cuda to use gpu acceleration? #1673

Open
aloksharma1 opened this issue May 25, 2024 · 11 comments

Comments

@aloksharma1
Copy link

aloksharma1 commented May 25, 2024

hello i am using windows 11 and i have already checked 967 & #1668 , but as a c# dev i dont work with c++ much and these instructions are not clear for me (too advanced atm). I was hoping if you or anyone here can provide me with a step by step guide (please add a documentation for it, it will be big help instead of this "If you want to use the CUDA features, you need to customize the native bindings yourself.").

Thank you

@shimat @AvenSun

@aloksharma1
Copy link
Author

aloksharma1 commented May 29, 2024

Here is my opencv build cmake logs and i was able to make a build from it, but whats next?

Details
PS E:\CMakes\4.9\ShimatOpenCVSharp\opencv_files> .\build_windows_custom.ps1
Computing installation plan...
The following packages are already installed:
    tesseract:x64-windows-static -> 5.3.1
tesseract:x64-windows-static is already installed
Total install time: 64.3 us
tesseract provides CMake targets:

    # this is heuristically generated, and may not be correct
    find_package(Tesseract CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Tesseract::libtesseract)

Computing installation plan...
The following packages are already installed:
    eigen3:x64-windows -> 3.4.0#2
eigen3:x64-windows is already installed
Total install time: 66.7 us
eigen3 provides CMake targets:

    # this is heuristically generated, and may not be correct
    find_package(Eigen3 CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Eigen3::Eigen)

Computing installation plan...
The following packages are already installed:
    gflags:x64-windows -> 2.2.2#7
gflags:x64-windows is already installed
Total install time: 74.3 us
The package gflags provides CMake targets:

    find_package(gflags CONFIG REQUIRED)
    target_link_libraries(main PRIVATE gflags::gflags)

Computing installation plan...
The following packages are already installed:
    glog:x64-windows -> 0.6.0#2
glog:x64-windows is already installed
Total install time: 78.3 us
glog provides CMake targets:

    # this is heuristically generated, and may not be correct
    find_package(glog CONFIG REQUIRED)
    target_link_libraries(main PRIVATE glog::glog)


CUDA_PATH: E:\InstalledApps\Nvidia Cuda Toolkit 11.8
CUDNN_INCLUDE_DIR: E:\InstalledApps\Nvidia Cuda Toolkit 11.8\cudnn\v8.9.7.29_cuda11\include
CUDNN_LIB_DIR: E:\InstalledApps\Nvidia Cuda Toolkit 11.8\cudnn\v8.9.7.29_cuda11\lib\x64
NVCODEC_PATH: E:/InstalledApps/Nvidia Video Codec SDK/
Python Path: C:/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0
VCPKG Path: E:/CMakes/4.9/ShimatOpenCVSharp/vcpkg
GFLAGS Include Path: E:/CMakes/4.9/ShimatOpenCVSharp/vcpkg/packages/gflags_x64-windows/include
GFLAGS Lib Path: E:/CMakes/4.9/ShimatOpenCVSharp/vcpkg/packages/gflags_x64-windows/lib
GLOG Include Path: E:/CMakes/4.9/ShimatOpenCVSharp/vcpkg/packages/glog_x64-windows/include
GLOG Lib Path: E:/CMakes/4.9/ShimatOpenCVSharp/vcpkg/packages/glog_x64-windows/lib
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- The CXX compiler identification is MSVC 19.40.33808.0
-- The C compiler identification is MSVC 19.40.33808.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detected processor: AMD64
-- Found Python: C:/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0/python3.12.exe (found suitable version "3.12.3", minimum required is "3.2") found components: Interpreter Development Development.Module Development.Embed
-- Found Python: C:/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0/python3.12.exe (found suitable version "3.12.3", minimum required is "3.12") found components: Interpreter Development Development.Module Development.Embed
-- Performing Test HAVE_CXX_FP:FAST
-- Performing Test HAVE_CXX_FP:FAST - Success
-- Performing Test HAVE_C_FP:FAST
-- Performing Test HAVE_C_FP:FAST - Success
-- Performing Test HAVE_CPU_SSE3_SUPPORT (check file: cmake/checks/cpu_sse3.cpp)
-- Performing Test HAVE_CPU_SSE3_SUPPORT - Success
-- Performing Test HAVE_CPU_SSSE3_SUPPORT (check file: cmake/checks/cpu_ssse3.cpp)
-- Performing Test HAVE_CPU_SSSE3_SUPPORT - Success
-- Performing Test HAVE_CPU_SSE4_1_SUPPORT (check file: cmake/checks/cpu_sse41.cpp)
-- Performing Test HAVE_CPU_SSE4_1_SUPPORT - Success
-- Performing Test HAVE_CPU_POPCNT_SUPPORT (check file: cmake/checks/cpu_popcnt.cpp)
-- Performing Test HAVE_CPU_POPCNT_SUPPORT - Success
-- Performing Test HAVE_CPU_SSE4_2_SUPPORT (check file: cmake/checks/cpu_sse42.cpp)
-- Performing Test HAVE_CPU_SSE4_2_SUPPORT - Success
-- Performing Test HAVE_CXX_ARCH:AVX (check file: cmake/checks/cpu_fp16.cpp)
-- Performing Test HAVE_CXX_ARCH:AVX - Success
-- Performing Test HAVE_CXX_ARCH:AVX2 (check file: cmake/checks/cpu_avx2.cpp)
-- Performing Test HAVE_CXX_ARCH:AVX2 - Success
-- Performing Test HAVE_CXX_ARCH:AVX512 (check file: cmake/checks/cpu_avx512.cpp)
-- Performing Test HAVE_CXX_ARCH:AVX512 - Success
-- Performing Test HAVE_CPU_BASELINE_FLAGS
-- Performing Test HAVE_CPU_BASELINE_FLAGS - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_1
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_1 - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_2
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_2 - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_FP16
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_FP16 - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX2
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX2 - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX512_SKX
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX512_SKX - Success
-- Performing Test HAVE_CXX_W15240
-- Performing Test HAVE_CXX_W15240 - Success
-- Performing Test HAVE_C_W15240
-- Performing Test HAVE_C_W15240 - Success
-- Looking for malloc.h
-- Looking for malloc.h - found
-- Looking for _aligned_malloc
-- Looking for _aligned_malloc - found
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - failed
-- libjpeg-turbo: VERSION = 2.1.3, BUILD = opencv-4.9.0-libjpeg-turbo
-- Check size of size_t
-- Check size of size_t - done
-- Check size of unsigned long
-- Check size of unsigned long - done
-- Looking for include file intrin.h
-- Looking for include file intrin.h - found
-- Looking for a ASM_NASM compiler
-- Looking for a ASM_NASM compiler - E:/InstalledApps/nasm-2.16.03/nasm.exe
-- The ASM_NASM compiler identification is NASM
-- Found assembler: E:/InstalledApps/nasm-2.16.03/nasm.exe
-- CMAKE_ASM_NASM_COMPILER = E:/InstalledApps/nasm-2.16.03/nasm.exe
-- SIMD extensions: x86_64 (WITH_SIMD = 1)
-- Looking for assert.h
-- Looking for assert.h - found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for io.h
-- Looking for io.h - found
-- Looking for limits.h
-- Looking for limits.h - found
-- Looking for memory.h
-- Looking for memory.h - found
-- Looking for search.h
-- Looking for search.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Performing Test C_HAS_inline
-- Performing Test C_HAS_inline - Success
-- Check size of signed short
-- Check size of signed short - done
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Check size of signed int
-- Check size of signed int - done
-- Check size of unsigned int
-- Check size of unsigned int - done
-- Check size of signed long
-- Check size of signed long - done
-- Check size of signed long long
-- Check size of signed long long - done
-- Check size of unsigned long long
-- Check size of unsigned long long - done
-- Check size of unsigned char *
-- Check size of unsigned char * - done
-- Check size of ptrdiff_t
-- Check size of ptrdiff_t - done
-- Looking for memmove
-- Looking for memmove - not found
-- Looking for setmode
-- Looking for setmode - found
-- Looking for strcasecmp
-- Looking for strcasecmp - not found
-- Looking for strchr
-- Looking for strchr - found
-- Looking for strrchr
-- Looking for strrchr - found
-- Looking for strstr
-- Looking for strstr - found
-- Looking for strtol
-- Looking for strtol - found
-- Looking for strtol
-- Looking for strtol - found
-- Looking for strtoull
-- Looking for strtoull - found
-- Looking for lfind
-- Looking for lfind - found
-- Performing Test HAVE_SNPRINTF
-- Performing Test HAVE_SNPRINTF - Success
-- Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
-- OpenJPEG: VERSION = 2.5.0, BUILD = opencv-4.9.0-openjp2-2.5.0
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for stdio.h
-- Looking for stdio.h - found
-- Looking for math.h
-- Looking for math.h - found
-- Looking for float.h
-- Looking for float.h - found
-- Looking for time.h
-- Looking for time.h - found
-- Looking for stdarg.h
-- Looking for stdarg.h - found
-- Looking for ctype.h
-- Looking for ctype.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for strings.h
-- Looking for strings.h - not found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Looking for include file malloc.h
-- Looking for include file malloc.h - found
-- Looking for _aligned_malloc
-- Looking for _aligned_malloc - found
-- Looking for posix_memalign
-- Looking for posix_memalign - not found
-- Looking for memalign
-- Looking for memalign - not found
-- OpenJPEG libraries will be built from sources: libopenjp2 (version "2.5.0")
-- IPPICV: Downloading ippicv_2021.10.0_win_intel64_20230919_general.zip from https://raw.githubusercontent.com/opencv/opencv_3rdparty/0cc4aa06bf2bef4b05d237c69a5a96b9cd0cb85a/ippicv/ippicv_2021.10.0_win_intel64_20230919_general.zip
-- found Intel IPP (ICV version): 2021.11.0 [2021.11.0]
-- at: E:/CMakes/4.9/ShimatOpenCVSharp/opencv_files/build_win_x64/3rdparty/ippicv/ippicv_win/icv
-- found Intel IPP Integration Wrappers sources: 2021.11.0
-- at: E:/CMakes/4.9/ShimatOpenCVSharp/opencv_files/build_win_x64/3rdparty/ippicv/ippicv_win/iw
-- Found CUDNN: E:/InstalledApps/Nvidia Cuda Toolkit 11.8/cudnn/v8.9.7.29_cuda11/lib/x64/cudnn.lib (found suitable version "8.9.7", minimum required is "7.5")
-- Found NVCUVID: E:/InstalledApps/Nvidia Cuda Toolkit 11.8/lib/x64/nvcuvid.lib
-- Found NVCUVENC: E:/InstalledApps/Nvidia Cuda Toolkit 11.8/lib/x64/nvencodeapi.lib
-- CUDA detected: 11.8
-- CUDA: Using CUDA_ARCH_BIN=8.9
-- CUDA: NVCC target flags -allow-unsupported-compiler;-Xptxas=-v;-gencode;arch=compute_89,code=sm_89;-D_FORCE_INLINES
-- CUDA: MSVS generator is detected. Disabling CMake re-run checks (CMAKE_SUPPRESS_REGENERATION=ON). You need to run CMake manually if updates are required.
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- ADE: Downloading v0.1.2d.zip from https://github.com/opencv/ade/archive/v0.1.2d.zip
-- FFMPEG: Downloading opencv_videoio_ffmpeg.dll from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fbac408a47977ee4265f39e7659d33f1dfef5216/ffmpeg/opencv_videoio_ffmpeg.dll
-- FFMPEG: Downloading opencv_videoio_ffmpeg_64.dll from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fbac408a47977ee4265f39e7659d33f1dfef5216/ffmpeg/opencv_videoio_ffmpeg_64.dll
-- FFMPEG: Downloading ffmpeg_version.cmake from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fbac408a47977ee4265f39e7659d33f1dfef5216/ffmpeg/ffmpeg_version.cmake
-- Looking for mfapi.h
-- Looking for mfapi.h - found
-- Looking for vidcap.h
-- Looking for vidcap.h - found
-- Looking for d3d11_4.h
-- Looking for d3d11_4.h - found
-- freetype2:   NO
-- harfbuzz:    NO
-- Julia not found. Not compiling Julia Bindings.
-- Module opencv_ovis disabled because OGRE3D was not found
-- Checking SFM glog/gflags deps... TRUE
-- CERES support is disabled. Ceres Solver for reconstruction API is required.
-- Tesseract:   YES (ver unknown)
-- Allocator metrics storage type: 'long long'
-- Excluding from source files list: modules/imgproc/src/imgwarp.lasx.cpp
-- Excluding from source files list: modules/imgproc/src/resize.lasx.cpp
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': E:/CMakes/4.9/ShimatOpenCVSharp/opencv_files/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- Excluding from source files list: modules/dnn/src/layers/cpu_kernels/conv_winograd_f63.neon.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.rvv.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/int8layers/layers_common.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_block.neon.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_block.neon_fp16.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_depthwise.rvv.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_depthwise.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_winograd_f63.neon_fp16.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/fast_gemm_kernels.neon.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/fast_gemm_kernels.lasx.cpp
-- imgcodecs: OpenEXR codec is disabled in runtime. Details: https://github.com/opencv/opencv/issues/21326
-- highgui: using builtin backend: WIN32UI
-- wechat_qrcode: Downloading detect.caffemodel from https://raw.githubusercontent.com/WeChatCV/opencv_3rdparty/a8b69ccc738421293254aec5ddb38bd523503252/detect.caffemodel
-- wechat_qrcode: Downloading detect.prototxt from https://raw.githubusercontent.com/WeChatCV/opencv_3rdparty/a8b69ccc738421293254aec5ddb38bd523503252/detect.prototxt
-- wechat_qrcode: Downloading sr.caffemodel from https://raw.githubusercontent.com/WeChatCV/opencv_3rdparty/a8b69ccc738421293254aec5ddb38bd523503252/sr.caffemodel
-- wechat_qrcode: Downloading sr.prototxt from https://raw.githubusercontent.com/WeChatCV/opencv_3rdparty/a8b69ccc738421293254aec5ddb38bd523503252/sr.prototxt
-- xfeatures2d/boostdesc: Downloading boostdesc_bgm.i from https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm.i
-- xfeatures2d/boostdesc: Downloading boostdesc_bgm_bi.i from https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_bi.i
-- xfeatures2d/boostdesc: Downloading boostdesc_bgm_hd.i from https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_hd.i
-- xfeatures2d/boostdesc: Downloading boostdesc_binboost_064.i from https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_064.i
-- xfeatures2d/boostdesc: Downloading boostdesc_binboost_128.i from https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_128.i
-- xfeatures2d/boostdesc: Downloading boostdesc_binboost_256.i from https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_256.i
-- xfeatures2d/boostdesc: Downloading boostdesc_lbgm.i from https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_lbgm.i
-- xfeatures2d/vgg: Downloading vgg_generated_48.i from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_48.i
-- xfeatures2d/vgg: Downloading vgg_generated_64.i from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_64.i
-- xfeatures2d/vgg: Downloading vgg_generated_80.i from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_80.i
-- xfeatures2d/vgg: Downloading vgg_generated_120.i from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_120.i
-- data: Downloading face_landmark_model.dat from https://raw.githubusercontent.com/opencv/opencv_3rdparty/8afa57abc8229d611c4937165d20e2a2d9fc5a12/face_landmark_model.dat
-- CERES support is disabled. Ceres Solver for reconstruction API is required.
-- NVIDIA_OPTICAL_FLOW: Downloading edb50da3cf849840d680249aa6dbef248ebce2ca.zip from https://github.com/NVIDIA/NVIDIAOpticalFlowSDK/archive/edb50da3cf849840d680249aa6dbef248ebce2ca.zip
-- Building with NVIDIA Optical Flow API 2.0
--
-- General configuration for OpenCV 4.9.0 =====================================
--   Version control:               4.9.0-dirty
--
--   Extra modules:
--     Location (extra):            E:/CMakes/4.9/ShimatOpenCVSharp/opencv_files/opencv_contrib/modules
--     Version control (extra):     4.9.0
--
--   Platform:
--     Timestamp:                   2024-05-28T17:08:43Z
--     Host:                        Windows 10.0.22631 AMD64
--     CMake:                       3.29.3
--     CMake generator:             Visual Studio 17 2022
--     CMake build tool:            C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/MSBuild.exe
--     MSVC:                        1940
--     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 (14 files):         + SSSE3 SSE4_1
--       SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (0 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (8 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (34 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (5 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
--   C/C++:
--     Built as dynamic libs?:      NO
--     C++ standard:                11
--     C++ Compiler:                C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe  (ver 19.40.33808.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 /wd4819 /MP  /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  /fp:fast     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP  /Zi /Ob0 /Od /RTC1
--     C Compiler:                  C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/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  /fp:fast     /MP   /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  /fp:fast     /MP /Zi /Ob0 /Od /RTC1
--     Linker flags (Release):      /machine:x64  /NODEFAULTLIB:atlthunk.lib /INCREMENTAL:NO  /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:libcpmtd.lib /NODEFAULTLIB:msvcrtd.lib
--     Linker flags (Debug):        /machine:x64  /NODEFAULTLIB:atlthunk.lib /debug /INCREMENTAL  /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcpmt.lib /NODEFAULTLIB:msvcrt.lib
--     ccache:                      NO
--     Precompiled headers:         YES
--     Extra dependencies:          E:/CMakes/4.9/ShimatOpenCVSharp/vcpkg/packages/lapack_x64-windows/lib/lapack.lib comctl32 gdi32 ole32 setupapi ws2_32 E:/InstalledApps/Nvidia Cuda Toolkit 11.8/lib/x64/cuda.lib E:/InstalledApps/Nvidia Cuda Toolkit 11.8/lib/x64/nvcuvid.lib E:/InstalledApps/Nvidia Cuda Toolkit 11.8/lib/x64/nvencodeapi.lib correspondence multiview numeric glog::glog gflags::gflags_shared 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:E:/InstalledApps/Nvidia Cuda Toolkit 11.8/lib/x64 -LIBPATH:E:/InstalledApps/Nvidia Cuda Toolkit 11.8/cudnn/v8.9.7.29_cuda11/lib/x64
--     3rdparty dependencies:       ittnotify libprotobuf libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf zlib ippiw ippicv
--
--   OpenCV modules:
--     To be built:                 alphamat aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    datasets gapi java_bindings_generator js_bindings_generator objc_bindings_generator python_bindings_generator python_tests world
--     Disabled by dependency:      -
--     Unavailable:                 cannops cvv freetype hdf java julia matlab ovis python2 python3 ts viz
--     Applications:                -
--     Documentation:               NO
--     Non-free algorithms:         YES
--
--   Windows RT support:            NO
--
--   GUI:                           WIN32UI
--     Win32 UI:                    YES
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        build (ver 1.3)
--     JPEG:                        build-libjpeg-turbo (ver 2.1.3-62)
--       SIMD Support Request:      YES
--       SIMD Support:              YES
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         build (ver 1.6.37)
--     TIFF:                        build (ver 42 - 4.2.0)
--     JPEG 2000:                   build (ver 2.5.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:                   2021.11.0 [2021.11.0]
--            at:                   E:/CMakes/4.9/ShimatOpenCVSharp/opencv_files/build_win_x64/3rdparty/ippicv/ippicv_win/icv
--     Intel IPP IW:                sources (2021.11.0)
--               at:                E:/CMakes/4.9/ShimatOpenCVSharp/opencv_files/build_win_x64/3rdparty/ippicv/ippicv_win/iw
--     Lapack:                      NO
--     Eigen:                       YES (ver 3.4.0)
--     Custom HAL:                  NO
--     Protobuf:                    build (3.19.1)
--     Flatbuffers:                 builtin/3rdparty (23.5.9)
--
--   NVIDIA CUDA:                   YES (ver 11.8, CUFFT CUBLAS NVCUVID NVCUVENC FAST_MATH)
--     NVIDIA GPU arch:             89
--     NVIDIA PTX archs:
--
--   cuDNN:                         YES (ver 8.9.7)
--
--   OpenCL:                        YES (NVD3D11)
--     Include path:                E:/CMakes/4.9/ShimatOpenCVSharp/opencv_files/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
--
--   Python (for build):            C:/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0/python3.12.exe
--
--   Install to:                    E:/CMakes/4.9/ShimatOpenCVSharp/opencv_files/build_win_x64/install
-- -----------------------------------------------------------------
--
-- Configuring done (69.1s)
-- Generating done (4.1s)
-- Build files have been written to: E:/CMakes/4.9/ShimatOpenCVSharp/opencv_files/build_win_x64
Path
----
E:\CMakes\4.9\ShimatOpenCVSharp\opencv_files\build_win_x64

@aloksharma1
Copy link
Author

guys, i have built the opencvextern.dll but now i am getting error on trying to compile opencvsharp with x64 release config:

Build started at 12:28 AM...
1>------ Build started: Project: OpenCvSharp, Configuration: Release Any CPU ------
1>C:\Users\Alok\.nuget\packages\microsoft.build.tasks.git\1.1.1\build\Microsoft.Build.Tasks.Git.targets(25,5): warning : Could not find file 'F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\samples\.git'. The source code won't be available via Source Link.
1>C:\Users\Alok\.nuget\packages\microsoft.build.tasks.git\1.1.1\build\Microsoft.Build.Tasks.Git.targets(25,5): warning : Could not find file 'F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\samples\.git'. The source code won't be available via Source Link.
1>C:\Users\Alok\.nuget\packages\microsoft.build.tasks.git\1.1.1\build\Microsoft.Build.Tasks.Git.targets(25,5): warning : Could not find file 'F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\samples\.git'. The source code won't be available via Source Link.
1>C:\Users\Alok\.nuget\packages\microsoft.build.tasks.git\1.1.1\build\Microsoft.Build.Tasks.Git.targets(25,5): warning : Could not find file 'F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\samples\.git'. The source code won't be available via Source Link.
1>OpenCvSharp -> F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\bin\Release\netstandard2.1\OpenCvSharp.dll
1>OpenCvSharp -> F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\bin\Release\netstandard2.0\OpenCvSharp.dll
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\cuda\GpuMat.cs(7,19,7,23): error CS0234: The type or namespace name 'Util' does not exist in the namespace 'OpenCvSharp' (are you missing an assembly reference?)
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\cuda\GpuMatIndexer.cs(3,19,3,23): error CS0234: The type or namespace name 'Util' does not exist in the namespace 'OpenCvSharp' (are you missing an assembly reference?)
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\cuda\GpuMat.cs(1018,53,1018,57): warning CS8625: Cannot convert null literal to non-nullable reference type.
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\cuda\Stream.cs(272,84,272,88): warning CS8625: Cannot convert null literal to non-nullable reference type.
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\core\InputArray.cs(354,41,354,47): error CS0246: The type or namespace name 'GpuMat' could not be found (are you missing a using directive or an assembly reference?)
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\core\InputArray.cs(666,52,666,58): error CS0246: The type or namespace name 'GpuMat' could not be found (are you missing a using directive or an assembly reference?)
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\core\OutputArray.cs(265,42,265,48): error CS0246: The type or namespace name 'GpuMat' could not be found (are you missing a using directive or an assembly reference?)

total 565 error of this type, where do i need to reference the OpenCvSharpExtern release files? i tried putting them in opencvsharp solution folder and a x64 folder with this config in csproj folder:

<ItemGroup>
	<None Update="x64\OpenCvSharpExtern.dll">
		<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
		<TargetPath>runtimes\win-x64\native\OpenCvSharpExtern.dll</TargetPath>
	</None>
	<None Update="x64\OpenCvSharpExtern.exp">
		<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
		<TargetPath>runtimes\win-x64\native\OpenCvSharpExtern.exp</TargetPath>
	</None>
	<None Update="\OpenCvSharpExtern.lib">
		<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
		<TargetPath>runtimes\win-x64\native\OpenCvSharpExtern.lib</TargetPath>
	</None>
	<None Update="x64\OpenCvSharpExtern.pdb">
		<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
		<TargetPath>runtimes\win-x64\native\OpenCvSharpExtern.pdb</TargetPath>
	</None>
</ItemGroup>

still the issue remains the same.

@aloksharma1
Copy link
Author

Screenshot 2024-06-01 022732
here is the dependency walker result, if that helps?

@toita86
Copy link

toita86 commented Jun 3, 2024

Hi @aloksharma1,

I want to start by saying that I don't have the same level of knowledge as @AvenSun, as I'm still new to this stuff, but I'll do my best to help.

Let's begin with some basic checks. Just to be sure, is the NuGet package for OpenCvSharp (not the runtime) installed in your project? (Sorry if this seems like a basic question.)

@shimat
Copy link
Owner

shimat commented Jun 4, 2024

Are you trying to use the old OpenCvSharp implementation of GpuMat.cs, Stream.cs, etc? I think the OpenCvSharp implementation has changed so much that it is not compatible. I can't write up the solution to that here. This is probably not a problem on the C++ side, but on the C# implementation.

1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\cuda\GpuMat.cs(7,19,7,23): error CS0234: > > The type or namespace name 'Util' does not exist in the namespace 'OpenCvSharp' (are you missing an assembly reference?)
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\cuda\GpuMatIndexer.cs(3,19,3,23): error > CS0234: The type or namespace name 'Util' does not exist in the namespace 'OpenCvSharp' (are you missing an assembly reference?)

As for the error message about the Util namespace not being found, there is currently an implementation at
https://github.com/shimat/opencvsharp/tree/main/src/OpenCvSharp/Internal/Util

@aloksharma1
Copy link
Author

aloksharma1 commented Jun 4, 2024

Hi Guys,
First of All Thank you for your reply. I am not trying to use GpuMat implementation per say , just that my mat and operations are using cuda processors thats important even if syntax is changed i am ok with it.I'm  just trying to build a cuda compatible version so I can leverage my gpu, the cpu process is super slow.
@toita86 no, i am trying to build opencvsharp from source after successful compilation of opencv files & opencvexternextern folder. If i can use it without the compilation of opencvsharp project itself, please guide.

@shimat i will try your solution and will let you know before eod. i simply want gpu accelaration tow owkr with project.

Also one more question for you, my build log says:

-- FFMPEG: Downloading opencv_videoio_ffmpeg.dll from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fbac408a47977ee4265f39e7659d33f1dfef5216/ffmpeg/opencv_videoio_ffmpeg.dll
-- FFMPEG: Downloading opencv_videoio_ffmpeg_64.dll from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fbac408a47977ee4265f39e7659d33f1dfef5216/ffmpeg/opencv_videoio_ffmpeg_64.dll
-- FFMPEG: Downloading ffmpeg_version.cmake from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fbac408a47977ee4265f39e7659d33f1dfef5216/ffmpeg/ffmpeg_version.cmake

so its downloading ffmpeg, is cmake making the cuda version of this dll? my thinking is since we have enabled cuda flags it should be doing that internally?

thanks

@shimat
Copy link
Owner

shimat commented Jun 4, 2024

This is my guess, but there is only one opencv_videoio_ffmpeg(_64).dll available in the repository. The CUDA flag of the OpenCV cmake has no effect on the ffmpeg DLL selection.

@aloksharma1
Copy link
Author

aloksharma1 commented Jun 5, 2024

Hello @shimat i tried your suggestion and the util folder is already present in in the code. please check the screenshot here
Screenshot 2024-06-05 154631

as for the gpu mat error, i dont understand it much i downloaded and followed instructions given by you in here https://github.com/shimat/opencv_files

@shimat
Copy link
Owner

shimat commented Jun 5, 2024

The remaining Cuda code in OpenCvSharp has not been maintained for a long time, and unless you know a lot both C# and C++, it will be difficult to solve the problem in the short term. I discontinued OpenCvSharp's CUDA support because I was tired of dealing with issues like the one here.

This is my last reply, but perhaps the errors in your screenshot could be solved by changing namespace from OpenCvSharp to OpenCvSharp.Internal.

In addition, the corresponding functions on the C++ side must be included in the compilation beforehand. Currently they are excluded by macros.

#ifdef ENABLED_CUDA

@toita86
Copy link

toita86 commented Jun 8, 2024

Hi @aloksharma1 sorry for late response, for my case after all the compilations i just took advantage of the performance gain obtained by changing the target from CPU to GPU(for example on the Computer Vision model).

@aloksharma1
Copy link
Author

Hi @aloksharma1 sorry for late response, for my case after all the compilations i just took advantage of the performance gain obtained by changing the target from CPU to GPU(for example on the Computer Vision model).

thanks after @shimat said he disabled gpu support, i switched back to original compiled opencv with cuda support on python and used zero mq for cross process communication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants