Building DNN module with cuDNN backend

asked 2020-05-20 12:04:19 -0500

rgov gravatar image

updated 2020-05-20 12:06:43 -0500

I am building OpenCV 4.3.0-dev with cuDNN support. My cuDNN version is the latest, 7.6.x. I pass these options to CMake:

    -DCUDNN_LIBRARY="$(pwd)/../../cudnn/lib64/" \
    -DCUDNN_INCLUDE_DIR="$(pwd)/../../cudnn/include" \
    -DCUDA_ARCH_BIN=7.0 \

And it seems to go OK:

--   NVIDIA CUDA:                   YES (ver 9.1, CUFFT CUBLAS)
--     NVIDIA GPU arch:             70
--     NVIDIA PTX archs:
--   cuDNN:                         YES (ver 7.6.4)

However when I try to use the CUDA backend to the DNN module:


I get the message "setUpNet DNN module was not built with CUDA backend; switching to CPU".

This GitHub issue suggests disabling CUDA architectures below 7.0 which is what I am doing. Is there something else I'm missing?

edit retag flag offensive close merge delete


According to this guide I should also pass -DOPENCV_DNN_CUDA=ON so I'm trying that now.

rgov gravatar imagergov ( 2020-05-20 12:08:30 -0500 )edit

Is it possible the error message is wrong and the problem is that your program can't load cudnn64_7.dll. I ask because you haven't installed cuDNN so its possible cudnn64_7.dll has not been added to your system/user path.

I have not had any issues building with cuDNN but I always install it into my CUDA directory and let CMake automatically find it as recommended described in the installation guide and item 6 of this guide which I use to successfully get the DNN backend to work without restricting the compute capability.

cudawarped gravatar imagecudawarped ( 2020-05-21 04:12:43 -0500 )edit

@rgov The issue linked in the post is outdated. All compute capabilities are now supported by the CUDA backend. The message you have got is decided at compile-time. The only way you can get that message is if the CUDA backend wasn't compiled at all.

Yashas gravatar imageYashas ( 2020-05-23 03:14:45 -0500 )edit