Cv2.error: no CUDA-capable device is detected in function ‘ManagedPtr’

Hi!

My environment:

  • Jetson Nano
  • Jetpack 4.6.4
  • L4T: 32.7.4
  • CUDA 10.2.300
  • cuDNN 8.2.1.32
  • OpenCV 4.5.1 compiled with CUDA
  • Python 3.7.5

I’m trying to use OpenCV 4.5.1 with CUDA on Python. But I get this error:

cv2.error: OpenCV(4.5.1) /home/jetson/opencv/modules/dnn/src/cuda4dnn/csl/memory.hpp:54: error: (-217:Gpu API call) no CUDA-capable device is detected in function ‘ManagedPtr’

How can I solve it and make it work?
Thanks a lot.

Addition: same problem with OpenCV 4.4.0:

cv2.error: OpenCV(4.4.0) /home/jetson/opencv/modules/dnn/src/cuda4dnn/csl/memory.hpp:54: error: (-217:Gpu API call) no CUDA-capable device is detected in function ‘ManagedPtr’

Any idea?

No reaction from support?

Hi,

Sorry for the late update.

Please install it from the source to get the CUDA support.
Below is a script for your reference:

Thanks.

Hi, I installed opencv 4.6.0 with the script you provided but something seems to be wrong. See below output. He complains about missing libopencv_hdf.so.4.5. How to fix it?

jetson@nano:~$ python
Python 3.7.5 (default, Dec 9 2021, 17:04:37)
[GCC 8.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import cv2
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/python3/dist-packages/cv2/init.py”, line 129, in
bootstrap()
File “/usr/lib/python3/dist-packages/cv2/init.py”, line 112, in bootstrap
import cv2
ImportError: libopencv_hdf.so.4.5: cannot open shared object file: No such file or directory

Hi,

Do you use a custom Python version? (3.7?)
If yes, please check if all the dependencies are updated for v3.7 as well.

Thanks.

Hi, I switched to Python3.8 and have compiled OpenCV 4.6.0 again based on the script you provided. Compilation and installation of OpenCV was successful, see test below:

jetson@nano:~$ python
Python 3.8.0 (default, Dec 9 2021, 17:53:27)
[GCC 8.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import cv2
cv2.version
‘4.6.0’
count = cv2.cuda.getCudaEnabledDeviceCount()
print(count)
1

But the original error from the beginning remains unchanged:

08/31/23 23:09:50 zmesdetect_m1[9928] ERR detect_sequence.py:713 [Error running model: OpenCV(4.6.0) /home/jetson/workspace/opencv-4.6.0/modules/dnn/src/cuda4dnn/csl/memory.hpp:54: error: (-217:Gpu API call) no CUDA-capable device is detected in function ‘ManagedPtr’]

08/31/23 23:09:50 zmesdetect_m1[9928] DBG2 detect_sequence.py:714 [Traceback (most recent call last):
File “/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py”, line 710, in detect_stream
_b,_l,_c,_m = m.detect(image=frame)
File “/usr/local/lib/python3.8/dist-packages/pyzm/ml/object.py”, line 71, in detect
b,l,c,_model_names = self.model.detect(image)
File “/usr/local/lib/python3.8/dist-packages/pyzm/ml/yolo.py”, line 189, in detect
outs = self.net.forward(ln)
cv2.error: OpenCV(4.6.0) /home/jetson/workspace/opencv-4.6.0/modules/dnn/src/cuda4dnn/csl/memory.hpp:54: error: (-217:Gpu API call) no CUDA-capable device is detected in function ‘ManagedPtr’]

08/31/23 23:09:50 zmesdetect_m1[9928] DBG2 detect_sequence.py:770 [We did not find any object matches in frame: alarm]

08/31/23 23:09:50 zmesdetect_m1[9928] DBG2 yolo.py:82 [pyzm_uid33_gpu_lock portalock already released]

08/31/23 23:09:50 zmesdetect_m1[9928] DBG1 detect_sequence.py:830 [perf: TOTAL detection sequence (with image loads) took: 477.96 ms to process 550]

08/31/23 23:09:50 zmesdetect_m1[9928] DBG1 zm_detect.py:556 [Closing logs]

What else can I do to solve it? I’m totally desperate and happy to provide additional information, in case that would help to fix it. Please let me know.

Hi,

For Nano, it’s more commended to use the default Python 3.6.

Is OpenCV 4.5.0 an option for you?
If yes, please try the below script which is verified under the JetPack 4 environment:

Thanks.

Hi, OpenCV 4.5.0 would also be OK but I need Python version beyond 3.6. Any idea how to make it work?

Hi,

You will need to install the new Python version manually.
And update all the dependencies to the corresponding Python version.

We didn’t try it before but it should work since some users have successfully built it.
Thanks.

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