opencv-4.10.0-cudnn-9.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233
  1. https://github.com/opencv/opencv/issues/25711
  2. https://github.com/opencv/opencv/pull/25841
  3. From 3d74d646d8c4c48e400e650fef9463f174414b96 Mon Sep 17 00:00:00 2001
  4. From: Alexander Smorkalov <alexander.smorkalov@xperience.ai>
  5. Date: Mon, 1 Jul 2024 17:33:24 +0300
  6. Subject: [PATCH] Fixed CuDNN runtime version check for CuDNN 9+.
  7. --- a/modules/dnn/src/cuda4dnn/init.hpp
  8. +++ b/modules/dnn/src/cuda4dnn/init.hpp
  9. @@ -23,8 +23,19 @@ namespace cv { namespace dnn { namespace cuda4dnn {
  10. // Any patch release x.y.z is forward or backward-compatible with applications built against another cuDNN patch release x.y.w (meaning, of the same major and minor version number, but having w!=z).
  11. // cuDNN minor releases beginning with cuDNN 7 are binary backward-compatible with applications built against the same or earlier patch release (meaning, an application built against cuDNN 7.x is binary compatible with cuDNN library 7.y, where y>=x).
  12. // Applications compiled with a cuDNN version 7.y are not guaranteed to work with 7.x release when y > x.
  13. - auto cudnn_bversion = cudnnGetVersion();
  14. - auto cudnn_major_bversion = cudnn_bversion / 1000, cudnn_minor_bversion = cudnn_bversion % 1000 / 100;
  15. + int cudnn_bversion = cudnnGetVersion();
  16. + int cudnn_major_bversion = 0, cudnn_minor_bversion = 0;
  17. + // CuDNN changed major version multiplier in 9.0
  18. + if (cudnn_bversion >= 9*10000)
  19. + {
  20. + cudnn_major_bversion = cudnn_bversion / 10000;
  21. + cudnn_minor_bversion = cudnn_bversion % 10000 / 100;
  22. + }
  23. + else
  24. + {
  25. + cudnn_major_bversion = cudnn_bversion / 1000;
  26. + cudnn_minor_bversion = cudnn_bversion % 1000 / 100;
  27. + }
  28. if (cudnn_major_bversion != CUDNN_MAJOR || cudnn_minor_bversion < CUDNN_MINOR)
  29. {
  30. std::ostringstream oss;