OpenCV with CUDA error - device unavailable. Jetson Orin Nano

Hi,
i want to work with OpenCV with CUDA support to process images on a Jetson Orin Nano.
For the start i decided to simply use a cannyEdge detector.
To build OpenCV with CUDA support i followed the instructions that worked in this Thread.

So currently i have OpenCV 4.9.0-dev installed with CUDA support enabled (as jtop stats confirm).

Now everytime i call cv::cuda::setDevice(0); or canny->detect(matImg,edgeImg);
i get the exception

  what():  OpenCV(4.9.0-dev) /home/myUser/opencv/modules/core/src/cuda_info.cpp:74: error: (-217:Gpu API call) all CUDA-capable devices are busy or unavailable in function 'setDevice'

or ‘allocate’ in case of the canny call.

I tried reinstalling OpenCV in Version 4.4 and 4.9 as well.

Some more info:
Calling cv::getBuildInformation returns(only CUDA section)

NVIDIA CUDA:                   YES (ver 11.4, CUFFT CUBLAS FAST_MATH)
     NVIDIA GPU arch:             87
     NVIDIA PTX archs:            87

cuDNN:                         YES (ver 8.6.0)

Calling cv::cuda::printCudaDeviceInfo(0) returns the stats of the GPU on the board.
Both outputs look fine to me, so if anyone has an idea what is going on there i would be very grateful.

Hi,

Which JetPack version do you use?
We wound like to give it a try in our environment first.

Thanks.

You can try to build you self (There is a script in the link below). Hope it helps!

ubuntu22.04@Jetson Orin Nano之OpenCV安装

Hi thanks for your answer,
but i already built it myself using two different scripts.
The build went well and jtop tells me i have exactly the version installed, which i built.
Thats why im so confused why i get this error.

Hi,
Oh yeah of course i forgot about that info.
I use Jetpack 5.1.1 [L4T 35.3.1].
Thanks.

OK. As we have got the right sofware version installed. Then it might be related with environment or software it self.

Would you mind share a piece a code which will eventually fail, and then we can try?

I have Jetson Pack 6.0DP OpenCV 4.9 with CUDA support. Maybe I can give it a try on this.

Hey thanks but i was able to solve it under my JP version.
The problem apparently was a combination of our own software with CUDA.
Thanks a lot.

1 Like

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