opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
75.95k stars 55.62k forks source link

Could NOT find CUDNN (missing: CUDNN_LIBRARY CUDNN_INCLUDE_DIR) #16380

Closed brian208579 closed 4 years ago

brian208579 commented 4 years ago

OS: win10 ( 64bits ) Cuda : 10.2 Cudnn : 7.6.5 Opencv: github latest

When I use cmake-gui I get this information :

Could NOT find CUDNN (missing: CUDNN_LIBRARY CUDNN_INCLUDE_DIR) (Required is at least version "7.5") cudnn_problem_1

and

cuDNN : NO cudnn_problem_2

But I have installed it in the c: / path please give me some suggestions , thx ...

BadMachine commented 4 years ago

@brian208579 i guess it just because you didn`t install cudnn) cudnn download link Cheers!

brian208579 commented 4 years ago

@BadMachine

Thanks for your response

But I already have it installed and put it in c: /

cudnn

Can manually specify the path for cmake to find cudnn ?

BadMachine commented 4 years ago

@brian208579 Wrong! You should place it in the same folder that CUDA installed. E.g. "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\ "

brian208579 commented 4 years ago

@BadMachine

Sorry , it doesn't work ... When I configure I got the same result

cudnn_1

BadMachine commented 4 years ago

@brian208579 you didn't get me. Now in CUDNN folder you have (include, lib, bin). At the same time in .../CUDA/v10.2/ u have the same folders. Now you should paste (lib, bin, include) from CUDNN to .../CUDA/v10.2/

brian208579 commented 4 years ago

@BadMachine Unfortunately ... It still doesn’t work

BadMachine commented 4 years ago

you can mail me teamviewer and I will try to help , otherwise I can’t help if I don’t see what is happening

brian208579 commented 4 years ago

@BadMachine I already mail, please check it , thank you.

brian208579 commented 4 years ago

Problem has been solved !!! thx for @BadMachine

haquocviet commented 4 years ago

Problem has been solved !!! thx for @BadMachine

I got the same issue. Could you share the solution you have to me and other people?

BadMachine commented 4 years ago

@haquocviet First of all make sure u are using release version OpenCV. Then make sure that cudnn folders with files merged with cuda folders: copy 3 folders from cudnn to cuda folder.

haquocviet commented 4 years ago

I am using OpenCV 4.2.0 release. I checked the path again and found nothing abnormal, result is same as before. CDNN-folder

General configuration for OpenCV 4.2.0 =====================================
  Version control:               4.2.0

NVIDIA CUDA:                   YES (ver 10.2, CUFFT CUBLAS)
    NVIDIA GPU arch:             75
    NVIDIA PTX archs:
  cuDNN:                         NO
BadMachine commented 4 years ago

@haquocviet I said cudnn folders, not cudnn folder as is. If u don’t understand “merge” meaning: Copy content from cudnn include dir to cuda include dir, same for lib dir, etc.

haquocviet commented 4 years ago

Thanks for your explanation. That way of course will work but it seems not relate to the issue Could NOT find CUDNN (missing: CUDNN_LIBRARY CUDNN_INCLUDE_DIR) (Required is at least version "7.5") CUDNN_LIBRARY and CUDNN_INCLUDE_DIR should point to folders of cuDNN somewhere separately instead in same place as CUDA's.

BadMachine commented 4 years ago

@haquocviet ok, gimme treamviewer -_-

haquocviet commented 4 years ago

Thanks. I solved the issue. No need to merge cudnn's files into CUDA folders. I modified CMakeCache.txt directly to change vars below.

CUDNN_INCLUDE_DIR:FILEPATH=D:/.../cudnn-7.5.6/include
CUDNN_LIBRARY:FILEPATH=D:/.../cudnn-7.5.6/lib/cudnn.lib
solarflarefx commented 4 years ago

@haquocviet how did you go about setting this? I downloaded cudnn and put the files in the proper directories. I even ensured the paths are in the environment variables. However, I still get an error saying cudnn was not detected. I tried following the instructions on here: https://jamesbowley.co.uk/accelerate-opencv-4-2-0-build-with-cuda-and-python-bindings/

haquocviet commented 4 years ago

First, you need to generate CMakeCache.txt file via either cmake cmdline or gui. Then you replace the vars in the file with your real paths of DNN. Finally you do "configure" again to complete the job. Note that, this is only a temporary way to workaround the issue which the next version of opencv should fix it.

cudawarped commented 4 years ago

@haquocviet how did you go about setting this? I downloaded cudnn and put the files in the proper directories. I even ensured the paths are in the environment variables. However, I still get an error saying cudnn was not detected. I tried following the instructions on here: https://jamesbowley.co.uk/accelerate-opencv-4-2-0-build-with-cuda-and-python-bindings/

Just to confirm when you type the following into cmd

where cudnn64_7.dll

you get the below path?

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin\cudnn64_7.dll

solarflarefx commented 4 years ago

Thanks for the reply. I should have mentioned that I am using CUDA 10.1.

Below is what I used for the command line:

set "openCvSource=C:\opencv_build\opencv" set "openCVExtraModules=C:\opencv_build\opencv_contrib\modules" set "openCvBuild=%openCvSource%\build" set "buildType=Debug" set "generator=Visual Studio 16 2019"

"C:\Program Files\CMake\bin\cmake.exe" -B"%openCvBuild%/" -H"%openCvSource%/" -G"%generator%" -DCMAKE_BUILD_TYPE=%buildType% -DOPENCV_EXTRA_MODULES_PATH="%openCVExtraModules%/" ^ -DINSTALL_TESTS=ON -DINSTALL_C_EXAMPLES=ON -DBUILD_EXAMPLES=ON ^ -DBUILD_opencv_world=ON ^ -DWITH_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1" -DCUDA_FAST_MATH=ON -DWITH_CUBLAS=ON -DCUDA_ARCH_BIN=5.3,6.0,6.1,7.0,7.5 -DCUDA_ARCH_PTX=7.5 -DWITH_NVCUVID=ON ^ -DWITH_OPENGL=ON ^ -DWITH_MFX=ON

If I type "where cudnn64_7.dll" in command line, I get: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin\cudnn64_7.dll C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin\cudnn64_7.dll C:\libtorch-win-shared-with-deps-debug-1.4.0\libtorch\lib\cudnn64_7.dll

Also I wanted to confirm another thing -- after doing the build I should be able to reference the .dll and .lib files and use them in a Visual C++ project? I tried to do so but when I used a GpuMat structure, I got an error saying that OpenCV was not built with CUDA, which is a bit confusing.

I looked at the existing CMakeCache.txt file, which says: //Include NVidia Cuda Runtime support WITH_CUDA:BOOL=ON

//List of extra modules OPENCV_MODULES_EXTRA:INTERNAL=aruco;bgsegm;bioinspired;ccalib;cnn_3dobj;cudaarithm;cudabgsegm;cudacodec;cudafeatures2d;cudafilters;cudaimgproc;cudalegacy;cudaobjdetect;cudaoptflow;cudastereo;cudawarping;cudev;cvv;datasets;dnn_objdetect;dnn_superres;dpm;face;freetype;fuzzy;hdf;hfs;img_hash;intensity_transform;java_bindings_generator;line_descriptor;matlab;optflow;ovis;phase_unwrapping;plot;python2;python3;python_bindings_generator;python_tests;quality;rapid;reg;rgbd;saliency;sfm;shape;stereo;structured_light;superres;surface_matching;text;tracking;videostab;viz;xfeatures2d;ximgproc;xobjdetect;xphoto //List of main modules OPENCV_MODULES_MAIN:INTERNAL=core;imgproc;imgcodecs;videoio;highgui;video;calib3d;features2d;objdetect;dnn;ml;flann;photo;stitching;gapi;java;js;ts;world //List of OpenCV modules marked for export OPENCV_MODULES_PUBLIC:INTERNAL=opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio;opencv_world;opencv_aruco;opencv_bgsegm;opencv_bioinspired;opencv_ccalib;opencv_cudaarithm;opencv_cudabgsegm;opencv_cudacodec;opencv_cudafeatures2d;opencv_cudafilters;opencv_cudaimgproc;opencv_cudalegacy;opencv_cudaobjdetect;opencv_cudaoptflow;opencv_cudastereo;opencv_cudawarping;opencv_cudev;opencv_datasets;opencv_dnn_objdetect;opencv_dnn_superres;opencv_dpm;opencv_face;opencv_fuzzy;opencv_hfs;opencv_img_hash;opencv_intensity_transform;opencv_line_descriptor;opencv_optflow;opencv_phase_unwrapping;opencv_plot;opencv_quality;opencv_rapid;opencv_reg;opencv_rgbd;opencv_saliency;opencv_shape;opencv_stereo;opencv_structured_light;opencv_superres;opencv_surface_matching;opencv_text;opencv_tracking;opencv_videostab;opencv_xfeatures2d;opencv_ximgproc;opencv_xobjdetect;opencv_xphoto

It seems that the build was set up to build with CUDA but my results show otherwise.

cudawarped commented 4 years ago

Can you post the output to the below please

C:\opencv_build\opencv\build\bin\opencv_version_win32d.exe

or if you built release

C:\opencv_build\opencv\build\bin\opencv_version_win32.exe

What size is your shared library?

C:\opencv_build\opencv\build\bin\opencv_world420d.dll

Do you have either

C:\opencv_build\opencv\build\bin\opencv_perf_cudaarithmd.exe

or

C:\opencv_build\opencv\build\bin\opencv_perf_cudaarithm.exe

if so do some of the tests pass?

solarflarefx commented 4 years ago
Regarding running opencv_version_win32d.exe: ![Q1_1](https://user-images.githubusercontent.com/45402633/75297828-da0fce00-57fe-11ea-8b89-1f3fdf89ebc8.PNG) ![Q1_2](https://user-images.githubusercontent.com/45402633/75297829-daa86480-57fe-11ea-9d30-2b2b0d16c33a.PNG) ![Q1_3](https://user-images.githubusercontent.com/45402633/75297830-daa86480-57fe-11ea-9fc2-c46c433549e8.PNG) ![Q1_4](https://user-images.githubusercontent.com/45402633/75297832-db40fb00-57fe-11ea-9c39-bccbd8b80dfb.PNG) Size of "Debug" folder within C:\opencv_build\opencv\build\bin is: 6.40 GB I do have C:\opencv_build\opencv\build\bin\Debug\cudaarithmd.exe Results: ![Cuda_Arithmd_1](https://user-images.githubusercontent.com/45402633/75298217-e6485b00-57ff-11ea-8a5e-538148a74e8e.PNG) ![Cuda_Arithmd_2](https://user-images.githubusercontent.com/45402633/75298218-e6e0f180-57ff-11ea-82c6-64e32394e38c.PNG) ![Cuda_Arithmd_3](https://user-images.githubusercontent.com/45402633/75298219-e6e0f180-57ff-11ea-8802-6b8564e095e2.PNG)
alalek commented 4 years ago

Avoid posting screenshots with text information - it is ridiculous.

CMakeCache.txt

Check contents of CMakeVars.txt for CUDA / CUDNN stuff too.

If you make experiments with dependencies, then you should clean CMake cache before each run.

(May not work) Partial cache cleanup is possible:

cudawarped commented 4 years ago

The output implies you have managed to finish the build of OpenCV with CUDA support, my guess would by as alalek has suggested, you probably ran cmake initialy before you had placed cudnn64_7.dll on your path (or you placed it on your system path without a restart or your user path without opening a new command prompt or similar).

Regarding the error you mentioned in another thread

Perhaps I do not need cudnn for the GpuMat use, but when I used the .dll and .lib files, Visual Studio gave an error saying they were not built with CUDA support

I can only think that you are not picking up the correct .dll at runtime as the results of running

C:\opencv_build\opencv\build\bin\opencv_perf_cudaarithmd.exe

show that you can successfully build and run an application against

C:\opencv_build\opencv\build\bin\opencv_world420d.dll

compiled with CUDA support.

solarflarefx commented 4 years ago

Thanks for the help and guidance.

I apologize for the screenshots on the text information -- I will copy and paste text for this kind of information.

Regarding not having restarted or opened a new command prompt, I had actually done both and it seems that cudnn still does not show up.

As for debugging the GpuMat error, I looked at my configuration for Visual Studio and it is the following:

VC++ Directories

Include Directories: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include;C:\opencv_build\opencv\build\install\include;$(IncludePath)

Library Directories: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\lib\x64;C:\opencv_build\opencv\build\lib\Debug;$(LibraryPath)


C/C++

Additional Include Directories: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include


Linker:

Additional library directories: C:\opencv_build\opencv\build\lib\Debug;


Additional Dependencies:

opencv_world420d.lib;%(AdditionalDependencies)


My code is pretty simple: `

include <opencv2/core/core.hpp>

include <opencv2/highgui/highgui.hpp>

include <opencv2/imgproc.hpp>

include

include <opencv2/cudaarithm.hpp>

using namespace cv; using namespace std;

int main() { Mat image = Mat::zeros(300, 600, CV_8UC1); cv::cuda::GpuMat gpu_image(image); circle(image, Point(250, 150), 100, Scalar(0, 255, 128), -100); circle(image, Point(350, 150), 100, Scalar(255, 255, 255), -100); imshow("Display Window", image); waitKey(0); return 0; } `

I get the following error: OpenCV(4.2.0) Error: No CUDA support (The library is compiled without CUDA support) in throw_no_cuda, file C:\build\master_winpack-build-win64-vc15\opencv\modules\core\include\opencv2/core/private.cuda.hpp, line 109

My guess is I am referencing the wrong files in the configuration? My point of confusion is that I see multiple files of the same name on the C:\opencv_build directory and am not 100% sure which ones are the "correct" ones.

As I reference guide, I used this link: https://medium.com/@subwaymatch/adding-opencv-4-2-0-to-visual-studio-2019-project-in-windows-using-pre-built-binaries-93a851ed6141

However, instead of using the prebuilt binaries I used the ones I built.

cudawarped commented 4 years ago

Regarding not having restarted or opened a new command prompt, I had actually done both and it seems that cudnn still does not show up.

Did you as alalek suggested clean the cache or even better delete or use a fresh build directory?

OpenCV(4.2.0) Error: No CUDA support (The library is compiled without CUDA support) in throw_no_cuda, file C:\build\master_winpack-build-win64-vc15\opencv\modules\core\include\opencv2/core/private.cuda.hpp, line 109

I assume you are seeing this error when running your program?

If so check the location reported by

where opencv_world420d.dll

is only

C:\opencv_build\opencv\build\bin\Debug\opencv_world420d.dll

If you are using visual studio you should be able to see this location in the modules window when debugging your program.

Additionally if you have built with Visual Studio, you have a multiple working projects you can study (opencv_test_cudaarithm etc.) when the solution is open to get build options which work.

solarflarefx commented 4 years ago

Hello,

So I took a look at some of the Visual Studio solution files and it seems that whenever I try to build and compile them, it seems to be building everything from source again to run an executable.

Perhaps my understanding is wrong, but one of my goals was to build OpenCV with CUDA and then use the .dll and .lib files to create my own Visual Studio C++ project. I did not see any of the Visual Studio solution examples doing that. As I mentioned, when I tried to include the .dll and .lib files and then tried to run my code in Debug mode, I got an error saying that OpenCV was not built with CUDA.

Is my understanding and approach incorrect? Thanks for all the help thus far.

cudawarped commented 4 years ago

You can select this project only and then build to avoid building the whole solution. Please check which .dll is loaded in the module windows when debugging and/or by using the where command I mentioned above , or just copy

C:\opencv_build\opencv\build\bin\opencv_world420d.dll

to your build directory to force the correct .dll to be used.

solarflarefx commented 4 years ago

So I notice I do not have any .lib or .dll files in the directory: C:\opencv_build\opencv\build\bin

I have a "Debug" and "Release" directory in there though. In the "Debug" directory I have .pdb, .ilk, and .exe files. No .dll or .lib files however. Am I in the wrong directory, or did something go wrong in my build process?

I do have a "bin" and "lib" folder in: C:\opencv_build\opencv\build\install\x64\vc16

In that directory, the "bin" folder contains: opencv_img_hash420d.dll, opencv_videoio_ffmpeg420_64.dll, and opencv_world420d.dll.

The "lib" folder contains: opencv_img_hash420d.lib, opencv_world420d.lib

manan-d8 commented 4 years ago

If Anyone Doing this on Windows try deleting cache from build folder in cmake or change build folder...!

Adriann2k commented 3 years ago

Anyone being able to help me with this? @BadMachine or @haquocviet

I've been trying 10 hours to install this, and i am still failing. I am really desperate. Please, help me.

Thanks!

cudawarped commented 3 years ago

@Adriann2k What is your exact issue? Is it just that you are not picking up cuDnn when running cmake or that you are failing to compile OpenCv with CUDA, can you post your errors?

Adriann2k commented 3 years ago

i managed to fix it by downgrading python from 3.7 to 3.6

Adriann2k commented 3 years ago

thanks anyways :)

HduSy commented 3 years ago

Problem has been solved !!! thx for @BadMachine

I still haven't solved this problem,i copy the include\lib to the target dir:usr/local/cuda/include and lib,but it didn't work my cuda is 10.0 cudnn is v7.5 for cuda10.0

HduSy commented 3 years ago

Actually you can also solve by cmake add this -D CUDNN_INCLUDE_DIR="your cudnn include path" -D CUDNN_LIBRARY="your cudnn lib path"

bigntallmike commented 3 years ago

Actually you can also solve by cmake add this -D CUDNN_INCLUDE_DIR="your cudnn include path" -D CUDNN_LIBRARY="your cudnn lib path"

This is what I did to solve it as well. In my case:

    -D CUDNN_INCLUDE_DIR=/usr/include \
    -D CUDNN_LIBRARY=/usr/lib64/libcudnn_static_v7.a \
    -D CUDNN_VERSION=7.6.5 \
nhorton04 commented 3 years ago

-D CUDNN_INCLUDE_DIR="your cudnn include path" -D CUDNN_LIBRARY="your cudnn lib path" I tried adding these to cmake-gui and it still didn't see CUDNN. I also copied the contents of cudnn/include and lib64 to cuda/include and lib64

@BadMachine can you please help me?

edit:

Detected processor: x86_64
Looking for ccache - not found
Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.11", minimum required is "1.2.3") 
Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1)
Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR) 
Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
Found OpenEXR: /usr/lib/x86_64-linux-gnu/libIlmImf.so
CMake Warning (dev) at /snap/cmake/549/share/cmake-3.18/Modules/FindOpenGL.cmake:305 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  cmake/OpenCVFindLibsGUI.cmake:76 (find_package)
  CMakeLists.txt:686 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

Found TBB (cmake): /usr/lib/x86_64-linux-gnu/libtbb.so.2
found Intel IPP (ICV version): 2020.0.0 [2020.0.0 Gold]
at: /home/nick/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
found Intel IPP Integration Wrappers sources: 2020.0.0
at: /home/nick/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
Could NOT find CUDNN (missing: CUDNN_LIBRARY CUDNN_INCLUDE_DIR) (found suitable version "8.0.2", minimum required is "7.5")
CUDA detected: 10.1
CUDA: Using CUDA_ARCH_BIN=7.5
CUDA NVCC target flags: -gencode;arch=compute_75,code=sm_75;-D_FORCE_INLINES;-gencode;arch=compute_75,code=compute_75
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR) 
A library with LAPACK API found.
Could NOT find JNI (missing: 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: /home/nick/opencv/build/python_loader
Processing WORLD modules...
    module opencv_cudev...
    module opencv_core...
Allocator metrics storage type: 'long long'
    module opencv_flann...
    module opencv_imgproc...
    module opencv_ml...
    module opencv_photo...
    module opencv_dnn...
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/nick/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
opencv_dnn: filter out cuda4dnn source code
    module opencv_features2d...
    module opencv_imgcodecs...
    module opencv_videoio...
    module opencv_calib3d...
    module opencv_highgui...
    module opencv_objdetect...
    module opencv_stitching...
    module opencv_video...
    module opencv_gapi...
Processing WORLD modules... DONE
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 

General configuration for OpenCV 4.4.0-dev =====================================
  Version control:               4.4.0-146-g458bd1652d

  Platform:
    Timestamp:                   2020-08-25T03:22:52Z
    Host:                        Linux 5.4.0-42-generic x86_64
    CMake:                       3.18.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Debug

  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 (17 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 (31 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (7 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:                /usr/bin/c++  (ver 9.3.0)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG -g1
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG -g1
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed  
    Linker flags (Debug):        -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed  
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:          m pthread /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so cudart_static dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/lib/x86_64-linux-gnu
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 calib3d core cudev dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo stitching ts video videoio world
    Disabled:                    -
    Disabled by dependency:      -
    Unavailable:                 java js python2 python3
    Applications:                tests perf_tests examples apps
    Documentation:               NO
    Non-free algorithms:         NO

  GUI: 
    QT:                          YES (ver 5.9.7)
      QT OpenGL support:         YES (Qt5::OpenGL 5.9.7)
    GTK+:                        NO
    OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so)
    VTK support:                 NO

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
    WEBP:                        build (ver encoder: 0x020f)
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.1.0)
    JPEG 2000:                   build Jasper (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2_3)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:
    DC1394:                      YES (2.2.5)
    FFMPEG:                      YES
      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:                   YES (1.16.2)
    v4l/v4l2:                    YES (linux/videodev2.h)
    Xine:                        NO

  Parallel framework:            TBB (ver 2020.1 interface 11101)

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP:                   2020.0.0 Gold [2020.0.0]
           at:                   /home/nick/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
    Intel IPP IW:                sources (2020.0.0)
              at:                /home/nick/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  NVIDIA CUDA:                   YES (ver 10.1, CUFFT CUBLAS FAST_MATH)
    NVIDIA GPU arch:             75
    NVIDIA PTX archs:            75

  cuDNN:                         NO

  Vulkan:                        YES
    Include path:                /home/nick/opencv/3rdparty/include
    Link libraries:              Dynamic load

  OpenCL:                        YES (no extra features)
    Include path:                /home/nick/opencv/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python (for build):            /home/nick/anaconda3/envs/tflow1/bin/python3

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

  Install to:                    /usr/local
-----------------------------------------------------------------

Configuring done

I can't figure it out... every time I include CUDNN_LIBRARY and CUDNN_INCLUDE_DIR and their paths (/usr/local/cuda/include + /usr/local/cuda/lib64), it gives me the same as above, except this part where it says missing cudnn_library, not also missing cudnn_include_dir:

Could NOT find CUDNN (missing: CUDNN_LIBRARY) (found suitable version "8.0.2", minimum required is "7.5")
CUDA detected: 10.1
CUDA: Using CUDA_ARCH_BIN=7.5

Do you know how I fix this?

edit2: looks like its actually the exact same thing as OP's pic

taf2 commented 3 years ago

@nhorton04

I got this working for me by doing the following:

sudo apt install libcudnn7-dev  libcudnn7-doc  libcudnn7 nvidia-container-csv-cudnn

Checked to see which version of cudnn it installed, for me it's 7.6.3

 -D CUDNN_INCLUDE_DIR=/usr/include \
-D CUDNN_LIBRARY=/usr/lib64/libcudnn_static_v7.a \
-D CUDNN_VERSION=7.6.3

hope this helps!

rickymedrano commented 3 years ago

@nhorton04 I was getting the same errors as you. I fixed it by including this in the cmake command: -D CUDNN_INCLUDE_DIR=/usr/lib/cuda/include \ -D CUDNN_LIBRARY=/usr/local/cuda-10.2/lib64/libcudnn.so.7 \ -D CUDNN_VERSION=7.6.5 \ Note your libcuddn.so.7 file could be in cuda, cuda-10.1 or cuda-10.2 so adjust the path accordingly above. I did also have to copy all the cublas related files in cuda-10.2/lib64 to cuda-10.1/lib64 and cuda/lib64 or else cmake was erroring out and wouldn't create a make file.

NuwanMadhusanka0417 commented 3 years ago

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_ENABLE_NONFREE=ON -D WITH_CUDA=ON -D WITH_CUDNN=ON -D OPENCV_DNN_CUDA=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D CUDA_ARCH_BIN=6.1 -D WITH_CUBLAS=1 -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules -D HAVE_opencv_python3=ON -D PYTHON_EXECUTABLE=~/env/bin/python -D BUILD_EXAMPLES=ON -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.0 -D CUDNN_INCLUDE_DIR=/usr/include -DCUDNN_LIBRARY=/usr/local/cuda/lib64/libcudnn.so.8 -D CUDNN_VERSION=8.0.3.33 ..

This is work for me.. Thank you all

SkpC9 commented 3 years ago

I am using windows with cuda10.1 and cudnn7.6.5. For anyone who gets the same error, I added C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\lib\Win32 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\lib\x64 to System PATH, then Cmake can find CUDNN.

asimukaye commented 3 years ago

Hi, I was facing a similar issue and none of the above fixes worked for me. I was using OpenCV 4.2.0 with CUDA 10.2 and CUDNN 8.2. After several attempts, I figured that the FindCUDNN.cmake in OpenCV cmake folder was looking for the version of CUDNN in "cudnn.h" whereas CUDNN 8.2 has the version in "cudnn_version.h". So I replaced the name in FindCUDNN.cmake and it worked finally.

P.S : clear all the cmake cache before trying again

tellamon commented 2 years ago

I had this problem too.

I am using windows 10 with cuda10.1, cudnn8.0.5.39

My solution :

  1. I merged cudnn files to CUDA folder (C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1).
  2. I removed the unnecessary PATH. (no need to add CUDNN_LIBRARY nor CUDNN_INCLUDE_DIR) and also removed Anaconda path. (I found that anaconda had cudnn dll with different version)
  3. Reboot.
  4. I just cleaned up CMake build folder and re-configure several times with CUDA option enabled.
  5. cmake configure works! ( cuDNN : YES (ver 8.0.5))