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

I am trying to run this script: opencv/ 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?


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:
Developers wiki:

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): Install-OpenCV-Jetson-Nano/ at main · Qengineering/Install-OpenCV-Jetson-Nano · GitHub
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)


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.


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