Module 'cv2.dnn' has no attribute 'DNN_BACKEND_CUDA' - Jetson Nano 4GB

I am trying to run this script: opencv/person_reid.py at master · opencv/opencv · GitHub

But it throws me the title error:
module ‘cv2.dnn’ has no attribute ‘DNN_BACKEND_CUDA’.

My python version is 3.6.9. OpenCV version is 4.1.1

I don’t know what the error is, who can help me?

Hi,

It seems that you need to update the OpenCV library. Here you can find documentation on how to compile OpenCV from source code in Jetson boards: Compiling OpenCV from Source | OpenCV | RidgeRun - RidgeRun Developer Connection. Make sure to build with the flags “-D WITH_CUDA=ON” and “-D OPENCV_DNN_CUDA=ON” and “-D WITH_CUDNN=ON”

Some reference links about your issue:

Jafet Chaves,
Embedded SW Engineer at RidgeRun
Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com/
Website: www.ridgerun.com

1 Like

Do you know a solution so that the installation does not throw that error?

Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

I read that it runs because the processing is too much, both CPUs are at 99%.
Is there a way to limit it so that error doesn’t happen?

I think this one has a solution (line 86): https://github.com/Qengineering/Install-OpenCV-Jetson-Nano/blob/main/OpenCV-4-7-0.sh#L86
Is that it or not?

(I’m not an expert, but I think that’s the solution. My jetson nano is 4GB and I only use 2core and in the installation it used make -j8 What exactly does the j8 mean? That last code will use make -j1)

Hi,

You can try to build it with make -j1 so that only one CPU will be occupied.
This can prevent your system to freeze but will take longer compiling time.

Our default OpenCV doesn’t build with CUDA support.
So you will need to rebuild it from the source if you want to use GPU.

Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.