opencv: AttributeError: module 'cv2.dnn' has no attribute 'DNN_BACKEND_CUDA'

System information (version)
Detailed description

Hello, I’m trying to execute the tutorial of Social distancing of Adrian Rosebrock .

I have changed from GPU=False to GPU=True in social_destancing_config.py file before executing the script, I’m got this error:

File “social_distance_detector.py”, line 41, in <module> net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA) AttributeError: module ‘cv2.dnn’ has no attribute ‘DNN_BACKEND_CUDA’

How can I fix this error?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (10 by maintainers)

Most upvoted comments

@abdou31 A bug was introduced a week ago which broke CUDA builds. The fix was merged into master just a few hours ago. You need to pull the latest changes from master to avoid that error.

Or you can use OpenCV 4.3 which is a stable version without any serious issues.