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


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:
You can modify the script into v4.1.0 and recompile the OpenCV again.


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.



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


5.3 is Nano GPU architecture. OpenCV only includes dGPU architecture by default.
You will need to add the Tegra capacity manually:

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