Problem building OpenCV with CUDA support from source files with Cmake (Python)

Hello all,

I am trying to compile OpenCV with Cuda support in Python, from source files using Cmake. I am using this video as reference: https://www.youtube.com/watch?v=YsmhKar8oOc

However, after trying numerous times, I always encounter problems. I believe it has to do with the specific Cuda/CUDNN version, my compute capability (8.6), the used version of Visual Studio and the matching OpenCV and OpenCV Contrib version.

I am using an NVIDIA GeForce RTX 3080 Laptop GPU with compute capability 8.6.

Using the latest versions of OpenCV (4.8.0) and Cuda/CUDNN (12.3 or 12.2) did not work, as after building and generating the source files and running the cmake command in Command Prompt (“C:\Program Files\CMake\bin\cmake.exe” --build “C:\OpenCV_Build\build” --target INSTALL --config Release) there still did not appear a CV2 folder in my anaconda3 sitepackages, neither did the file cv2.cp38-win_amd64.pyd appear in either the build folder or the anaconda folder.

However, I DID once get it to compile with a much earlier version of OpenCV and Cuda (I believe it was OpenCV 4.5 and Cuda 8.2, not sure, and Visual Studio 2019), but using this cv2 yielded strange results in VS code even though I could import cv2.cuda. It also complained of a version mismatch between the detected Cudnn and what cuda/cudnn OpenCV was compiled with. So I decided to try and recompile with a newer version again, but kept running into problems.

Anyways, my question is: What is the latest version of OpenCV and Cuda/Cudnn that you have confirmed to be able to work/compile successfully without errors that you know of? Using Cmake and source files. And have you been able to make it work with Visual Studio 2022 or only using the 2019 version? (the videos claim only version 2019 will work, but the videos are also 2 years old now)

Kind Regards
Jonathan

What error/warning/output makes you think its a CUDA/cuDNN issue?

This implies you haven’t specified the pythonpaths correctly. I would advise starting again and using the command line as described in this guide

then inspecting the CMake output before building to make sure that python3 will be built and that you have something similar to

– Python 3:
– Interpreter: C:/Users/username/mambaforge/python.exe (ver 3.9.16)
– Libraries: C:/Users/username/mambaforge/libs/python39.lib (ver 3.9.16)
– numpy: C:/Users/username/mambaforge/Lib/site-packages/numpy/core/include (ver 1.23.5)
– install path: C:/Users/username/mambaforge/Lib/site-packages/cv2/python-3.9

Hello Cudawarped, thank you for your comment.

What error/warning/output makes you think its a CUDA/cuDNN issue?
No error or warning, but on the tutorials people emphasized never to use the latest version of Cuda but something like 8.2 instead of 8.2.3 for example, which gave me the feeling that not all Cuda are stable/supports it properly. Also they said that Visual Studio 2022 doesn’t work and one should use the 2019 version instead.

This implies you haven’t specified the pythonpaths correctly. I would advise starting again and using the command line as described in this guide

I was aware of this and inspecting CMake to make sure it had these paths. It did. (This is also a step emphasized in the video from 3:21 - 6:51, that addressed all the pitfalls in Cmake to look out for. I double checked everything to a point). I ensured the proper python3 bindings and paths were correct, including that OpenCV Modules included python3 under “to be built”, that Cudnn and Cuda (and their proper version) were being detected in Cmake, and all of these things. Everything looked correct but still the file was not being output where it should after I configured and generated one last time and then ran the cmake command in Command Prompt, unfortunately.

This is always a possibility (new releases can always break something) but it is not the general rule and not the case as far as I know at the moment. If you successfuly built the OpenCV libs then its a python binding not a CUDA issue.

Can you provide your CMake configuration output please.

General configuration for OpenCV 4.8.0 =====================================
Version control: unknown

Extra modules:
Location (extra): C:/Users/JGJ/Desktop/JLI/JLI_Chromasense_opgave23/OpenCV_GPU_Build_231023/opencv_contrib-4.8.0/modules
Version control (extra): unknown

Platform:
Timestamp: 2023-10-24T10:55:13Z
Host: Windows 10.0.19045 AMD64
CMake: 3.27.7
CMake generator: Visual Studio 17 2022
CMake build tool: C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe
MSVC: 1937
Configuration: Release

CPU/HW features:
Baseline: SSE SSE2 SSE3
requested: SSE3
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (18 files): + SSSE3 SSE4_1
SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (37 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX

C/C++:
Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe (ver 19.37.32825.0)
C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP /MD /O2 /Ob2 /DNDEBUG
C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP /MDd /Zi /Ob0 /Od /RTC1
C Compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe
C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /MP /MD /O2 /Ob2 /DNDEBUG
C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /MP /MDd /Zi /Ob0 /Od /RTC1
Linker flags (Release): /machine:x64 /INCREMENTAL:NO
Linker flags (Debug): /machine:x64 /debug /INCREMENTAL
ccache: NO
Precompiled headers: NO
Extra dependencies: cudart_static.lib nppc.lib nppial.lib nppicc.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cudnn.lib cufft.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/lib/x64
3rdparty dependencies:

OpenCV modules:
To be built: aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode world xfeatures2d ximgproc xobjdetect xphoto
Disabled: -
Disabled by dependency: -
Unavailable: alphamat cvv freetype hdf java julia matlab ovis python2 python2 sfm viz
Applications: tests perf_tests apps
Documentation: NO
Non-free algorithms: NO

Windows RT support: NO

GUI:
Win32 UI: YES
VTK support: NO

Media I/O:
ZLib: build (ver 1.2.13)
JPEG: build-libjpeg-turbo (ver 2.1.3-62)
SIMD Support Request: YES
SIMD Support: NO
WEBP: build (ver encoder: 0x020f)
PNG: build (ver 1.6.37)
TIFF: build (ver 42 - 4.2.0)
JPEG 2000: build (ver 2.5.0)
OpenEXR: build (ver 2.3.0)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES

Video I/O:
DC1394: NO
FFMPEG: YES (prebuilt binaries)
avcodec: YES (58.134.100)
avformat: YES (58.76.100)
avutil: YES (56.70.100)
swscale: YES (5.9.100)
avresample: YES (4.0.0)
GStreamer: NO
DirectShow: YES
Media Foundation: YES
DXVA: YES

Parallel framework: Concurrency

Trace: YES (with Intel ITT)

Other third-party libraries:
Intel IPP: 2021.8 [2021.8.0]
at: C:/OpenCV_Build_231023/3rdparty/ippicv/ippicv_win/icv
Intel IPP IW: sources (2021.8.0)
at: C:/OpenCV_Build_231023/3rdparty/ippicv/ippicv_win/iw
Lapack: NO
Eigen: NO
Custom HAL: NO
Protobuf: build (3.19.1)
Flatbuffers: builtin/3rdparty (23.5.9)

NVIDIA CUDA: YES (ver 12.2, CUFFT CUBLAS FAST_MATH)
NVIDIA GPU arch: 86
NVIDIA PTX archs:

cuDNN: YES (ver 8.9.5)

OpenCL: YES (NVD3D11)
Include path: C:/Users/JGJ/Desktop/JLI/JLI_Chromasense_opgave23/OpenCV_GPU_Build_231023/opencv-4.8.0/3rdparty/include/opencl/1.2
Link libraries: Dynamic load

Python 3:
Interpreter: C:/ProgramData/anaconda3/python.exe (ver 3.11.5)
Libraries: C:/ProgramData/anaconda3/libs/python311.lib (ver 3.11.5)
numpy: C:/Users/JGJ/AppData/Roaming/Python/Python311/site-packages/numpy/core/include (ver 1.26.1)
install path: C:/ProgramData/anaconda3/Lib/site-packages/cv2/python-3.11

Python (for build): C:/ProgramData/anaconda3/python.exe

Java:
ant: NO
Java: NO
JNI: NO
Java wrappers: NO
Java tests: NO

Install to: C:/OpenCV_Install_231023

Configuring done (16.5s)

I think your issue could be due to a compatibility problem with CUDA >=12.2 and OpenCV 4.8.0 (CUDA 12.2 was released after OpenCV 4.8.0) resulting in your build failing. I just checked and MSBuild does not appear to explicitly indicate that a failure has taken place. As I said compatibility problems are not the rule but it does happen.

If you use the latest commits from 4.x branch of opencv and opencv_contrib repos you shouldn’t have any issues. Additionaly I would build with ninja unless you enjoy waiting 3 hours for Visual Studio to do its thing.

please direct your issues to the author of the video. they are responsible for any issues that arise from following their advice. or ditch that entire youtube channel and follow the guides provided by cudawarped.

1 Like

Hi again Cudawarped,

I tried again with the latest commits of OpenCV (4.8.1) and corresponding contrib, along with a fresh reinstall of VS 2022 but same thing. It runs until the end without any errors, but the file is not made and the install dir is still empty…

I also tried using the Ninja method from your website, but during this the cmd complains of the following error:

– Excluding from source files list: /modules/world/int8layers/layers_common.lasx.cpp
– Excluding from source files list: /modules/world/layers/cpu_kernels/conv_depthwise.rvv.cpp
– Excluding from source files list: /modules/world/layers/cpu_kernels/conv_depthwise.lasx.cpp
CMake Error at cmake/OpenCVUtils.cmake:1479 (target_link_libraries):
Syntax error in cmake code at

C:/OpenCV_Build_4.8.1/opencv-4.8.1/cmake/OpenCVUtils.cmake:1479

when parsing string

PRIVATE;C:\ProgramData\anaconda3\libs\python%pyVer%.lib

Invalid character escape ‘\P’.
Call Stack (most recent call first):
cmake/OpenCVUtils.cmake:1509 (__ocv_push_target_link_libraries)
modules/python/common.cmake:64 (ocv_target_link_libraries)
modules/python/python3/CMakeLists.txt:20 (include)

– Configuring incomplete, errors occurred!

Use the latest commit from the 4.x branch the 4.8.1 tag does not include the fix and the other error is my fault, I left in the the environmental variable tags, it should be

-DPYTHON3_LIBRARY=PATH_TO_PYTHON_DIST/libs/pythonPYTHON_VERSION.lib 

where

PYTHON_VERSION is the concatination of the major and minor version of your python install, e.g. for Python 3.10.10 PYTHON_VERSION==310.

The same error occurs unfortunately after applying your changes, and using the latest commit from the 4.x branch for Opencv and contrib:

– Excluding from source files list: /modules/world/layers/cpu_kernels/fast_gemm_kernels.lasx.cpp
CMake Error at cmake/OpenCVUtils.cmake:1479 (target_link_libraries):
Syntax error in cmake code at

C:/OpenCV_Build_LatestCommit/opencv-4.x/cmake/OpenCVUtils.cmake:1479

when parsing string

PRIVATE;C:\ProgramData\anaconda3\libs\python311.lib

Invalid character escape ‘\P’.
Call Stack (most recent call first):
cmake/OpenCVUtils.cmake:1509 (__ocv_push_target_link_libraries)
modules/python/common.cmake:64 (ocv_target_link_libraries)
modules/python/python3/CMakeLists.txt:20 (include)

– Configuring incomplete, errors occurred!

This is the code I provide to the cmd:

“C:/Program Files/CMake/bin/cmake.exe” -H"C:/OpenCV_Build_LatestCommit/opencv-4.x" -DOPENCV_EXTRA_MODULES_PATH=“C:/OpenCV_Build_LatestCommit/opencv_contrib-4.x/modules” -B"C:/OpenCV_Build_LatestCommit/build" -G"Ninja" -DCMAKE_BUILD_TYPE=Release -DINSTALL_TESTS=ON -DINSTALL_C_EXAMPLES=ON -DBUILD_EXAMPLES=ON -DBUILD_opencv_world=ON -DWITH_CUDA=ON -DCUDA_ARCH_BIN=86 -DCUDA_ARCH_PTX=8.6 -DBUILD_opencv_python3=ON -DPYTHON3_INCLUDE_DIR=C:/ProgramData/anaconda3/include -DPYTHON3_LIBRARY=“C:/ProgramData/anaconda3/libs/python311.lib” -DPYTHON3_EXECUTABLE=“C:/ProgramData/anaconda3/python.exe” -DPYTHON3_NUMPY_INCLUDE_DIRS=“C:/ProgramData/anaconda3/lib/site-packages/numpy/core/include” -DPYTHON3_PACKAGES_PATH=“C:/ProgramData/anaconda3/Lib/site-packages” -DOPENCV_SKIP_PYTHON_LOADER=ON

I tried also using both forward slashes and back slashes

I just tried your arguments with my source and build directory and cmake doesn’t output any errors even though I don’t have python installed in the same locations as you.

I used

"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"

"C:/Program Files/CMake/bin/cmake.exe" -H"D:\repos\opencv\opencv" -DOPENCV_EXTRA_MODULES_PATH="D:\repos\opencv\contrib\modules" -B"D:/build/opencv/cuda_12_3_test_python" -G"Ninja" -DCMAKE_BUILD_TYPE=Release -DINSTALL_TESTS=ON -DINSTALL_C_EXAMPLES=ON -DBUILD_EXAMPLES=ON -DBUILD_opencv_world=ON -DWITH_CUDA=ON -DCUDA_ARCH_BIN=86 -DCUDA_ARCH_PTX=8.6 -DBUILD_opencv_python3=ON -DPYTHON3_INCLUDE_DIR=C:/ProgramData/anaconda3/include -DPYTHON3_LIBRARY="C:/ProgramData/anaconda3/libs/python311.lib" -DPYTHON3_EXECUTABLE="C:/ProgramData/anaconda3/python.exe" -DPYTHON3_NUMPY_INCLUDE_DIRS="C:/ProgramData/anaconda3/lib/site-packages/numpy/core/include" -DPYTHON3_PACKAGES_PATH="C:/ProgramData/anaconda3/Lib/site-packages"

Can you clean your build directory and post the output you get with forward slashes as the error you posted

PRIVATE;C:\ProgramData\anaconda3\libs\python311.lib

was from when you called CMake with back slashes.

Hi again,

So, after cleaning the build directory and typing it in exactly as you did, it for some reason worked. I am not sure why, because I believe I cleaned the build directory before each run, and didn’t make any changes… Except that I used forward slashes except for the two paths you specified (-H"D:\repos\opencv\opencv" -DOPENCV_EXTRA_MODULES_PATH=“D:\repos\opencv\contrib\modules”) where backslashes were used instead.

HOWEVER, after running this and the install path, and everything working correctly (including getting the PASSED test after running “PATH_TO_BUILD_DIR\bin\opencv_test_cudaarithm.exe” --gtest_filter=CUDA_Arithm/GEMM.Accuracy/0,

I am still not able to import cv2. When running import cv2 as cv, it returns
“ImportError: DLL load failed while importing cv2: The specified module could not be found.”.

I am currently following your tutorial on how to fix this issue (ImportError: DLL load failed while importing cv2: The specified module could not be found) , using the process monitor, but in your tutorial you locate the opencv_world480.dll inside a directory similar to “D:\build\opencv\4_7_0\cuda_12_D\bin”.

After looking in my build folder, there is no folder named opencv. There is however a folder named opencv2, but this folder only contains 2 files, “cvconfig.h” and “opencv_modules.hpp”, and no subdirectories. I also tried to do a search across my entire C drive for this file, but it doesn’t seem to exist anywhere, so I guess it was never created. You can see the output of my processmonitor below, after trying to import cv2 in Anaconda Prompt:

I guess the step at this point is to attempt a clean, new reinstall, but I feel like I’ve done that so many times to no avail, after following the instructions to the point. But atleast I know that OpenCV is successfully installed and cuda verified, I just need to make Python be able to detect it. Can you advise? Thank you for your time.

I should also add that there doesn’t exist a folder named “cv2” at all inside the site-packages of the Python_dist_library_path, and also, that the file “cv2.cp311-win_amd64.pyd” WAS created in here, in the Python_dist_library_path (C:\ProgramData\anaconda3\Lib\site-packages), but not any folder named cv2. So that file is the only trace of any cv2 activity being created, so to say. And the timestamp matches when I ran the build, so atleast that part is correct.

Hi again,

my system did actually find the opencv_world480.dll file in the end, it just took it like 30 minutes of searching to do so for some reason, hence the reason why I didn’t think it existed. It was located in “C:\OpenCV_Build_LatestCommit\build\bin\opencv_world480.dll” after all, so the path was a bit different to yours

D:\build\opencv\4_7_0\cuda_12_D\ is my path to where I built OpenCV, i.e. its a build of 4.7.0 and the build folder is cuda_12_D. The folder you are looking for is the bin inside that directory.

I am not sure why this is in the wrong place, did you manually copy it previously?

Check your CMake configuration output to see where the cv2 directory is being installed to. In the one from the guide, repeated below

– Interpreter: C:/Users/b/mambaforge/python.exe (ver 3.9.16)
– Libraries: C:/Users/b/mambaforge//libs/python39.lib (ver 3.9.16)
– numpy: C:/Users/b/mambaforge/Lib/site-packages/numpy/core/include (ver 1.23.5)
– install path: C:/Users/b/mambaforge//Lib/site-packages//cv2/python-3.9

it is being installed to C:/Users/b/mambaforge//Lib/site-packages//cv2/python-3.9 which in your case should be the C:\ProgramData\anaconda3\Lib\site-packages\cv2\python-3.10 directory?

It’s possible you have files from previous installation attempts in the site packages directory which is causing your error.

I am not sure why this is in the wrong place, did you manually copy it previously?

No, it put it there itself as part of the installation process. I never moved it myself. And the timestamp of its creation indicates that it was created as part of the running the command.

Check your CMake configuration output to see where the cv2 directory is being installed to. In the one from the guide, repeated below

Considering I am now using the CMD approach, isn’t the cmake configuration output exclusive to using the Cmake GUI approach? anyhow I opened up Cmake and checked, and it should install to C:/ProgramData/anaconda3/Lib/site-packages/cv2/python-3.11. But this directory doesn’t exist and is not being created for some reason.

It’s possible you have files from previous installation attempts in the site packages directory which is causing your error.

I deleted anaconda and visual studio completely and did a fresh reinstall prior to each installation attempt, but I guess I could try and do this again now that I got the CMD approach to work.

When you call CMake from the command line you get output to the command prompt. At the bottom it will be something similar to

--   Python 3:
--     Interpreter:                 C:/Users/b/mambaforge/python.exe (ver 3.9.16)
--     Libraries:                   C:/Users/b/mambaforge//libs/python39.lib (ver 3.9.16)
--     numpy:                       C:/Users/b/mambaforge/Lib/site-packages/numpy/core/include (ver 1.23.5)
--     install path:                C:/Users/b/mambaforge//Lib/site-packages//cv2/python-3.9
--
--   Python (for build):            C:/Users/b/mambaforge/python.exe
--
--   Java:
--     ant:                         NO
--     Java:                        NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
--
--   Install to:                    D:/build/opencv/4_8_X/install
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: D:/build/opencv/4_8_X

Can you post your CMake configuration output so I can take a look. It is the same output shown in the guide under “Example of CMake Configuration Output”.

When you build the Install target you should have output again to the command line showing where things are installed, e.g.

Example of Python installation output

– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/init.py
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/load_config_py2.py
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/load_config_py3.py
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/config.py
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/misc/init.py
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/misc/version.py
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/mat_wrapper/init.py
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/utils/init.py
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/init.py
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/aruco
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/aruco/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/barcode
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/barcode/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/bgsegm
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/bgsegm/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/bioinspired
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/bioinspired/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/ccm
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/ccm/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/colored_kinfu
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/colored_kinfu/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/cuda
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/cuda/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/cudacodec
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/cudacodec/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/datasets
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/datasets/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/detail
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/detail/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/dnn
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/dnn/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/dnn_superres
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/dnn_superres/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/dpm
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/dpm/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/dynafu
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/dynafu/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/Error
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/Error/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/face
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/face/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/fisheye
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/fisheye/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/flann
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/flann/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/ft
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/ft/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/core
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/core/cpu
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/core/cpu/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/core/fluid
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/core/fluid/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/core/ocl
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/core/ocl/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/core/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/ie
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/ie/detail
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/ie/detail/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/ie/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/imgproc
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/imgproc/fluid
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/imgproc/fluid/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/imgproc/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/oak
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/oak/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/onnx
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/onnx/ep
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/onnx/ep/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/onnx/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/ov
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/ov/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/own
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/own/detail
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/own/detail/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/own/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/render
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/render/ocv
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/render/ocv/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/render/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/streaming
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/streaming/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/video
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/video/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/wip
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/wip/draw
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/wip/draw/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/wip/gst
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/wip/gst/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/wip/onevpl
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/wip/onevpl/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/wip/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/gapi/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/hfs
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/hfs/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/img_hash
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/img_hash/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/intensity_transform
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/intensity_transform/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/ipp
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/ipp/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/kinfu
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/kinfu/detail
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/kinfu/detail/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/kinfu/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/large_kinfu
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/large_kinfu/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/legacy
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/legacy/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/linemod
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/linemod/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/line_descriptor
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/line_descriptor/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/mcc
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/mcc/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/ml
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/ml/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/motempl
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/motempl/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/multicalib
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/multicalib/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/ocl
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/ocl/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/ogl
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/ogl/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/omnidir
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/omnidir/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/optflow
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/optflow/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/parallel
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/parallel/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/phase_unwrapping
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/phase_unwrapping/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/plot
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/plot/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/ppf_match_3d
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/ppf_match_3d/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/py.typed
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/quality
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/quality/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/rapid
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/rapid/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/reg
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/reg/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/rgbd
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/rgbd/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/saliency
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/saliency/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/samples
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/samples/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/segmentation
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/segmentation/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/stereo
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/stereo/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/structured_light
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/structured_light/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/text
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/text/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/typing
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/typing/init.py
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/utils
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/utils/fs
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/utils/fs/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/utils/nested
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/utils/nested/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/utils/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/videoio_registry
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/videoio_registry/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/videostab
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/videostab/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/wechat_qrcode
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/wechat_qrcode/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/xfeatures2d
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/xfeatures2d/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/ximgproc
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/ximgproc/segmentation
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/ximgproc/segmentation/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/ximgproc/init.pyi
– Up-to-date: C:/Users/b/mambaforge/Lib/site-packages/cv2/xphoto
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/xphoto/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/init.pyi
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/python-3.9/cv2.cp39-win_amd64.pyd
– Installing: C:/Users/b/mambaforge/Lib/site-packages/cv2/config-3.9.py

Hi again,

after adding these two lines before importing cv2, it seems to work now in VS Code:

os.add_dll_directory(r"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\bin")

os.add_dll_directory(r"C:\OpenCV_Build_LatestCommit\build\bin")

Thank you for all your help!

One last question, if you have the time: The entire reason why I wanted OpenCV with CUDA support was because I am trying to create disparity maps with the function

stereo = cv.StereoBM_create(
numDisparities=numDisparities,
blockSize=BlockSize)

I was interested in seeing the speedup when doing this with the gpu isntead. As far as I could see, the cuda version/way of doing this would be:

stereo = cuda.createStereoBM(
            numDisparities=numDisparities,
            blockSize=BlockSize
        )
    
    imgL_gpu = cv.cuda_GpuMat()
    imgR_gpu = cv.cuda_GpuMat()
    imgL_gpu.upload(imgL)
    imgR_gpu.upload(imgR)
    
    # Create a CUDA stream
    stream = cv2.cuda_Stream()
    
    disparity_gpu = stereo.compute(imgL_gpu, imgR_gpu, stream=stream)

    #print(f"disp dtype: {disparity_gpu.dtype}") #uint8
    disparity = disparity_gpu.download(stream=stream)

However my output disparity maps from this method looks very weird and wrong compared to the cpu-based version. It seems that the cuda version initially outputs the disparity in the uint8 data format, instead of the int16 that the cpu-version does. But no amount of datatype-transformation seems to fix the issue. (I’ve tried transforming to int16 and scaling up and down for example, normalizing and transforming to float32 before doing any mathematical operations on the output). Do you perhaps know what could be the issue? I initially thought it was due to some type of version mismatch between OpenCV and CuDNN/CUDA, which is why I started reinstalling with the latest commits instead of the 4.5 version of OpenCV I used before.

Thanks for all your time.

Here is the output of Cmake from the CMD (I made a new directory called build2_test for this)

-- General configuration for OpenCV 4.8.0-dev =====================================
--   Version control:               unknown
--
--   Extra modules:
--     Location (extra):            C:/OpenCV_Build_LatestCommit/opencv_contrib-4.x/modules
--     Version control (extra):     unknown
--
--   Platform:
--     Timestamp:                   2023-10-26T12:10:11Z
--     Host:                        Windows 10.0.19045 AMD64
--     CMake:                       3.28.0-rc2
--     CMake generator:             Ninja
--     CMake build tool:            C:/PROGRA~1/MIB055~1/2022/COMMUN~1/Common7/IDE/COMMON~1/MICROS~1/CMake/Ninja/ninja.exe
--     MSVC:                        1937
--     Configuration:               Release
--
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (18 files):         + SSSE3 SSE4_1
--       SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (9 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (38 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (8 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ standard:                11
--     C++ Compiler:                C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe  (ver 19.37.32825.0)
--     C++ flags (Release):         /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  /MD /O2 /Ob2 /DNDEBUG
--     C++ flags (Debug):           /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  /MDd /Zi /Ob0 /Od /RTC1
--     C Compiler:                  C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe
--     C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise /FS       /MD /O2 /Ob2 /DNDEBUG
--     C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise /FS     /MDd /Zi /Ob0 /Od /RTC1
--     Linker flags (Release):      /machine:x64  /INCREMENTAL:NO
--     Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          cudart_static.lib nppc.lib nppial.lib nppicc.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cudnn.lib cufft.lib -LIBPATH:"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/lib/x64"
--     3rdparty dependencies:
--
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode world xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    -
--     Disabled by dependency:      -
--     Unavailable:                 alphamat cvv freetype hdf java julia matlab ovis python2 python2 sfm viz
--     Applications:                tests perf_tests examples apps
--     Documentation:               NO
--     Non-free algorithms:         NO
--
--   Windows RT support:            NO
--
--   GUI:
--     Win32 UI:                    YES
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        build (ver 1.2.13)
--     JPEG:                        build-libjpeg-turbo (ver 2.1.3-62)
--       SIMD Support Request:      YES
--       SIMD Support:              NO
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         build (ver 1.6.37)
--     TIFF:                        build (ver 42 - 4.2.0)
--     JPEG 2000:                   build (ver 2.5.0)
--     OpenEXR:                     build (ver 2.3.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
--
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      YES (prebuilt binaries)
--       avcodec:                   YES (58.134.100)
--       avformat:                  YES (58.76.100)
--       avutil:                    YES (56.70.100)
--       swscale:                   YES (5.9.100)
--       avresample:                YES (4.0.0)
--     GStreamer:                   NO
--     DirectShow:                  YES
--     Media Foundation:            YES
--       DXVA:                      YES
--
--   Parallel framework:            Concurrency
--
--   Trace:                         YES (with Intel ITT)
--
--   Other third-party libraries:
--     Intel IPP:                   2021.8 [2021.8.0]
--            at:                   C:/OpenCV_Build_LatestCommit/build2_test/3rdparty/ippicv/ippicv_win/icv
--     Intel IPP IW:                sources (2021.8.0)
--               at:                C:/OpenCV_Build_LatestCommit/build2_test/3rdparty/ippicv/ippicv_win/iw
--     Lapack:                      NO
--     Eigen:                       NO
--     Custom HAL:                  NO
--     Protobuf:                    build (3.19.1)
--     Flatbuffers:                 builtin/3rdparty (23.5.9)
--
--   NVIDIA CUDA:                   YES (ver 12.2, CUFFT CUBLAS)
--     NVIDIA GPU arch:             86
--     NVIDIA PTX archs:            86
--
--   cuDNN:                         YES (ver 8.9.5)
--
--   OpenCL:                        YES (NVD3D11)
--     Include path:                C:/OpenCV_Build_LatestCommit/opencv-4.x/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
--
--   Python 3:
--     Interpreter:                 C:/ProgramData/anaconda3/python.exe (ver 3.11.5)
--     Libraries:                   C:/ProgramData/anaconda3/libs/python311.lib (ver 3.11.5)
--     numpy:                       C:/ProgramData/anaconda3/Lib/site-packages/numpy/core/include (ver 1.26.1)
--     install path:                C:/ProgramData/anaconda3/Lib/site-packages
--
--   Python (for build):            C:/ProgramData/anaconda3/python.exe
--
--   Java:
--     ant:                         NO
--     Java:                        NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
--
--   Install to:                    C:/OpenCV_Build_LatestCommit/build2_test/install

This is where the problem lies it should be

C:/ProgramData/anaconda3/Lib/site-packages/cv2/python-3.11