Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ZelboK
Copy link
Contributor

@ZelboK ZelboK commented Apr 14, 2024

A lot of APIs that are currently being used in the dnn module have been removed in cudnn 9. They were deprecated in 8. This PR updates said code accordingly to the newer API.

Some key notes:

  1. This is my first PR. I am new to openCV.
  2. opencv_test_core tests pass
  3. On a 3080, cuda 12.4(should be irrelevant since I didn't build the opencv_modules, gcc 11.4, WSL 2.
  4. For brevity I will avoid including macro code that will allow for older versions of cudnn to build.

I was unable to get the tests working for opencv_test_dnn and opencv_perf_dnn. The errors I get are of the following:

 OpenCV tests: Can't find required data file: dnn/onnx/conformance/node/test_reduce_prod_default_axes_keepdims_example/model.onnx in function 'findData'
" thrown in the test body.

So before I spend more time investigating I was hoping to get a maintainer to point me in the right direction here. I would like to run these tests and confirm things are working as intended. I may have missed some details.

Pull Request Readiness Checklist

relevant issue
(#24983

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@ZelboK ZelboK marked this pull request as draft April 14, 2024 21:11
@ZelboK
Copy link
Contributor Author

ZelboK commented Apr 14, 2024

I ran the precommit hook, but it is highlighting a lot of formatting related problems. Is there a simple fix for this?

@ZelboK ZelboK marked this pull request as ready for review April 14, 2024 21:16
@asmorkalov
Copy link
Contributor

@ZelboK thanks for the patch. General comments:

  • Please do not touch original formatting and the code that is not relevant to CuDNN 9.0.
  • OpenCV uses opencv_extra repository to store test data. See https://github.com/opencv/opencv/wiki/QA_in_OpenCV. Also there is download_models.py script in opencv_extra/testdata/dnn to download 3rdparty models for testing. Please use it to achieve full dnn coverage locally.

@ZelboK
Copy link
Contributor Author

ZelboK commented Apr 16, 2024

@asmorkalov
opencv_test_dnn
opencv_test_core
opencv_perf_dnn
opencv_sanity_dnn

All pass. Updated to remove the formatting problems.

Also, is there no formatting hook I could run to do all the formatting automatically for me?

@asmorkalov asmorkalov self-requested a review April 17, 2024 08:33
@asmorkalov
Copy link
Contributor

The PR breaks CuDNN 8 (v 8.7.0, Ubuntu 18.04):

[ 72%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/const_layer.cpp.o
In file included from /home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/csl/cudnn.hpp:8:0,
                 from /home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../op_cuda.hpp:12,
                 from /home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/blank_layer.cpp:43:
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/primitives/../csl/cudnn/recurrent.hpp: In constructor ‘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&)’:
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/primitives/../csl/cudnn/recurrent.hpp:129:11: error: ‘input_size’ was not declared in this scope
           input_size, hidden_size,
           ^
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/csl/cudnn/cudnn.hpp:22:53: note: in definition of macro ‘CUDA4DNN_CHECK_CUDNN’
     ::cv::dnn::cuda4dnn::csl::cudnn::detail::check((call), CV_Func, __FILE__, __LINE__)
                                                     ^~~~
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/primitives/../csl/cudnn/recurrent.hpp:129:11: note: suggested alternative: ‘hidden_size’
           input_size, hidden_size,
           ^
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/csl/cudnn/cudnn.hpp:22:53: note: in definition of macro ‘CUDA4DNN_CHECK_CUDNN’
     ::cv::dnn::cuda4dnn::csl::cudnn::detail::check((call), CV_Func, __FILE__, __LINE__)
                                                     ^~~~
In file included from /home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/primitives/reshape.hpp:12:0,
                 from /home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/blank_layer.cpp:49:
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/primitives/../csl/tensor_ops.hpp: In constructor ‘cv::dnn::cuda4dnn::csl::LSTM<T>::LSTM(cv::dnn::cuda4dnn::csl::cudnn::Handle, const cv::dnn::cuda4dnn::csl::LSTM<T>::params_type&)’:
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/primitives/../csl/tensor_ops.hpp:548:13: error: ‘filterDesc’ was not declared in this scope
             filterDesc = FilterDescriptor(params.weights_shape);
             ^~~~~~~~~~
modules/dnn/CMakeFiles/opencv_dnn.dir/build.make:853: recipe for target 'modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/blank_layer.cpp.o' failed
make[3]: *** [modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/blank_layer.cpp.o] Error 1
make[3]: *** Ожидание завершения заданий…
In file included from /home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/csl/cudnn.hpp:8:0,
                 from /home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../op_cuda.hpp:12,
                 from /home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/const_layer.cpp:10:
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/primitives/../csl/cudnn/recurrent.hpp: In constructor ‘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&)’:
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/primitives/../csl/cudnn/recurrent.hpp:129:11: error: ‘input_size’ was not declared in this scope
           input_size, hidden_size,
           ^
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/csl/cudnn/cudnn.hpp:22:53: note: in definition of macro ‘CUDA4DNN_CHECK_CUDNN’
     ::cv::dnn::cuda4dnn::csl::cudnn::detail::check((call), CV_Func, __FILE__, __LINE__)
                                                     ^~~~
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/primitives/../csl/cudnn/recurrent.hpp:129:11: note: suggested alternative: ‘hidden_size’
           input_size, hidden_size,
           ^
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/csl/cudnn/cudnn.hpp:22:53: note: in definition of macro ‘CUDA4DNN_CHECK_CUDNN’
     ::cv::dnn::cuda4dnn::csl::cudnn::detail::check((call), CV_Func, __FILE__, __LINE__)
                                                     ^~~~
In file included from /home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/primitives/const.hpp:12:0,
                 from /home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/const_layer.cpp:23:
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/primitives/../csl/tensor_ops.hpp: In constructor ‘cv::dnn::cuda4dnn::csl::LSTM<T>::LSTM(cv::dnn::cuda4dnn::csl::cudnn::Handle, const cv::dnn::cuda4dnn::csl::LSTM<T>::params_type&)’:
/home/alexander/Projects/OpenCV/opencv-master/modules/dnn/src/layers/../cuda4dnn/primitives/../csl/tensor_ops.hpp:548:13: error: ‘filterDesc’ was not declared in this scope
             filterDesc = FilterDescriptor(params.weights_shape);
             ^~~~~~~~~~
modules/dnn/CMakeFiles/opencv_dnn.dir/build.make:881: recipe for target 'modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/const_layer.cpp.o' failed

@johnnynunez
Copy link
Contributor

The PR breaks CuDNN 8 (v 8.7.0, Ubuntu 18.04):

it was because the PR is incomplete.
Some variables not exists as input_size.
This modules need to refactored

ZelboK and others added 2 commits May 17, 2024 15:25
@asmorkalov asmorkalov force-pushed the update-cudnn-to-9 branch from 7d9844c to 8eb703b Compare May 17, 2024 12:45
@johnnynunez
Copy link
Contributor

great job @asmorkalov! I'm waiting to that for build on jetson

@asmorkalov
Copy link
Contributor

There is still LSTM test failure.

ZelboK added 2 commits May 27, 2024 09:02
Remove print statements.
remove redundant coment
Copy link
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@asmorkalov asmorkalov self-assigned this May 27, 2024
@asmorkalov asmorkalov added this to the 4.10.0 milestone May 27, 2024
Remove trailing white space
@asmorkalov asmorkalov merged commit 05e4860 into opencv:4.x May 28, 2024
@mshabunin mshabunin mentioned this pull request Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: dnn category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants