summaryrefslogtreecommitdiff
path: root/media-libs/opencv/files/opencv-4.10.0-cudnn-9.patch
blob: 78ac162bef2dd7e621d7014b6b66de6a85b3aa08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
https://github.com/opencv/opencv/issues/25711
https://github.com/opencv/opencv/pull/25841

From 3d74d646d8c4c48e400e650fef9463f174414b96 Mon Sep 17 00:00:00 2001
From: Alexander Smorkalov <alexander.smorkalov@xperience.ai>
Date: Mon, 1 Jul 2024 17:33:24 +0300
Subject: [PATCH] Fixed CuDNN runtime version check for CuDNN 9+.

--- a/modules/dnn/src/cuda4dnn/init.hpp
+++ b/modules/dnn/src/cuda4dnn/init.hpp
@@ -23,8 +23,19 @@ namespace cv { namespace dnn { namespace cuda4dnn {
         //     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).
         //     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).
         //     Applications compiled with a cuDNN version 7.y are not guaranteed to work with 7.x release when y > x.
-        auto cudnn_bversion = cudnnGetVersion();
-        auto cudnn_major_bversion = cudnn_bversion / 1000, cudnn_minor_bversion = cudnn_bversion % 1000 / 100;
+        int cudnn_bversion = cudnnGetVersion();
+        int cudnn_major_bversion = 0, cudnn_minor_bversion = 0;
+        // CuDNN changed major version multiplier in 9.0
+        if (cudnn_bversion >= 9*10000)
+        {
+            cudnn_major_bversion = cudnn_bversion / 10000;
+            cudnn_minor_bversion = cudnn_bversion % 10000 / 100;
+        }
+        else
+        {
+            cudnn_major_bversion = cudnn_bversion / 1000;
+            cudnn_minor_bversion = cudnn_bversion % 1000 / 100;
+        }
         if (cudnn_major_bversion != CUDNN_MAJOR || cudnn_minor_bversion < CUDNN_MINOR)
         {
             std::ostringstream oss;