Bug 431115 - Enable GPU optimizations support for OpenCV.
Summary: Enable GPU optimizations support for OpenCV.
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Bundle-Windows (other bugs)
Version First Reported In: 7.2.0
Platform: Microsoft Windows Microsoft Windows
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-03 16:52 UTC by Robert Golden
Modified: 2023-05-05 21:45 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 8.0.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Golden 2021-01-03 16:52:39 UTC
OS: Windows 10 Pro
GPU: Nvidia GTX 1080

When performing face recognition with "Disable hardware acceleration OpenCL" disabled, the task manager doesn't show the GPU being used. This leads me to believe that OpenCV is not compiled with CUDA support.

I found the following article that describes how to enable CUDA support for OpenCV: https://medium.com/@mhfateen/build-opencv-4-4-0-with-cuda-gpu-support-on-windows-10-without-tears-aa85d470bcd0
Comment 1 caulier.gilles 2021-01-03 17:46:51 UTC
Yes, opencv is not compiled with CUDA support.

In fact plenty of features are disabled :

https://invent.kde.org/graphics/digikam/-/blob/master/project/bundles/3rdparty/ext_opencv/CMakeLists.txt#L11

Why ? because Opencv is a biggggg puzzle, very complex to stabilize and optimize (from the digiKam side implementations).

Gilles Caulier
Comment 2 caulier.gilles 2023-04-03 12:47:23 UTC
Git commit 1e1a075f2cbb5160cff28f453a4a3693a97388df by Gilles Caulier.
Committed on 03/04/2023 at 12:45.
Pushed by cgilles into branch 'master'.

enable OpenCL compilation options in bundles.
OpenCL support still disabled by default

M  +9    -11   project/bundles/3rdparty/ext_opencv/CMakeLists.txt
D  +0    -12   project/bundles/3rdparty/ext_opencv/opencv-mmpause-linux.patch

https://invent.kde.org/graphics/digikam/commit/1e1a075f2cbb5160cff28f453a4a3693a97388df

diff --git a/project/bundles/3rdparty/ext_opencv/CMakeLists.txt b/project/bundles/3rdparty/ext_opencv/CMakeLists.txt
index 1371da72d6c..e8172314ccc 100644
--- a/project/bundles/3rdparty/ext_opencv/CMakeLists.txt
+++ b/project/bundles/3rdparty/ext_opencv/CMakeLists.txt
@@ -78,17 +78,18 @@ set(Opencv_Conf -DBUILD_EXAMPLES=OFF
                 -DWITH_IMGCODEC_HDR=OFF
                 -DWITH_IMGCODEC_SUNRASTER=OFF
                 -DWITH_IMGCODEC_PXM=OFF
+                -DCV_TRACE=OFF
+                -DCV_ENABLE_INTRINSICS=OFF
+                -DCV_DISABLE_OPTIMIZATION=ON
                 -DWITH_CUDA=OFF
                 -DWITH_CUFFT=OFF
                 -DWITH_CUBLAS=OFF
                 -DWITH_NVCUVID=OFF
-                -DWITH_OPENCL=OFF
-                -DWITH_OPENCL_SVM=OFF
-                -DWITH_OPENCLAMDFFT=OFF
-                -DWITH_OPENCLAMDBLAS=OFF
-                -DCV_ENABLE_INTRINSICS=OFF
-                -DCV_DISABLE_OPTIMIZATION=ON
-                -DCV_TRACE=OFF
+                -DWITH_OPENCL=ON
+                -DWITH_OPENCL_SVM=ON
+                -DWITH_OPENCLAMDFFT=ON
+                -DWITH_OPENCLAMDBLAS=ON
+                -DWITH_OPENCL_D3D11_NV=ON
 )

 JoinListAsString("${Opencv_Conf}" " " BASH_OPTIONS)
@@ -132,7 +133,7 @@ elseif(APPLE)
         ALWAYS 0
     )

-else() #Linux
+else() # Linux

     ExternalProject_Add(ext_opencv
         DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
@@ -142,9 +143,6 @@ else() #Linux

         INSTALL_DIR ${EXTPREFIX_opencv}

-        # To fix broken compilation under Linux 32 bits
-        PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/opencv-mmpause-linux.patch
-
         CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTPREFIX_opencv}
                    -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE}
                    ${GLOBAL_PROFILE}
diff --git a/project/bundles/3rdparty/ext_opencv/opencv-mmpause-linux.patch b/project/bundles/3rdparty/ext_opencv/opencv-mmpause-linux.patch
deleted file mode 100644
index 7bda6d1d1aa..00000000000
--- a/project/bundles/3rdparty/ext_opencv/opencv-mmpause-linux.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/modules/core/src/parallel_impl.cpp b/modules/core/src/parallel_impl.cpp
-index bc64fce7a..e80ebc3d1 100644
---- a/modules/core/src/parallel_impl.cpp
-+++ b/modules/core/src/parallel_impl.cpp
-@@ -44,6 +44,7 @@ DECLARE_CV_YIELD
- # endif
- #endif // CV_YIELD
-
-+#include <xmmintrin.h>
- // Spin lock's CPU-level yield (required for Hyper-Threading)
- #ifdef DECLARE_CV_PAUSE
- DECLARE_CV_PAUSE
Comment 3 caulier.gilles 2023-04-03 15:32:10 UTC
Git commit 51cc28d4c44b8e70228da877dd59b6970986731f by Gilles Caulier.
Committed on 03/04/2023 at 15:31.
Pushed by cgilles into branch 'master'.

add OpenCV::OpenCL configuration in Components Info Dialog

M  +1    -0    core/app/utils/digikam_opencv.h.cmake.in
M  +189  -0    core/libs/dialogs/libsinfodlg.cpp
M  +8    -0    core/libs/dialogs/libsinfodlg.h

https://invent.kde.org/graphics/digikam/commit/51cc28d4c44b8e70228da877dd59b6970986731f
Comment 4 caulier.gilles 2023-04-03 16:05:06 UTC
Git commit 9dce758cc0363a90ea1cc15ab06f34551e42d867 by Gilles Caulier.
Committed on 03/04/2023 at 16:04.
Pushed by cgilles into branch 'master'.

add OpenCV hardware and threads support information

M  +66   -12   core/libs/dialogs/libsinfodlg.cpp

https://invent.kde.org/graphics/digikam/commit/9dce758cc0363a90ea1cc15ab06f34551e42d867
Comment 5 caulier.gilles 2023-04-03 16:23:50 UTC
Git commit aaac1dc16783211286501b782445601ffe2545a6 by Gilles Caulier.
Committed on 03/04/2023 at 16:22.
Pushed by cgilles into branch 'master'.

update online documentation about the OpenCV::OpenCL support option from the Setup/Miscs configuration panel.

M  +1    -1    menu_descriptions/menu_mainwindow.rst
M  +1    -1    setup_application/miscs_settings.rst

https://invent.kde.org/documentation/digikam-doc/commit/aaac1dc16783211286501b782445601ffe2545a6
Comment 6 caulier.gilles 2023-04-03 16:26:18 UTC
The digiKam bundles (AppImage, Windows, MacOS) now have the OpenCV::OpenCL compilation enabled.
OpenCV::OpenCL support is disabled by default in application and needs to be turned on in Setup/Miscs/System configuration panel, for stability reasons.

Gilles Caulier
Comment 7 abstract.wolf@gmail.com 2023-05-05 21:41:50 UTC
(In reply to caulier.gilles from comment #6)
> The digiKam bundles (AppImage, Windows, MacOS) now have the OpenCV::OpenCL
> compilation enabled.
> OpenCV::OpenCL support is disabled by default in application and needs to be
> turned on in Setup/Miscs/System configuration panel, for stability reasons.
> 
> Gilles Caulier

Are there plans for the linux release to get a release with OpenCL enabled?
Comment 8 abstract.wolf@gmail.com 2023-05-05 21:45:59 UTC
(In reply to abstract.wolf@gmail.com from comment #7)
> (In reply to caulier.gilles from comment #6)
> > The digiKam bundles (AppImage, Windows, MacOS) now have the OpenCV::OpenCL
> > compilation enabled.
> > OpenCV::OpenCL support is disabled by default in application and needs to be
> > turned on in Setup/Miscs/System configuration panel, for stability reasons.
> > 
> > Gilles Caulier
> 
> Are there plans for the linux release to get a release with OpenCL enabled?

Ooops, I just saw that your comment didn't mention Linux, but in fact, after unchecking "Disable hardware acceleration OpenCL", my digikam is using OpenCL: http://ix.io/4vhU