Building Opencv with CUDA

Hi everyone, I have a Jetson Orin Nano Developement kit 8GB with following configurations:

I am using the following Cmake command to build opencv with CUDA support

cmake -D WITH_CUDA=ON -D WITH_CUDNN=ON -D CUDA_ARCH_BIN="8.7" -D OPENCV_GENERATE_PKGCONFIG=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -DCUDA_STANDARD=14.0 -DCUDNN_VERSION=8.9.4 -DL4T_VERSION=36.2 -DPYTHON3_EXECUTABLE=/usr/bin/python3.10 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -D CMAKE_INSTALL_PREFIX=/usr/local ..

(PS: I am not very confident of the make tags myself)

I am getting the folllowing error while performing make:

Dumping the Cmake and make logs below

cmake_log.txt (32.0 KB)
make_log.txt (44.2 KB)

Please guide me. Thanks.

Hi,

We have an automatic script that can build OpenCV with CUDA support:

Could you check if this works for you?

Thanks.

Hi, thanks for the response.
Nope, still getting the same make error

However, I made some edits to the scripts, changed opencv version to 4.8.0 and updates some obsolete packages

  • python-dev to python3-dev
  • libdc1394-22-dev to libdc1394-dev (depreciated after ubuntu 21)
  • omitted v4l2ucp (depreciated)
  • omitted python-numpy (python3-numpy available)

I hope none of these changes are causing the issue. (From what I can understand it seem like some error in the C++11 library)

Can you please take a look at the make error again.
Thank you.

Hi,

Thanks for the testing.
We will give it a try and update.

Hi,

It looks like you are facing the same issue as below:

Could you check if the WAR also works for you (degrade to G++10) ?
Thanks.

1 Like

Yes! this definitely works.
Successfully built OpenCV with CUDA
Thank you so much for your help.

Hi @sanidhya3009
Were you building these binaries bare metal or within a docker container? If it’s a docker container, can you let me know what base image/docker run command you are using?

I am trying the same process within a docker container and using the python:3.8.18-slim-bullseye image as the base. However even after running the container with --runtime nvidia, it is not copying the cuda and cuDNN files into /usr/local/cuda, /usr/lib/aarch64-linux-gnu or /usr/include/aarch64-linux-gnu.

@AastaLLL your script builds fine within the container (I am using an Orin NX - Jetpack 5.1.1) but on execution of my code, it says that opencv was not built with CUDA. I tried volume mounting these directories directly into the container but it still does not work.

Any guidance would be great! Thank you.

Hi, @aieng

Since your container doesn’t build on the top of the l4t (linux4tegra) branch, it doesn’t contain the iGPU driver.
Since you don’t have GPU access within the container, the script doesn’t build OpenCV with CUDA since cmake cannot find it.

Thanks.

1 Like

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