GPU Support for cv2.dnn on jetson Nano

Hi,

I’m experimenting with the person_tracking.py script from this github repository https://github.com/mailrocketsystems/AIComputerVision and it works with only 1-3 fps.
I have read some forum posts saying that there is no GPU support for cv.dnn and (for example) also not for cap_cv2.VideoCapture(). In some different posts I’ve read that there ist a GPU support now.

Now I’m not really sure if there is a GPU support or not and what is the current state? If not, is there a a possibility to activate the GPU support?

Some information about my system:

  • Image: jetson-nano-4gb-jp441-sd-card-image
  • OpenCV 4.1.1
  • CUDA Version 10.2
  • Ubuntu 18.04 LTS

Best regards
chris

Assuming you have installed OpenCV with CUDA support (the default version installed with JetPack does NOT support CUDA/GPU) you must uncomment the lines starting with “detector.setPreferable…” (lines 11 and 12 in the current commit of the person_tracking.py script in order to enable GPU usage.

Try that and report back if fps increases, you should see 3x performance improvement.

Hi dkreutz,
thanks for your reply.

I have wrongly assumed that the default version of opencv does support CUDA/GPU. So I have to install opencv with CUDA support first.

Just to give it a try I uncommented
detector.setPreferableBackend(cv2.dnn.DNN_BACKEND_INFERENCE_ENGINE)
and run person_tracking.py

Is the error you can see below an indication to the missing support?

nvidia@nvidia-desktop:~/Mailrocketsystems/AIComputerVision$ python3 person_tracking.py 
Traceback (most recent call last):
  File "person_tracking.py", line 130, in <module>
    main()
  File "person_tracking.py", line 81, in main
    person_detections = detector.forward()
cv2.error: OpenCV(4.1.1) /home/nvidia/host/build_opencv/nv_opencv/modules/dnn/src/dnn.cpp:999: error: (-215:Assertion failed) haveInfEngine() in function 'wrapMat'

And one more question if you dont mind. Could it be that I must install intel’s open vino environment first? Please have a look to the answer I got here:

When the error message appeared after uncommenting then I suppose it is caused by missing CUDA support. (Sorry, I can’t verify this on my Nano right now).

For building/installing OpenCV with CUDA support I recommend to use this script by community member @mdegans.

Regarding OpenVINO - maybe this is a specific requirement for AIComputerVision - I don’t remember having used/installed it for my OpenCV-DNN experiments.

Thanks a lot for the answer and your recommendation! I will have a look at it.