No CUDA-capable device is detected in function 'getDevice' jetson xavier

Hi, I tried to run my python application on Jetson AGX Xavier.
The python application runs in a docker container and uses opencv. The docker image is based on the l4t_base image.
I compiled opencv with cuda enabled in the container and if I run print(cv2.getBuildInformation())
it shows

NVIDIA CUDA: YES (ver 10.2, CUFFT CUBLAS FAST_MATH)
NVIDIA GPU arch: 72
NVIDIA PTX archs:
cuDNN: YES (ver 8.0)

But when I run my python code with cv2.cuda.cvtColor
it shows

signal: aborted (core dumped)
terminate called after throwing an instance of ‘cv::Exception’
what(): OpenCV(4.4.0) /tmp/build_opencv/opencv/modules/core/src/cuda_info.cpp:84: error: (-217:Gpu API call) no CUDA-capable device is detected in function ‘getDevice’

I also ran the following in both the container and the host machine.

import cv2
count = cv2.cuda.getCudaEnabledDeviceCount()
print(count)

On the host machine, it returns 1 but in the container, it returns 0.

How should I solve this?
Thanks

Sorry for the late response, is this still an issue to support?

Thanks

Hi,

The default OpenCV version doesn’t enable GPU support.
Please build it from source to get the CUDA support.

Here is a building script for your reference:

Thanks.

Hi,
I built opencv from source with cuda enabled but I cannot get the device. Should I rebuild opencv using your script?

Hi,

YES. Please give it a try.

Thanks.