Some resources https://docs.opencv.org/4.x/d7/d9f/tutorial_linux_install.html


Orin-NX

Orin NX

Install minimal prerequisite

sudo apt update && sudo apt install -y cmake g++ wget unzip

Create a directory, and pull opencv

mkdir building && git clone https://github.com/opencv/opencv.git

Create a build dir, and cd into it

mkdir -p build && cd build

Find other minimal prerequisites here under the sections Preparation and Prerequisites.

  1. Find the correct “Compute Capability” (CUDA_ARCH_BIN) on Wikipedia, for the Orin it is 8.7
  2. Remember to set the correct path for Cuda, DCUDA_TOOLKIT_ROOT_DIR, in this case it is /usr/local/cuda-12.2

Then you can run

cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DBUILD_PNG=OFF \
    -DBUILD_TIFF=OFF \
    -DBUILD_TBB=OFF \
    -DBUILD_JPEG=OFF \
    -DBUILD_JASPER=OFF \
    -DBUILD_ZLIB=OFF \
    -DBUILD_EXAMPLES=OFF \
    -DBUILD_JAVA=OFF \
    -DBUILD_opencv_python2=OFF \
    -DBUILD_opencv_python3=ON \
    -DENABLE_PRECOMPILED_HEADERS=OFF \
    -DWITH_OPENCL=OFF \
    -DWITH_OPENMP=OFF \
    -DWITH_FFMPEG=ON \
    -DWITH_GSTREAMER=OFF \
    -DWITH_GSTREAMER_0_10=OFF \
    -DWITH_CUDA=ON \
    -DWITH_GTK=ON \
    -DWITH_VTK=OFF \
    -DWITH_TBB=ON \
    -DWITH_1394=OFF \
    -DWITH_OPENEXR=OFF \
    -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-12.2 \
    -DCUDA_ARCH_BIN=8.7 \
    -DCUDA_ARCH_PTX="" \
    -DINSTALL_C_EXAMPLES=OFF \
    -DINSTALL_TESTS=OFF \
    -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
    -DBUILD_opencv_world=OFF \
    -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules \
    ../opencv

And lastly

cmake --build .

This will take some time (~3 hours)

Or use several cores (way faster)

make - j 8

This uses 8 cores (which is all cores on the Orin)

To be sure that the neccessary links are created

sudo ldconfig
sudo make install

General tips

Use tmux.