How to achieve the official cloudson nano mirror with opencv with cuda acceleration

I now need to use jetson nano to deploy opencv to use cuda accelerated development environment, but after downloading and compiling the source code of opencv4.1.0, run the test program, cv::gpu::GetCudaEnabledDeviceCount() return value is always 0

Hi,

Do you compile the OpenCV with the correct GPU architecture.
Nano GPU capacity is sm=5.3 so please add the following option as the the cmake option:

cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3" -D CUDA_ARCH_PTX="" .....

Here is a sample script for v4.0.0:
https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.0.0_Nano.sh
You can modify the script into v4.1.0 and recompile the OpenCV again.

Thanks.

How necessary are those second two? And at which versions of OpenCV? I’m asking because in my script I didn’t add them explicitly and those flags ended up getting set to the same things. I didn’t run tests for every version, however.

Since my script is supposed to support multiple versions, I suppose I better set those explicitly.

Hi,

-D WITH_CUDA=ON

Please enable this configuration or OpenCV won’t build with GPU support.

-D CUDA_ARCH_BIN="5.3"

5.3 is Nano GPU architecture. OpenCV only includes dGPU architecture by default.
You will need to add the Tegra capacity manually:
https://github.com/opencv/opencv/blob/ae279966c2c2e4d2db4a295b6397cc9aa832c794/cmake/OpenCVDetectCUDA.cmake#L120

If the package doesn’t build with correct GPU architecture, it’s expected to have some runtime failure.

Thanks.