Compile opencv with cuda

hi
i have manifod g2 (DJI pc) with:
jetson tx2 Nvidia
jetpack 3.2
cuda 9-0

i try to use dnn with cuda.
(with:

self.net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
self.net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)

i try to compile opencv 4.5.1 with opencv_contrib with those flags:

  -D CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} \
  -D WITH_CUDA=ON \
  -D OPENCV_DNN_CUDA=ON \
  -D CUDNN_VERSION='9.0'\
  -D CUDA_ARCH_BIN=${ARCH_BIN} \
  -D CUDA_ARCH_PTX="" \
  -D ENABLE_FAST_MATH=ON \
  -D CUDA_FAST_MATH=ON \
  -D WITH_CUBLAS=ON \
  -D WITH_LIBV4L=ON \
  -D WITH_CUDNN=ON \
  -D WITH_GSTREAMER=ON \
  -D WITH_GSTREAMER_0_10=OFF \
  -D WITH_QT=ON \
  -D WITH_OPENGL=ON \
  -D OPENCV_EXTRA_MODULES_PATH=/home/nvidia/opencv_contrib/modules \
  -D BUILD_opencv_legacy=OFF \

In the building i get weird warring:
/usr/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudnn.so when searching for -lcudnn

and i get:

CMakeFiles/Makefile2:5082: recipe for target 'modules/dnn/CMakeFiles/opencv_dnn.dir/all' failed
make[1]: *** [modules/dnn/CMakeFiles/opencv_dnn.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

please someone can help me :)
tnkx

Find correct CUDNN version.

hi, i try to check the version:

#define CUDNN_MAJOR 7
#define CUDNN_MINOR 1
#define CUDNN_PATCHLEVEL 5
--
#define CUDNN_VERSION    (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

#include "driver_types.h"

so my version is “7.15”
i try again with:
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-master/modules -DWITH_CUDA=ON -DCUDA_ARCH_BIN=6.2 -DCUDA_ARCH_PTX="" -DENABLE_FAST_MATH=ON -DCUDA_FAST_MATH=ON -DWITH_CUBLAS=ON -DWITH_LIBV4L=ON -DWITH_GSTREAMER=ON -DWITH_GSTREAMER_0_10=OFF -DWITH_QT=ON -DWITH_OPENGL=ON -DOPENCV_DNN_CUDA=ON -DWITH_CUDNN=ON -DCUDNN_VERSION='7.15' ../opencv-master

but i get the same issue …


[ 23%] Linking CXX shared library …/…/lib/libopencv_cudawarping.so
/usr/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudnn.so when searching for -lcudnn
[ 23%] Built target opencv_cudawarping
Makefile:160: recipe for target ‘all’ failed
make: *** [all] Error 2

-DCUDNN_VERSION=‘7.1’

cmake -DOPENCV_EXTRA_MODULES_PATH=…/opencv_contrib-master/modules -DWITH_CUDA=ON -DCUDA_ARCH_BIN=6.2 -DCUDA_ARCH_PTX="" -DENABLE_FAST_MATH=ON -DCUDA_FAST_MATH=ON -DWITH_CUBLAS=ON -DWITH_LIBV4L=ON -DWITH_GSTREAMER=ON -DWITH_GSTREAMER_0_10=OFF -DWITH_QT=ON -DWITH_OPENGL=ON -DOPENCV_DNN_CUDA=ON -DWITH_CUDNN=ON -DCUDNN_VERSION=‘7.1’ …/opencv-master

i tried and i get this:


– Other third-party libraries:
– Lapack: YES (/usr/lib/liblapack.so /usr/lib/libcblas.so /usr/lib/libatlas.so)
– Eigen: YES (ver 3.3.7)
– Custom HAL: YES (carotene (ver 0.0.1))
– Protobuf: build (3.5.1)

– NVIDIA CUDA: YES (ver 9.0, CUFFT CUBLAS FAST_MATH)
– NVIDIA GPU arch: 62
– NVIDIA PTX archs:

– cuDNN: NO

– OpenCL: YES (no extra features)
– Include path: /root/opencv-master/3rdparty/include/opencl/1.2
– Link libraries: Dynamic load

– Python 2:
– Interpreter: /usr/bin/python2.7 (ver 2.7.12)
– Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.12)
– numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0)
– install path: lib/python2.7/dist-packages/cv2/python-2.7

– Python 3:
– Interpreter: /usr/bin/python3 (ver 3.8.9)
– Libraries: /usr/lib/aarch64-linux-gnu/libpython3.8.so (ver 3.8.9)
– numpy: /usr/local/lib/python3.8/dist-packages/numpy/core/include (ver 1.19.3)
– install path: lib/python3.8/dist-packages/cv2/python-3.8

– Python (for build): /usr/bin/python2.7

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

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

– Configuring incomplete, errors occurred!
See also “/root/build/CMakeFiles/CMakeOutput.log”.
See also “/root/build/CMakeFiles/CMakeError.log”.

No recognition: cuDNN: NO