Skip to content

CUDA 12.2 fp16 dnn compilation error #23893

@cudawarped

Description

@cudawarped

System Information

OpenCV version: 4.8.0
OS: Windows 11
Compiler: Visual Studio 2022
CUDA: 12.2

Detailed description

Switching from CUDA 12.1 to 12.2 results in several compilation like the one below when compiling the dnn module.

D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): error C2666: 'operator !=': overloaded functions have similar conversions
FAILED: modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/normalize_bbox_layer.cpp.obj
C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1434~1.319\bin\Hostx64\x64\cl.exe  /nologo /TP -DCVAPI_EXPORTS -DCV_CUDA4DNN=1 -DCV_OCL4DNN=1 -DENABLE_PLUGINS -DHAVE_FLATBUFFERS=1 -DHAVE_PROTOBUF=1 -D_CRT_SECURE_NO_WARNINGS=1 -D_USE_MATH_DEFINES -D_VARIADIC_MAX=10 -D_WIN32_WINNT=0x0601 -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -ID:\build\opencv\4_8_0\cuda_12_2_test\3rdparty\ippicv\ippicv_win\icv\include -ID:\build\opencv\4_8_0\cuda_12_2_test\3rdparty\ippicv\ippicv_win\iw\include -ID:\repos\opencv\opencv\modules\dnn\src -ID:\repos\opencv\opencv\modules\dnn\include -ID:\build\opencv\4_8_0\cuda_12_2_test\modules\dnn -ID:\repos\opencv\contrib\modules\cudev\include -ID:\repos\opencv\opencv\modules\core\include -ID:\repos\opencv\opencv\modules\imgproc\include -ID:\repos\opencv\opencv\modules\dnn\misc\caffe -ID:\repos\opencv\opencv\modules\dnn\misc\tensorflow -ID:\repos\opencv\opencv\modules\dnn\misc\onnx -ID:\repos\opencv\opencv\modules\dnn\misc\tflite -ID:\repos\opencv\opencv\3rdparty\include\opencl\1.2 -ID:\repos\opencv\opencv\modules\ts\include -ID:\repos\opencv\opencv\modules\imgcodecs\include -ID:\repos\opencv\opencv\modules\videoio\include -ID:\repos\opencv\opencv\modules\highgui\include -external:ID:\build\opencv\4_8_0\cuda_12_2_test -external:I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include" -external:ID:\repos\opencv\opencv\3rdparty\flatbuffers\include -external:ID:\repos\opencv\opencv\3rdparty\protobuf\src -external:W0 /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise /FS     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610 /wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506 /wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702 /wd4456 /wd4510 /wd4610 /wd4800 /wd4701 /wd4703 /wd4505 /wd4458  /MD /O2 /Ob2 /DNDEBUG /showIncludes /Fomodules\dnn\CMakeFiles\opencv_dnn.dir\src\layers\normalize_bbox_layer.cpp.obj /Fdlib\opencv_dnn480.pdb /FS -c D:\repos\opencv\opencv\modules\dnn\src\layers\normalize_bbox_layer.cpp
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): error C2666: 'operator !=': overloaded functions have similar conversions
D:\repos\opencv\opencv\modules\core\include\opencv2/core/persistence.hpp(1332): note: could be 'bool cv::operator !=(const cv::FileNodeIterator &,const cv::FileNodeIterator &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/mat.inl.hpp(2807): note: or       'bool cv::operator !=(const cv::SparseMatConstIterator &,const cv::SparseMatConstIterator &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/mat.inl.hpp(2398): note: or       'bool cv::operator !=(const cv::MatConstIterator &,const cv::MatConstIterator &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/mat.hpp(3708): note: or       'cv::MatExpr cv::operator !=(double,const cv::Mat &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/mat.hpp(3707): note: or       'cv::MatExpr cv::operator !=(const cv::Mat &,double)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/mat.hpp(3706): note: or       'cv::MatExpr cv::operator !=(const cv::Mat &,const cv::Mat &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/mat.hpp(583): note: or       'bool cv::operator !=(const cv::UMatData::MemoryFlag &,const int &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/mat.hpp(266): note: or       'bool cv::operator !=(const cv::_InputArray::KindFlag &,const int &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/mat.hpp(66): note: or       'bool cv::operator !=(const cv::AccessFlag &,const int &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/types.hpp(2086): note: or       'bool cv::operator !=(const cv::Range &,const cv::Range &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1279): note: or       'cv::hal_baseline::v_int64x2 cv::hal_baseline::operator !=(const cv::hal_baseline::v_int64x2 &,const cv::hal_baseline::v_int64x2 &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1278): note: or       'cv::hal_baseline::v_uint64x2 cv::hal_baseline::operator !=(const cv::hal_baseline::v_uint64x2 &,const cv::hal_baseline::v_uint64x2 &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1261): note: or       'cv::hal_baseline::v_float64x2 cv::hal_baseline::operator !=(const cv::hal_baseline::v_float64x2 &,const cv::hal_baseline::v_float64x2 &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1260): note: or       'cv::hal_baseline::v_float32x4 cv::hal_baseline::operator !=(const cv::hal_baseline::v_float32x4 &,const cv::hal_baseline::v_float32x4 &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1244): note: or       'cv::hal_baseline::v_int32x4 cv::hal_baseline::operator !=(const cv::hal_baseline::v_int32x4 &,const cv::hal_baseline::v_int32x4 &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1244): note: or       'cv::hal_baseline::v_uint32x4 cv::hal_baseline::operator !=(const cv::hal_baseline::v_uint32x4 &,const cv::hal_baseline::v_uint32x4 &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1243): note: or       'cv::hal_baseline::v_int16x8 cv::hal_baseline::operator !=(const cv::hal_baseline::v_int16x8 &,const cv::hal_baseline::v_int16x8 &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1243): note: or       'cv::hal_baseline::v_uint16x8 cv::hal_baseline::operator !=(const cv::hal_baseline::v_uint16x8 &,const cv::hal_baseline::v_uint16x8 &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1242): note: or       'cv::hal_baseline::v_int8x16 cv::hal_baseline::operator !=(const cv::hal_baseline::v_int8x16 &,const cv::hal_baseline::v_int8x16 &)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1242): note: or       'cv::hal_baseline::v_uint8x16 cv::hal_baseline::operator !=(const cv::hal_baseline::v_uint8x16 &,const cv::hal_baseline::v_uint8x16 &)'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include\cuda_fp16.hpp(714): note: or       'bool operator !=(const __half &,const __half &)' [found using argument-dependent lookup]
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include\cuda_fp16.hpp(917): note: or       'bool operator !=(const __half2 &,const __half2 &)' [found using argument-dependent lookup]
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include\cuda_bf16.hpp(700): note: or       'bool operator !=(const __nv_bfloat16 &,const __nv_bfloat16 &)' [found using argument-dependent lookup]
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include\cuda_bf16.hpp(903): note: or       'bool operator !=(const __nv_bfloat162 &,const __nv_bfloat162 &)' [found using argument-dependent lookup]
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(float, double)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(signed char, double)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(unsigned char, double)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(char, double)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(short, double)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(unsigned short, double)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(int, double)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(unsigned int, double)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(long, double)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(unsigned long, double)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(__int64, double)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(unsigned __int64, double)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: or       'built-in C++ operator!=(bool, double)'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/mat.inl.hpp(2718): note: or       'bool cv::operator !=(const cv::MatIterator_<_Tp> &,const cv::MatIterator_<_Tp> &)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: 'bool cv::operator !=(const cv::MatIterator_<_Tp> &,const cv::MatIterator_<_Tp> &)': could not deduce template argument for 'const cv::MatIterator_<_Tp> &' from 'T'
        with
        [
            T=half
        ]
D:\repos\opencv\opencv\modules\core\include\opencv2/core/mat.inl.hpp(2581): note: or       'bool cv::operator !=(const cv::MatConstIterator_<_Tp> &,const cv::MatConstIterator_<_Tp> &)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: 'bool cv::operator !=(const cv::MatConstIterator_<_Tp> &,const cv::MatConstIterator_<_Tp> &)': could not deduce template argument for 'const cv::MatConstIterator_<_Tp> &' from 'T'
        with
        [
            T=half
        ]
D:\repos\opencv\opencv\modules\core\include\opencv2/core/mat.hpp(3712): note: or       'cv::MatExpr cv::operator !=(const cv::Matx<_Tp,m,n> &,const cv::Mat &)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: 'cv::MatExpr cv::operator !=(const cv::Matx<_Tp,m,n> &,const cv::Mat &)': could not deduce template argument for 'const cv::Matx<_Tp,m,n> &' from 'T'
        with
        [
            T=half
        ]
D:\repos\opencv\opencv\modules\core\include\opencv2/core/mat.hpp(3710): note: or       'cv::MatExpr cv::operator !=(const cv::Mat &,const cv::Matx<_Tp,m,n> &)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: 'cv::MatExpr cv::operator !=(const cv::Mat &,const cv::Matx<_Tp,m,n> &)': could not deduce template argument for 'const cv::Matx<_Tp,m,n> &' from 'double'
D:\repos\opencv\opencv\modules\core\include\opencv2/core/types.hpp(2276): note: or       'bool cv::operator !=(const cv::Scalar_<_Tp> &,const cv::Scalar_<_Tp> &)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: 'bool cv::operator !=(const cv::Scalar_<_Tp> &,const cv::Scalar_<_Tp> &)': could not deduce template argument for 'const cv::Scalar_<_Tp> &' from 'T'
        with
        [
            T=half
        ]
D:\repos\opencv\opencv\modules\core\include\opencv2/core/types.hpp(1964): note: or       'bool cv::operator !=(const cv::Rect_<_Tp> &,const cv::Rect_<_Tp> &)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: 'bool cv::operator !=(const cv::Rect_<_Tp> &,const cv::Rect_<_Tp> &)': could not deduce template argument for 'const cv::Rect_<_Tp> &' from 'T'
        with
        [
            T=half
        ]
D:\repos\opencv\opencv\modules\core\include\opencv2/core/types.hpp(1795): note: or       'bool cv::operator !=(const cv::Size_<_Tp> &,const cv::Size_<_Tp> &)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: 'bool cv::operator !=(const cv::Size_<_Tp> &,const cv::Size_<_Tp> &)': could not deduce template argument for 'const cv::Size_<_Tp> &' from 'T'
        with
        [
            T=half
        ]
D:\repos\opencv\opencv\modules\core\include\opencv2/core/types.hpp(1584): note: or       'bool cv::operator !=(const cv::Point3_<_Tp> &,const cv::Point3_<_Tp> &)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: 'bool cv::operator !=(const cv::Point3_<_Tp> &,const cv::Point3_<_Tp> &)': could not deduce template argument for 'const cv::Point3_<_Tp> &' from 'T'
        with
        [
            T=half
        ]
D:\repos\opencv\opencv\modules\core\include\opencv2/core/types.hpp(1337): note: or       'bool cv::operator !=(const cv::Point_<_Tp> &,const cv::Point_<_Tp> &)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: 'bool cv::operator !=(const cv::Point_<_Tp> &,const cv::Point_<_Tp> &)': could not deduce template argument for 'const cv::Point_<_Tp> &' from 'T'
        with
        [
            T=half
        ]
D:\repos\opencv\opencv\modules\core\include\opencv2/core/types.hpp(1052): note: or       'bool cv::operator !=(const cv::Complex<_Tp> &,const cv::Complex<_Tp> &)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: 'bool cv::operator !=(const cv::Complex<_Tp> &,const cv::Complex<_Tp> &)': could not deduce template argument for 'const cv::Complex<_Tp> &' from 'T'
        with
        [
            T=half
        ]
D:\repos\opencv\opencv\modules\core\include\opencv2/core/matx.hpp(1365): note: or       'bool cv::operator !=(const cv::Matx<_Tp,m,n> &,const cv::Matx<_Tp,m,n> &)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: 'bool cv::operator !=(const cv::Matx<_Tp,m,n> &,const cv::Matx<_Tp,m,n> &)': could not deduce template argument for 'const cv::Matx<_Tp,m,n> &' from 'T'
        with
        [
            T=half
        ]
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(114): note: while trying to match the argument list '(T, double)'
        with
        [
            T=half
        ]
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/normalize_bbox.hpp(93): note: while compiling class template member function 'void cv::dnn::cuda4dnn::NormalizeOp<half>::forward(const std::vector<cv::Ptr<cv::dnn::dnn4_v20230620::BackendWrapper>,std::allocator<cv::Ptr<cv::dnn::dnn4_v20230620::BackendWrapper>>> &,const std::vector<cv::Ptr<cv::dnn::dnn4_v20230620::BackendWrapper>,std::allocator<cv::Ptr<cv::dnn::dnn4_v20230620::BackendWrapper>>> &,cv::dnn::cuda4dnn::csl::Workspace &)'
D:\repos\opencv\opencv\modules\dnn\src\layers\../op_cuda.hpp(194): note: see reference to class template instantiation 'cv::dnn::cuda4dnn::NormalizeOp<half>' being compiled
D:\repos\opencv\opencv\modules\dnn\src\layers\normalize_bbox_layer.cpp(332): note: see reference to function template instantiation 'cv::Ptr<cv::dnn::dnn4_v20230620::BackendNode> cv::dnn::make_cuda_node<cv::dnn::cuda4dnn::NormalizeOp,cv::dnn::cuda4dnn::csl::Stream,const cv::Mat&,cv::dnn::cuda4dnn::NormalizeConfiguration<float>&>(int,cv::dnn::cuda4dnn::csl::Stream &&,const cv::Mat &,cv::dnn::cuda4dnn::NormalizeConfiguration<float> &)' being compiled

it looks like a result of the CUDA Math API's being reworked in this version of CUDA, specifically changes to the C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include\cuda_fp16.hpp file.

Steps to reproduce

cmake.exe -BBUILD_DIR -HOPENCV_DIR -GNinja -DOPENCV_EXTRA_MODULES_PATH=OPENCV_CONTRIB_MODULES -DBUILD_opencv_world=OFF
-DWITH_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2" -DCUDA_ARCH_BIN=8.6

cmake.exe --build BUILD_DIR --target opencv_dnn

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions