I would like to build the OpenCV with CUDA on Orin Nano

I would like to build the OpenCV with CUDA on Orin Nano, but I am unable to build it because it fails to link CUDA related.

Orin Nano installed JetPack 6.1, then installed cmake and built OpenCV.
We built OpenCV based on the following link.
OpenCV on Orin Nano

sudo cmake -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D WITH_CUDA=ON -D CMAKE_BUILD_TYPE=RELEASE -D CUDA_ARCH_BIN=8.7 -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda ..

When the above command is executed, the error message “CMake Generate step failed. Build files cannot be regenerated correctly".

Error

    linked by target "opencv_videostab" in directory /BuildOpenCV/opencv_contrib/modules/videostab
    linked by target "opencv_videostab" in directory /BuildOpenCV/opencv_contrib/modules/videostab
    linked by target "opencv_annotation" in directory /BuildOpenCV/opencv/apps/annotation
    linked by target "opencv_visualisation" in directory /BuildOpenCV/opencv/apps/visualisation
    linked by target "opencv_interactive-calibration" in directory /BuildOpenCV/opencv/apps/interactive-calibration
    linked by target "opencv_version" in directory /BuildOpenCV/opencv/apps/version
    linked by target "opencv_model_diagnostics" in directory /BuildOpenCV/opencv/apps/model-diagnostics

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

Environment
JetPack: 6.1
OpenCV: 4.5.4 (I tried OpenCV ver.4.8.0 and 4.11.0, same error!)
CUDA: 12.6

Could you tell me the cause?

Hi,
Please try the script:
Jetson AGX Orin FAQ

Thank you for your response.

I have run install_opencv4.10.0_Jetpack6.1.sh but with the same error. Below is part of the error.

    linked by target "opencv_videostab" in directory /BuildOpenCV/workspace/opencv_contrib-4.10.0/modules/videostab
    linked by target "opencv_videostab" in directory /BuildOpenCV/workspace/opencv_contrib-4.10.0/modules/videostab
    linked by target "opencv_annotation" in directory /BuildOpenCV/workspace/opencv-4.10.0/apps/annotation
    linked by target "opencv_visualisation" in directory /BuildOpenCV/workspace/opencv-4.10.0/apps/visualisation
    linked by target "opencv_interactive-calibration" in directory /BuildOpenCV/workspace/opencv-4.10.0/apps/interactive-calibration
    linked by target "opencv_version" in directory /BuildOpenCV/workspace/opencv-4.10.0/apps/version
    linked by target "opencv_model_diagnostics" in directory /BuildOpenCV/workspace/opencv-4.10.0/apps/model-diagnostics

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

The environment variable PATH is set to “/usr/local/cuda” and LD_LIBRARY_PATH to “/usr/local/cuda/lib64”.
Are there any other settings needed?

Hi,
We don’t hit the error on Orin Nano developer kit. Do you use developer kit?

Hi,

It looks like you create a workspace under /BuildOpenCV/.
In case this is related to write permission, could you run the script under ${HOME}?

So it will create the workspace under the ${HOME}/workspace folder.

Thanks.

I use Orin Nano developer kit.
I had installed JetPack 6.1, but when I reinstalled it with the following command and then ran “install_opencv4.10.0_Jetpack6.1.sh”, it succeeded. Maybe something related to CUDA was missing.

sudo apt-get update
sudo apt-get install nvidia-jetpack

Resolved. Thank you very much.

1 Like

Thank you for your response.
We had removed some of the error paths to be listed here.

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