Developing on NVIDIA® Jetson™ for AI on the Edge

Build OpenCV on the NVIDIA Jetson TX1

Note: This article has been superseded. Please see Build OpenCV 3.4 with CUDA on NVIDIA Jetson TX1.

With the deprecation of OpenCV4Tegra in L4T 28.1, developers may want to build OpenCV from source for their applications. There is a script on the JetsonHacks Github account to help in the process. Looky here:


For some applications it makes sense to build OpenCV from source. OpenCV is a rich environment with many options. For example, the OpenCV libraries in the Ubuntu repositories currently do not include GPU acceleration for aarch64 machines. For the Jetson, with its built in GPU, it makes sense to build GPU support into the OpenCV library.

An earlier NVIDIA supplied version of OpenCV4Tegra provided a variety of optimizations for the OpenCV library. Over the course of the last couple of years these optimizations have migrated upstream. That means that the optimizations are now available in the public OpenCV library.


The community has gathered the recipe(s) for building OpenCV for version later than OpenCV 3.0. There is a repository on the JetsonHacks Github account which contains a build script to help in the process.

To download the source and build OpenCV:

$ git clone
$ cd buildOpenCVTX1
$ ./

Once finished building, you are ready to install.

Navigate to the build directory to install the newly built libraries:

$ cd ~/opencv/build

Note: As discussed in the video, due to the nature of the multi-processor make process, some files may not be compiled. It’s a good idea to run make again after switching to the build directory:

$ make

This takes an extra few minutes, but will round up any stragglers and save headaches down the road.

Now install:

$ sudo make install

Once you have generated the build files, you can use the ccmake tool to examine the different options and modules available.

Remember to setup your OpenCV library paths correctly after installation.


  • This is meant to be a template for building your own custom version of OpenCV, pick and choose your own modules and options
  • The Jetson TX1 in the video is running L4T 28.1, OpenCV 3.3 is the version being built.
  • In the script, GStreamer support has been enabled. However there are issues using the Jetson TX1 onboard camera with it. The issue is discussed here: NVIDIA Jetson TX1 Forum – L4T 28.1 Onboard Camera Error. As of this writing (9/5/2017), I have been unable to get this working.
  • Most people do NOT have both OpenCV4Tegra and the source built OpenCV on their system. Some people have noted success using both however, check the forums.
  • Sometimes the make tool does not build everything. Experience dictates to go back to the build directory and run make again, just to be sure
  • Different modules and setting may require different dependencies, make sure to look for error messages when building.
  • After building, you should run the tests. The build script includes the testing options. All tests may not pass.
  • The build script adds support for Python 2.7
  • The compiler assumes that the Jetson TX1 aarch64 (ARMv8) architecture is NEON enabled, therefore you do not have to enable the NEON flag for the build

The information for this script was gathered from several places:


14 Responses

  1. Thank you very much for the tutorial, I have not installed 3.3, when I installed opencv3.3 need to uninstall 2.4(OpenCV for Tegra)? Also, the camera at the end of this tutorial questions still exist?

  2. Thank you very much.
    When compiling openCV 3.3 my TX1 you run out of memory. I then inserted an SD cart and select it as install directory.
    Now when compiling code from the Host with Nsight, even if the compiler and the linker are able to found libraries in the SD they are not able to execute the code telling that the .so does not exist or is no reachable. Any clues?

  3. Thank you very much for the tutorial. I tried install opencv 3.3 with jetpack 2.3.1 but don’t could.Now installed the jetpack 3.1 and openCV 3.3 without problems! thanks!

  4. HI
    Thank you very much for the nice tutorial…

    sorry for asking a trivial question..

    you write:
    Remember to setup your OpenCV library paths correctly after installation.

    how would i do that ?

    1. The OpenCV library paths are environment variables in your particular development tree to tell compilers and such where to look for the OpenCV libraries. Since these variables depend on your particular development environment and library paths, it is beyond the scope of what can described here. Generally, if you
      $ echo $PATH
      you will see the existing paths to system libraries.

  5. Thank you for information, it’s great tutorial and code. If you didn’t read and used only github code, don’t forget to do “sudo make install” otherwise you get no module named cv2.

  6. Error message

    [ 31%] Building NVCC (Device) object modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/
    : fatal error: when writing output to : No space left on device
    compilation terminated.
    CMake Error at (message):
    Error generating

    modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/build.make:154: recipe for target ‘modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/’ failed
    make[2]: *** [modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/] Error 1
    CMakeFiles/Makefile2:1683: recipe for target ‘modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/all’ failed
    make[1]: *** [modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/all] Error 2
    Makefile:160: recipe for target ‘all’ failed
    make: *** [all] Error 2
    Make did not successfully build
    Please fix issues and retry build


    Hi jim, the script terminated with this error? Is this script designed to build on the SD card? also is it designed to get the latest version of opencv?

    1. I don’t know what the term “Is this script designed to build on the SD card” means.Your error message:

      : fatal error: when writing output to : No space left on device

      indicates that you do not have enough room to compile OpenCV on the SD card you are using. SD cards are available in a variety of sizes, 16GB is a bare minimum to just run the device. If you are developing code or compiling large programs, you should use a larger SD card, usually around 32GB for a start.

      This is for OpenCV 3.4, the current version is 4.X

Leave a Reply

Your email address will not be published. Required fields are marked *


Some links here are affiliate links. If you purchase through these links I will receive a small commission at no additional cost to you. As an Amazon Associate, I earn from qualifying purchases.

Books, Ideas & Other Curiosities