Ask Your Question
0

Building DNN module with cuDNN backend

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

rgov gravatar image

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

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?

edit retag flag offensive close merge delete

Comments

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 -0600 )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 -0600 )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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-12-05 19:00:05 -0600

i have the same problem with opencv 4.5.0, cuda 11.1 and cudnn 8.0.5

compile works without errors, cudnn and cuda are both found according to cmake output.

still backend CUDA does not work, always switches to CPU. I do not see any problem during compile. Is there any way to find out how DNN part of opencv was built?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-05-20 12:04:19 -0600

Seen: 9,802 times

Last updated: May 20 '20