Opencv + CUDA + C++

I had difficulties building from the opencv + CUDA source code for c++.
I do everything according to this guide. Build OpenCV (including Python) with CUDA on Windows: Comprehensive Guide including Python Bindings, cuDNN, and Nvidia Video Codec SDK .

I’m writing this command in cmake “cmake -S C:\libs\opencv-4.5.2 -B C:\libs\build -D OPENCV_EXTRA_MODULES_PATH=C:\lib\opencv_contrib4x\modules -DCMAKE_BUILD_TYPE=Release -DWITH_CUDA=ON -DOPENCV_DNN_CUDA=ON -DOPENCV_DNN_OPENCL=ON -DBUILD_opencv_dnn=ON -DENABLE_FAST_MATH=ON -DBUILD_opencv_world=ON”
But for some reason, the opencv_world file is missing in the final build\install\lib, although it should be. Also, when building a project through Visual Studio, a linking error is displayed " 120>LINK : fatal error LNK1104: unable to open the file “…..\lib\Debug\opencv_world452d.lib”
120>The build of the project “opencv_perf_cudafeatures2d.vcxaview” has been completed with an error.
"
NVIDIA CUDA: YES (ver 12.8, CUFFT CUBLAS)
NVIDIA GPU arch: 50 52 60 61 70 75 80 86
I have a little snag, like in that topic. Missing lib files while building with Visual Studio 2022 - #5 by cudawarped .
CUDA Version 12.8
Visual Studio 2022
Errors when building INSTALL in visual studio
C:\libs\opencv-4.5.2\3rdparty\protobuf\src\google\protobuf\stubs\hash.h (241,22): error C2504: hash_compare: base class not defined
6>(copy of the outgoing file “…/…/…/opencv-4.5.2/3rdparty/protobuf/src/google/protobuf/reflection_ops.cc”)
6>C:\libs\opencv-4.5.2\3rdparty\protobuf\src\google\protobuf\map_field.h (817.48): error C2064: the argument is not repeated, it accepts 1 argument
6>(a copy of the outgoing file “…/…/…/opencv-4.5.2/3rdparty/protobuf/src/google/protobuf/reflection_ops.cc”)
How can this be fixed?

Without seeing the errors it is impossible to say what the cause is. That said you need the latest version of OpenCV (4.11) if you want to build against CUDA 12.8 which was released yesterday. If you have to use OpenCV 4.5.2 then you should be able to build this against CUDA 12.3.

This is why the top of the guide you linked to says

This guide assumes you are building the latest stable release of OpenCV against the most recent CUDA dependencies. Whilst the instructions can also work on older versions, this is not guaranteed so please update to the latest stable releases before raising any issues.

Thank you.I somehow didn’t think about it, I tried to build with opencv version 4.10, but I had approximately similar errors.Everything is stable on version 4.11.0.

1 Like