Building DNN module with cuDNN backend
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:
-DWITH_CUDNN=ON \
-DCUDNN_LIBRARY="$(pwd)/../../cudnn/lib64/libcudnn.so" \
-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:
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
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?
According to this guide I should also pass
-DOPENCV_DNN_CUDA=ON
so I'm trying that now.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 possiblecudnn64_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.
@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.