Build opencv with cuda not working

I am following a tutorial to build opencv with cuda
everything worked well no errors found
but when I tried to check if it’s enabeled
typing this command


it shows 0
I installed cude toolkit 12.3 and CuDNN I set up paths
any suggestions

I’d say the title is probably misleading!

What does

this is the output that I got

`General configuration for OpenCV 4.6.0 =====================================
Version control: unknown

Extra modules:
Location (extra): C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/work/opencv_contrib-4.6.0/modules
Version control (extra): unknown

Timestamp: 2023-08-10T01:27:56Z
Host: Windows 10.0.17763 AMD64
CMake: 3.26.4
CMake generator: Ninja
CMake build tool: C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/_build_env/Library/bin/ninja.exe
MSVC: 1916
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 (16 files): + SSSE3 SSE4_1
SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (0 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (4 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (31 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2

Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe (ver 19.16.27050.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 /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 /MDd /Zi /Ob0 /Od /RTC1
C Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
Linker flags (Release): /machine:x64 /INCREMENTAL:NO
Linker flags (Debug): /machine:x64 /debug /INCREMENTAL
ccache: NO
Precompiled headers: NO
Extra dependencies:
3rdparty dependencies:

OpenCV modules:
To be built: alphamat aruco barcode bgsegm calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hdf 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 video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
Disabled: bioinspired world
Disabled by dependency: -
Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype java julia matlab ovis python2 sfm ts viz
Applications: apps
Documentation: NO
Non-free algorithms: NO

Windows RT support: NO


Media I/O:
ZLib: C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/_h_env/Library/lib/z.lib (ver 1.2.13)
JPEG: C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/_h_env/Library/lib/jpeg.lib (ver 90)
WEBP: C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/_h_env/Library/lib/libwebp.lib (ver encoder: 0x020f)
PNG: C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/_h_env/Library/lib/libpng.lib (ver 1.6.37)
TIFF: C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/_h_env/Library/lib/tiff.lib (ver 42 / 4.1.0)
OpenEXR: build (ver 2.3.0)

Video I/O:
GStreamer: YES (1.18.5)
DirectShow: YES
Media Foundation: YES

Parallel framework: Concurrency

Trace: YES (with Intel ITT)

Other third-party libraries:
Intel IPP: 2020.0.0 Gold [2020.0.0]
at: C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/work/build/3rdparty/ippicv/ippicv_win/icv
Intel IPP IW: NO
Eigen: YES (ver 3.3.7)
Custom HAL: NO
Protobuf: C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/_h_env/Library/lib/libprotobuf.lib (3.20.3)

Python 3:
Interpreter: C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/_h_env/python.exe (ver 3.11.4)
Libraries: C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/_h_env/libs/python311.lib (ver 3.11.4)
numpy: C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/_h_env/Lib/site-packages/numpy/core/include (ver 1.23.5)
install path: C:\b\abs_f8n1j3l9l0\croot\opencv-suite_1691622637237_h_env\Lib\site-packages

Python (for build): C:\b\abs_f8n1j3l9l0\croot\opencv-suite_1691622637237_h_env/python.exe

Install to: C:/b/abs_f8n1j3l9l0/croot/opencv-suite_1691622637237/_h_env/Library

You haven’t built with CUDA you should get output similar to the following

--   NVIDIA CUDA:                   YES (ver 12.3, CUFFT CUBLAS NVCUVID NVCUVENC)
--     NVIDIA GPU arch:             50 52 60 61 70 75 80 86 89 90
--     NVIDIA PTX archs:            90
--   cuDNN:                         YES (ver 8.9.5)

I recommend following the original guide I wrote which M. Haroon Shakeel (and probably every one else I have seen) took his “instructions” from

Whilst I can’t guarnatee the amount of tears you will encouner whilst reading it I can guarnatee I have at least tested the instructions in it multiple times to make sure they are accurate.

If you have any problems with the instructions or anything is unclear please let me know.

I think I am doing something wrong, I have everything installed in my computer
-visual studio 17 2022 with desktop developement with c++

  • opencv 4.8.0 and opencv contrib 4.8.0
  • cmake 3.28.1 for windows
    -cuda 12.3 and cudnn 8.9.2
    I copied like this

set CMAKE_BUILD_PARALLEL_LEVEL=8 "C:\Users\github\cmake-3.28.1-windows-x86_64\cmake-3.28.1-windows-x86_64\bin\cmake-gui.exe" -H"C:\Users\github\opencv-4.8.0\opencv-4.8.0" -DOPENCV_EXTRA_MODULES_PATH="C:\Users\github\opencv_contrib-4.8.0\opencv_contrib-4.8.0\modules" -B"C:\Users\github\build_" -G"Visual Studio 17 2022" -DINSTALL_TESTS=ON -DINSTALL_C_EXAMPLES=ON -DBUILD_EXAMPLES=ON -DBUILD_opencv_world=ON -DWITH_CUDA=ON -DCUDA_GENERATION=Auto -DBUILD_opencv_python3=ON -DPYTHON3_INCLUDE_DIR=C:\Users\anaconda3\include -DPYTHON3_LIBRARY=C:\Users\anaconda3\libs\python311.lib -DPYTHON3_EXECUTABLE="C:\Users\anaconda3\python.exe" -DPYTHON3_NUMPY_INCLUDE_DIRS="C:\Users\anaconda3\Lib\site-packages\numpy\core\include" -DPYTHON3_PACKAGES_PATH= "C:\Users\anaconda3\Lib\site-packages/"

I am executing it from the anaconda prompt when I hit enter nothing happened

You are trying to use the GUI (cmake-gui.exe), the guide uses cmake.exe.

I am sorry for bothering you but for some reason I think I am doing something wrong
because I am working with python via anaconda
I created a new environment with anaconda after building the opencv with cmake I tried to see if its successfully installed with spyder but it says opencv is not installed.Any suggestions
how can I build it with cuda enabeled inside the environment I am working on ?

OpenCV will be installed to the environment you gave it at CMake configuration time. From your previous settings

this will be to your main environment not the new one you created after configuring it.

Additionaly OpenCV it won’t show as installed in pip , conda etc. as the bindings have been installed by CMake. The bindings in the case of your previous commands will be inside *C:\Users\anaconda3\Lib\site-packages\cv2* and as long as you built a Release version you will be able to access OpenCV by calling import cv2 from that environment.

I got it now thank you

1 Like