Open CV build with CUDNN - need a bit of help

It’s never straightforward, is it?

I have Xavier NX, running # R32 (release), REVISION: 4.3, and trying to make openCV 4.2.0 build with cudnn… and get this error:
error: ‘CUDNN_CONVOLUTION_FWD_PREFER_FASTEST’ was not declared in this scope

I’ve read in the forum that there is some issue with JP4.4 production release and CUDNN. At first I was able to get around my first problem by reading a post which indicated I needed to do this in my make build: -D CUDNN_VERSION=8.0 \ which I did… and it helped. But now I am getting the error.

I read that maybe I have to go back to 4.4DP release… which I dont want to do… and or install openCV 4.3.0 which I could do.

I don’t understand all the patches needed now how to do them.

Can someone simply let me know what steps and direction I should go to get openCV running on my Xavier NX with cudnn ?

THANK YOU so much.

Hi birdingpix, please see @mdegans script here:

JetPack 4.4 NOTE: the minimum version that will build correctly on JetPack 4.4 GA is 4.4.0. Prior versions of JetPack may need the CUDNN version adjusted (the -D CUDNN_VERSION='8.0' line can simply be removed).

Dusty_nv THANK YOU for the excellent help.

I have followed that script and installed everything… no errors on make.

HOWEVER… I have this error:

ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions

However… I guess my old openCV installs are messing things up in my virtualenv…

I have tried lots of things… but I just don’t have the knowledge on how to solve this next step…

Here is output:

dk@XavierNX:~ workon opencv_cuda (opencv_cuda) dk@XavierNX:~ opencv_version --verbose

General configuration for OpenCV 4.4.0 =====================================
Version control: 4.4.0

Extra modules:
Location (extra): /tmp/build_opencv/opencv_contrib/modules
Version control (extra): 4.4.0

Timestamp: 2020-09-02T18:09:58Z
Host: Linux 4.9.140-tegra aarch64
CMake: 3.10.2
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: RELEASE

CPU/HW features:
Baseline: NEON FP16
required: NEON
disabled: VFPV3

Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: /usr/bin/c++ (ver 7.5.0)
C++ flags (Release): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,–gc-sections -Wl,–as-needed
Linker flags (Debug): -Wl,–gc-sections -Wl,–as-needed
ccache: NO
Precompiled headers: NO
Extra dependencies: m pthread cudart_static -lpthread dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda/lib64 -L/usr/lib/aarch64-linux-gnu
3rdparty dependencies:

OpenCV modules:
To be built: alphamat aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
Disabled: world
Disabled by dependency: -
Unavailable: cnn_3dobj cvv hdf java js julia matlab ovis python2 sfm ts viz
Applications: apps
Documentation: NO
Non-free algorithms: YES

GTK+: YES (ver 3.22.30)
GThread : YES (ver 2.56.4)
GtkGlExt: NO
OpenGL support: NO
VTK support: NO

Media I/O:
ZLib: /usr/lib/aarch64-linux-gnu/ (ver 1.2.11)
JPEG: /usr/lib/aarch64-linux-gnu/ (ver 80)
WEBP: build (ver encoder: 0x020f)
PNG: /usr/lib/aarch64-linux-gnu/ (ver 1.6.34)
TIFF: /usr/lib/aarch64-linux-gnu/ (ver 42 / 4.0.9)
JPEG 2000: build Jasper (ver 1.900.1)
OpenEXR: build (ver 2.3.0)

Video I/O:
DC1394: YES (2.2.5)
avcodec: YES (57.107.100)
avformat: YES (57.83.100)
avutil: YES (55.78.100)
swscale: YES (4.8.100)
avresample: YES (3.7.0)
GStreamer: YES (1.14.5)
v4l/v4l2: YES (linux/videodev2.h)

Parallel framework: pthreads

Trace: YES (with Intel ITT)

Other third-party libraries:
Lapack: YES (/usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/
Eigen: YES (ver 3.3.4)
Custom HAL: YES (carotene (ver 0.0.1))
Protobuf: build (3.5.1)

NVIDIA GPU arch: 72

cuDNN: YES (ver 8.0)

OpenCL: YES (no extra features)
Include path: /tmp/build_opencv/opencv/3rdparty/include/opencl/1.2
Link libraries: Dynamic load

Python 3:
Interpreter: /usr/bin/python3 (ver 3.6.9)
Libraries: /usr/lib/aarch64-linux-gnu/ (ver 3.6.9)
numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.13.3)
install path: ~/.virtualenvs/opencv_cuda/lib/python3.6/site-packages/cv2/python-3.6

Python (for build): /usr/bin/python3

ant: NO
Java wrappers: NO
Java tests: NO

Install to: /usr/local

(opencv_cuda) dk@XavierNX:~$ python
Python 3.6.9 (default, Jul 17 2020, 12:50:27)
[GCC 8.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import cv2
[’’, ‘~/.virtualenvs/opencv_cuda/lib/python3.6/site-packages/cv2/python-3.6’, ‘/usr/lib/’, ‘/usr/lib/python3.6’, ‘/usr/lib/python3.6/lib-dynload’, ‘/home/dk/.virtualenvs/opencv_cuda/lib/python3.6/site-packages’, ‘/usr/lib/python3.6/site-packages’, ‘/usr/local/lib/python3.6/dist-packages’, ‘/usr/lib/python3/dist-packages’, ‘/usr/lib/python3.6/dist-packages’]
Traceback (most recent call last):
File “”, line 1, in
File “/home/dk/.virtualenvs/opencv_cuda/lib/python3.6/site-packages/cv2/”, line 96, in
File “/home/dk/.virtualenvs/opencv_cuda/lib/python3.6/site-packages/cv2/”, line 86, in bootstrap
import cv2
File “/home/dk/.virtualenvs/opencv_cuda/lib/python3.6/site-packages/cv2/”, line 96, in
File “/home/dk/.virtualenvs/opencv_cuda/lib/python3.6/site-packages/cv2/”, line 23, in bootstrap
raise ImportError(‘ERROR: recursion is detected during loading of “cv2” binary extensions. Check OpenCV installation.’)
ImportError: ERROR: recursion is detected during loading of “cv2” binary extensions. Check OpenCV installation.

If someone can guide me to what is extra to be deleted and where… it would be a great help.

Thank you for getting me this far.

I think I am going to give up… and re-build from a clean new JP4.4 install.
That way there will be only one openCV installed version… and since I now know how to install OpenCV 4.4.0 with R32 (release), REVISION: 4.3… it will only take a 2 hours and then I should be good.

Hi, birdingpix

The cause of the original post is that cuDNN v8 has some API update and make it incompatible to the older OpenCV.
The new cuDNNv8 support is added in the latest OpenCV with -D CUDNN_VERSION='8.0' config.

That’s why we recommend to use above script for building OpenCV from source.


Thank you all. I have flashed the micro-SD card with new JP4.4 and run the mdegans install+build script. Wonderful help! I have now have openCV 4.4.0 with all capabilities installed and working.

Thanks so much. Dave

I used that script above to get OpenCV 4.4.0 on my Xaver AGX and it has been finished with no errors, but when I try to compile c++ application with OpenCV’s DNN module usage I got such errors

In function `eod::getOutputsNames[abi:cxx11](cv::dnn::dnn4_v20190621::Net const&)':
DnnDetector.cpp:(.text+0x1d8): undefined reference to `cv::dnn::dnn4_v20190621::Net::getUnconnectedOutLayers() const'
DnnDetector.cpp:(.text+0x1e8): undefined reference to `cv::dnn::dnn4_v20190621::Net::getLayerNames[abi:cxx11]() const'
CMakeFiles/offline_video.dir/src/lib/detectors/DnnDetector.cpp.o: In function `eod::GlobalDnnDetector::GlobalDnnDetector()':
DnnDetector.cpp:(.text+0x85c): undefined reference to `cv::dnn::dnn4_v20190621::Net::Net()'

I am compiling it as ROS node using catkin.
Please help, what I am doing wrong?