If you are trying to run DNN in OpenCV and unfortunately get such an error message:
[ WARN:0] global C:\OpenCV\OpenCV4.2.0\opencv-4.2.0\modules\dnn\src\dnn.cpp (1363) cv::dnn::dnn4_v20191202::Net::Impl::setUpNet DNN module was not built with CUDA backend; switching to CPU
This means you don’t have a compatible environment for running a cuDNN based application.
In this tutorial you will learn how to build OpenCV4.2.0 and all stuffs you have to notice.
After that you can easily use the following two commands without any errors.
net.setPreferableBackend(DNN_BACKEND_CUDA);
net.setPreferableTarget(DNN_TARGET_CUDA);
Note: Two different results as shown below (On Windows 10)
OpenCV 4.2.0 with Contrib + CUDA 10.2 + cuDNN 7.6.5 => FAILED
OpenCV 4.2.0 with Contrib + CUDA 10.0 + cuDNN 7.6.5 => SUCCESSFUL
Download Cuda Toolkit 10.0
Download cuDNN 7.6.5
Download Nvidia driver
445.75-desktop-win10-64bit-international-dch-whql
Click <Configuration>
Click <Configuration>
Click <Generate>
Click <Open Project>
--------------------------------------------------------------------------------------------------------------------------------
Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.18362.
Detected processor: AMD64
Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.7")
Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "3.2")
libjpeg-turbo: VERSION = 2.0.2, BUILD = opencv-4.2.0-libjpeg-turbo
found Intel IPP (ICV version): 2019.0.0 [2019.0.0 Gold]
at: C:/OpenCV/OpenCV4.2.0/build/3rdparty/ippicv/ippicv_win/icv
found Intel IPP Integration Wrappers sources: 2019.0.0
at: C:/OpenCV/OpenCV4.2.0/build/3rdparty/ippicv/ippicv_win/iw
CUDA detected: 10.2
CUDA NVCC target flags: -gencode;arch=compute_75,code=sm_75;-D_FORCE_INLINES
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find BLAS (missing: BLAS_LIBRARIES)
LAPACK requires BLAS
A library with LAPACK API not found. Please specify library location.
Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
OpenCV Python: during development append to PYTHONPATH: C:/OpenCV/OpenCV4.2.0/build/python_loader
Caffe: NO
Protobuf: NO
Glog: NO
freetype2: NO
harfbuzz: NO
Module opencv_ovis disabled because OGRE3D was not found
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
Tesseract: NO
Processing WORLD modules...
module opencv_cudev...
module opencv_core...
module opencv_cudaarithm...
module opencv_flann...
module opencv_imgproc...
module opencv_ml...
module opencv_phase_unwrapping...
module opencv_plot...
module opencv_quality...
module opencv_reg...
module opencv_surface_matching...
module opencv_cudafilters...
module opencv_cudaimgproc...
module opencv_cudawarping...
module opencv_dnn...
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': C:/OpenCV/OpenCV4.2.0/opencv-4.2.0/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
opencv_dnn: filter out cuda4dnn source code
module opencv_features2d...
module opencv_fuzzy...
module opencv_hfs...
module opencv_imgcodecs...
module opencv_line_descriptor...
module opencv_photo...
module opencv_saliency...
module opencv_text...
module opencv_videoio...
module opencv_xphoto...
module opencv_calib3d...
module opencv_cudacodec...
module opencv_cudafeatures2d...
module opencv_cudastereo...
module opencv_datasets...
module opencv_dnn_superres...
module opencv_highgui...
module opencv_objdetect...
module opencv_rgbd...
module opencv_shape...
module opencv_structured_light...
module opencv_video...
module opencv_xfeatures2d...
module opencv_ximgproc...
module opencv_xobjdetect...
module opencv_aruco...
module opencv_bgsegm...
module opencv_bioinspired...
module opencv_ccalib...
module opencv_cudabgsegm...
module opencv_cudalegacy...
module opencv_cudaobjdetect...
module opencv_dnn_objdetect...
module opencv_dpm...
module opencv_face...
module opencv_optflow...
module opencv_stitching...
module opencv_tracking...
module opencv_cudaoptflow...
module opencv_stereo...
module opencv_superres...
module opencv_videostab...
Processing WORLD modules... DONE
General configuration for OpenCV 4.2.0 =====================================
Version control: unknown
Extra modules:
Location (extra): C:/OpenCV/OpenCV4.2.0/opencv_contrib-4.2.0/modules
Version control (extra): unknown
Platform:
Timestamp: 2020-03-24T07:45:36Z
Host: Windows 10.0.18362 AMD64
CMake: 3.17.0
CMake generator: Visual Studio 15 2017
CMake build tool: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe
MSVC: 1916
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 (15 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 (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (28 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (6 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++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe (ver 19.16.27038.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 /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP8 /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 /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP8 /MDd /Zi /Ob0 /Od /RTC1
C Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/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 /MP8 /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 /MP8 /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: opengl32 glu32 cudart_static.lib nppc.lib nppial.lib nppicc.lib nppicom.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/v10.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 hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot quality reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab world xfeatures2d ximgproc xobjdetect xphoto
Disabled: gapi
Disabled by dependency: -
Unavailable: cnn_3dobj cvv freetype hdf java js matlab ovis python2 python3 sfm viz
Applications: tests perf_tests examples apps
Documentation: NO
Non-free algorithms: NO
Windows RT support: NO
GUI:
Win32 UI: YES
OpenGL support: YES (opengl32 glu32)
VTK support: NO
Media I/O:
ZLib: build (ver 1.2.11)
JPEG: build-libjpeg-turbo (ver 2.0.2-62)
WEBP: build (ver encoder: 0x020e)
PNG: build (ver 1.6.37)
TIFF: build (ver 42 - 4.0.10)
JPEG 2000: build (ver 1.900.1)
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.54.100)
avformat: YES (58.29.100)
avutil: YES (56.31.100)
swscale: YES (5.5.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: 2019.0.0 Gold [2019.0.0]
at: C:/OpenCV/OpenCV4.2.0/build/3rdparty/ippicv/ippicv_win/icv
Intel IPP IW: sources (2019.0.0)
at: C:/OpenCV/OpenCV4.2.0/build/3rdparty/ippicv/ippicv_win/iw
Lapack: NO
Eigen: NO
Custom HAL: NO
Protobuf: build (3.5.1)
NVIDIA CUDA: YES (ver 10.2, CUFFT CUBLAS FAST_MATH)
NVIDIA GPU arch: 75
NVIDIA PTX archs:
cuDNN: YES (ver 7.6.5)
OpenCL: YES (NVD3D11)
Include path: C:/OpenCV/OpenCV4.2.0/opencv-4.2.0/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python (for build): NO
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: C:/OpenCV/OpenCV4.2.0/build/install
-----------------------------------------------------------------
Commandline options:
-DINSTALL_C_EXAMPLES:BOOL="1" -DINSTALL_TESTS:BOOL="1" -DCUDA_FAST_MATH:BOOL="1" -DBUILD_opencv_gapi:BOOL="0" -DBUILD_EXAMPLES:BOOL="1" -DWITH_CUDA:BOOL="1" -DCUDA_ARCH_BIN:STRING="7.5" -DCUDA_GENERATION:STRING="Auto" -DWITH_OPENGL:BOOL="1" -DBUILD_opencv_world:BOOL="1" -DOPENCV_EXTRA_MODULES_PATH:PATH="C:/OpenCV/OpenCV4.2.0/opencv_contrib-4.2.0/modules"
-----------------------------------------------------------------
ASUS FX505DU-0091A3750H 魂動金 詳細規格表
--------------------------------------------
My new note book and it’s specification is shown below:
--------------------------------------------
LCD尺寸: 15.6'(薄邊框)/FHD 1920x1080 16:9/120Hz/IPS-level/250nits/Anti glare
CPU:AMD Ryzen 7-3750H Processor 2.3GHz (6M cache, up to 4.0GHz)
顯示晶片:NVIDIA GeForce GTX 1660Ti GDDR5 6GB獨顯
記憶體(內建/最大): DDR4 2400 8GB
HDD硬碟: PCIE NVME 512G M.2 SSD
光碟機: 無
作業系統:64 Bits Windows 10 Home
重量:2.2 Kg
留言列表