OpenCV - compile OpenCV 4.1.1 on Drive Software 10.0

Note: OpenCV is not officially supported nor is it optimized on the Drive platform. These instructions are provided only to help with porting/prototyping and is not maintained by NVIDIA. It is recommended to utilize NVIDIA APIs moving forward.

Cross compiling OpenCV on host


  1. Drive Software 10.0 is installed on the host machine via SDKManager (both host and device).
  2. cmake is installed (min version 3.10)

The instructions to build OpenCV on Host machine for Drive AGX Linux (V4L) platform:

  1. Download attached file “FindCUDA.cmake” (21.3 KB)
  2. cd <the_folder_where_FindCUDA.cmake_was_downloaded_to>
  3. execute the following commands:
    curl -L -o
    curl -L -o
    curl -L -o
    cd opencv-4.1.1/
    echo "** Apply patch"
    sed -i 's/include <Eigen\/Core>/include <eigen3\/Eigen\/Core>/g' modules/core/include/opencv2/core/private.hpp
    cp ../FindCUDA.cmake cmake/
    cp /usr/local/driveworks/samples/cmake/FindCUDA/* cmake/FindCUDA/
    cp /usr/local/driveworks/samples/cmake/CMakeParseArguments.cmake cmake/
    cp /usr/local/driveworks/samples/cmake/FindPackageHandleStandardArgs.cmake cmake/
    cp /usr/local/driveworks/samples/cmake/FindPackageMessage.cmake cmake/
    echo "** Building..."
    mkdir release
    cd release/
    export CUDA_PATH=/usr/local/cuda-10.2
    cmake \
    -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.1/modules \
    -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.2 \
    -DCUDA_ARCH_BIN=7.2 \
    -DCUDA_ARCH_PTX="" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_TOOLCHAIN_FILE=/usr/local/driveworks/samples/cmake/Toolchain-V5L.cmake \
    -DCMAKE_INSTALL_PREFIX=./install \
    -DVIBRANTE_PDK:STRING=<path_to_drive-t186ref-linux_location>/drive-t186ref-linux \
    -DBUILD_opencv_java=OFF \
    -DBUILD_opencv_python2=OFF \
    -DBUILD_opencv_python3=OFF \
    -DBUILD_opencv_videoio=OFF \
    -DBUILD_opencv_cudaimgproc=OFF \
    -DBUILD_opencv_highgui=OFF \
    -DBUILD_opencv_freetype=OFF \
    -DCUDNN_INCLUDE_DIR=/usr/include/aarch64-linux-gnu \
    -DWITH_1394=OFF \
    VERBOSE=1 \
    -DOPENCV_TEST_DATA_PATH=../opencv_extra-4.1.1/testdata \
    make -j8
    make install

native compiling OpenCV on AGX Drive

  1. Drive AGX hardware: Xavier or Pegasus.
  2. The latest Nvidia Drive Software is installed, SDK can be downloaded from :

The instructions to build OpenCV on Drive AGX Linux (V4L) platform:

  1. Execute the command: sudo apt update
  2. Execute the command: sudo dpkg -i /var/cuda-repo-10-2-local-10.2.19/cuda-toolkit-10-2_10.2.19-1_arm64.deb
  3. Execute the command: sudo apt --fix-broken -y install
  4. Run the script “” attached (1.3 KB)


I did the cross compiling steps without errors and it installed in the release/install directory. For some reason DVIBRANTE_PDK:STRING had no effect, so I had to copy the contents of release/install to targetfs manually. When I try to run the command “dpkg -l | grep libopencv” nothing shows. Also when I try to import cv2 in a python program I get the error “No module named cv2”.

Could you please support and advise regarding the problem presented above?
It is possible that I have not deployed OpenCV correctly to the target.

Thank you!

hello liviu.poenaru,

  1. the cross-compilation documentation above does not include opencv for python libs. to cross-compile OpenCV with Python you need first to install cross-compilation libs and define the following environment variables:

  2. to install opencv on a different location change the parameter:

  3. dpkg will not give you the opencv package as you haven’t installed it on the drive, to install it on the drive run “make install” on the Drive platform after copying the compiled opencv release folder and defining -DCMAKE_INSTALL_PREFIX=/usr/local when running cmake.

you can choose the second option for installing it on the AGX Drive: native compiling OpenCV on AGX Drive

Hi @shayNV,

If we would do the native compile on the AGX DRIVE, where should we install it?


Hi @shayNV

What would be the difference in the configuration for DRIVE™ OS 5.2.0 since the /usr/local/driveworks/samples/cmake/FindCUDA/ folder doesn’t exist.

I would like to know two things from the configuration above:

  • ENABLE_VFPV3 is not used? Why?

  • Why is WITH_TBB OFF?