Building Opencv with Cuda and cudnn: setupnet dnn module was not built with cuda backend; switching to cpu. JETSON TX2

Hi,
i’m trying to run a python script based on yolov3 on GPU of my Jetson Tx2.
I get this error:
opencv /modules/dnn/src/dnn.cpp (1363) setupnet dnn module was not built with cuda backend; switching to cpu
Following some forum developers answear i started to re-build opencv with:
cmake -D CMAKE_BUILD_TYPE=RELEASE
-D CMAKE_INSTALL_PREFIX=/usr
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules
-D EIGEN_INCLUDE_PATH=/usr/include/eigen3
-D WITH_OPENCL=OFF
-D WITH_CUDA=ON
-D CUDA_ARCH_BIN=6.2
-D CUDA_ARCH_PTX=“”
-D WITH_CUDNN=ON
-D WITH_CUBLAS=ON
-D ENABLE_FAST_MATH=ON
-D CUDA_FAST_MATH=ON
-D OPENCV_DNN_CUDA=ON
-D ENABLE_NEON=ON
-D WITH_QT=OFF
-D WITH_OPENMP=ON
-D WITH_OPENGL=ON
-D BUILD_TIFF=ON
-D WITH_FFMPEG=ON
-D WITH_GSTREAMER=ON
-D WITH_TBB=ON
-D BUILD_TBB=ON
-D BUILD_TESTS=OFF
-D WITH_EIGEN=ON
-D WITH_V4L=ON
-D WITH_LIBV4L=ON
-D OPENCV_ENABLE_NONFREE=ON
-D INSTALL_C_EXAMPLES=OFF
-D INSTALL_PYTHON_EXAMPLES=OFF
-D BUILD_NEW_PYTHON_SUPPORT=ON
-D BUILD_opencv_python3=TRUE
-D OPENCV_GENERATE_PKGCONFIG=ON
-D BUILD_EXAMPLES=OFF …
I get the following warning:
/usr/bin/ld: skipping incompatible /usr/local/cuda-10.2/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda-10.2/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda-10.2/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda-10.2/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda-10.2/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda-10.2/lib64/libcudnn.so when searching for -lcudnn
I get this warning when “Linking CXX shared library …/…/lib/libopencv_***.so” is running with every libopencv.so target library.
The building process continues, then i install everything but at the end after running my python script i get the same error/warning of the beginning:
opencv /modules/dnn/src/dnn.cpp (1363) setupnet dnn module was not built with cuda backend; switching to cpu
What is the problem?
OpenCV 4.5.1
Cuda 10.2
cuDNN 8.6.0
Jetpack 4.6.2

Hi,

We got a topic that reports a similar issue:

It looks like the GPU support is turned off somehow.
We are checking this internally. Please wait for our update.

Thanks.

@amfilippo @AastaLLL

after that, make sure you have the libopencv_world.so file in your /usr/local/lib (usually)
and adding this to the platform you use, like Visual Studio should work.