opencv: DNN module fails to compile against cuDNN 9.0
System Information
OpenCV version: 4.x (09/02/2024) OS: Windows 11 Compiler: VS 2022 CUDA: 12.3 cuDNN: 9.0
Detailed description
Switching from cuDNN 8.9.7 to 9.0 results in the following build error
D:\repos\opencv\opencv\modules\dnn\src\cuda4dnn\csl\cudnn/recurrent.hpp(122): error C3861: 'cudnnSetRNNDescriptor_v6': identifier not found
when compiling the DNN module.
Full error trace
[372/491] Building CXX object modules\dnn\CMakeFiles\opencv_dnn.dir\Release\src\layers\recurrent_layers.cpp.obj
FAILED: modules/dnn/CMakeFiles/opencv_dnn.dir/Release/src/layers/recurrent_layers.cpp.obj
C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1436~1.325\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 -DCMAKE_INTDIR=\"Release\" -ID:\build\opencv\cuda_12_3_dnn\3rdparty\ippicv\ippicv_win\icv\include -ID:\build\opencv\cuda_12_3_dnn\3rdparty\ippicv\ippicv_win\iw\include -ID:\repos\opencv\opencv\modules\dnn\src -ID:\repos\opencv\opencv\modules\dnn\include -ID:\build\opencv\cuda_12_3_dnn\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\cuda_12_3_dnn -external:I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\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 /O2 /Ob2 /DNDEBUG /Zi -MD /showIncludes /Fomodules\dnn\CMakeFiles\opencv_dnn.dir\Release\src\layers\recurrent_layers.cpp.obj /Fdlib\Release\opencv_dnn490.pdb /FS -c D:\repos\opencv\opencv\modules\dnn\src\layers\recurrent_layers.cpp
D:\repos\opencv\opencv\modules\dnn\src\cuda4dnn\csl\cudnn/recurrent.hpp(122): error C3861: 'cudnnSetRNNDescriptor_v6': identifier not found
D:\repos\opencv\opencv\modules\dnn\src\cuda4dnn\csl\cudnn/recurrent.hpp(100): note: while compiling class template member function 'cv::dnn::cuda4dnn::csl::cudnn::RNNDescriptor<T>::RNNDescriptor(const cv::dnn::cuda4dnn::csl::cudnn::Handle &,cv::dnn::cuda4dnn::csl::cudnn::RNNDescriptor<T>::RNNMode,int,int,bool,const cv::dnn::cuda4dnn::csl::cudnn::DropoutDescriptor &)'
with
[
T=float
]
D:\repos\opencv\opencv\modules\dnn\src\cuda4dnn\primitives\../csl/tensor_ops.hpp(541): note: see the first reference to 'cv::dnn::cuda4dnn::csl::cudnn::RNNDescriptor<T>::RNNDescriptor' in 'cv::dnn::cuda4dnn::csl::LSTM<T>::LSTM'
with
[
T=float
]
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/recurrent_cells.hpp(48): note: see the first reference to 'cv::dnn::cuda4dnn::csl::LSTM<T>::LSTM' in 'cv::dnn::cuda4dnn::LSTMOp<float>::LSTMOp'
with
[
T=float
]
D:\repos\opencv\opencv\modules\dnn\src\cuda4dnn\primitives\../../op_cuda.hpp(196): note: see the first reference to 'cv::dnn::cuda4dnn::LSTMOp<float>::LSTMOp' in 'cv::dnn::make_cuda_node'
D:\repos\opencv\opencv\modules\dnn\src\cuda4dnn\primitives\../csl/tensor_ops.hpp(511): note: see reference to class template instantiation 'cv::dnn::cuda4dnn::csl::cudnn::RNNDescriptor<T>' being compiled
with
[
T=float
]
D:\repos\opencv\opencv\modules\dnn\src\layers\../cuda4dnn/primitives/recurrent_cells.hpp(88): note: see reference to class template instantiation 'cv::dnn::cuda4dnn::csl::LSTM<T>' being compiled
with
[
T=float
]
D:\repos\opencv\opencv\modules\dnn\src\cuda4dnn\primitives\../../op_cuda.hpp(196): note: see reference to class template instantiation 'cv::dnn::cuda4dnn::LSTMOp<float>' being compiled
D:\repos\opencv\opencv\modules\dnn\src\layers\recurrent_layers.cpp(763): note: see reference to function template instantiation 'cv::Ptr<cv::dnn::dnn4_v20231225::BackendNode> cv::dnn::make_cuda_node<cv::dnn::cuda4dnn::LSTMOp,cv::dnn::cuda4dnn::csl::Stream,cv::dnn::cuda4dnn::csl::cudnn::Handle,cv::Mat&,cv::Mat&,cv::Mat&,cv::dnn::cuda4dnn::RNNConfiguration&>(int,cv::dnn::cuda4dnn::csl::Stream &&,cv::dnn::cuda4dnn::csl::cudnn::Handle &&,cv::Mat &,cv::Mat &,cv::Mat &,cv::dnn::cuda4dnn::RNNConfiguration &)' being compiled
[393/491] Building CXX object modules\dnn\CMakeFiles\opencv_dnn.dir\Release\src\layers\split_layer.cpp.obj
ninja: build stopped: subcommand failed.
Steps to reproduce
cmake --build . --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)
About this issue
- Original URL
- State: open
- Created 5 months ago
- Comments: 34 (6 by maintainers)
Out of boredom and curiosity I tried to update the code on my own to accommodate for the breaking changes. For now it seems to build with cudnn 9, I just need to update it to be compatible with CUDA 12.4 as well.
Will push a PR upwards when I’m done. I’m guessing this will need to be for OpenCV 5? @cudawarped This would be my first contribution to openCV.
I went down to cuDNN 8.9.7 and that fixed this issue for me.
I have a PR up for this but it seems like one of hte builds broke. I don’t have time to fix this for a while but I am pretty sure cuda 12.4’s thrust toolkit has some problems when it comes to the tuples.
If you’re getting errors like
then be aware that there was a bug in calculating the fake tuple_size. That is fixed in CCCL’s main however.
Use the latest version of OpenCV with CUDA 12.3 and cuDNN 8.97 (currently neither CUDA 12.4 or cuDNN 9.0 are supported by OpenCV).
For flags see https://cudawarped.github.io/opencv-experiments/qmd/opencv_cuda_python_windows.html#building-opencv-with-cmake
I hit the same issue on Windows with Cuda 12,3 and cuDNN 9.0 with generator Visual Studio 16 2019
@cudawarped Thanks; cuDNN 8.9.7 fixed the issue for me.
I have what I think is the same issue on Ubuntu 22.04.3 LTS
error: ‘cudnnSetRNNDescriptor_v6’ was not declared in this scope; did you mean ‘cudnnSetRNNDescriptor_v8’?
Tested on OpenCV 4.9.0 and 4.x dev branch.