Installing OpenCV 3.4.0 on the Nvidia Jetson Tx2

Connie Xu
3 min readSep 4, 2019

When using the Jetson Tx2, I found that building OpenCV from source has been beneficial. This allows for other configurations for OpenCV that the Jetson JetPack does not support. For the most part, I followed the tutorial linked here.

The first step is to remove any instances of OpenCV that may already been previously installed on the Jetson. You can do this by applying this command:

sudo apt-get purge libopencv*

It is recommended that you also purge the pre-downloaded (from JetPack) numpy and re-install it using pip:

sudo apt-get purge python-numpy
sudo apt autoremove
sudo apt-get update
sudo apt-get upgrade

I only installed OpenCV 3.4.0 for Python3. Here are the commands I used below:

sudo apt-get install --only-upgrade g++-5 cpp-5 gcc-5
sudo apt-get install build-essential make cmake cmake-curses-gui \
g++ libavformat-dev libavutil-dev \
libswscale-dev libv4l-dev libeigen3-dev \
libglew-dev libgtk2.0-dev
sudo apt-get install libdc1394-22-dev libxine2-dev \
libgstreamer1.0-dev \
sudo apt-get install libjpeg8-dev libjpeg-turbo8-dev libtiff5-dev \
libjasper-dev libpng12-dev libavcodec-dev
sudo apt-get install libxvidcore-dev libx264-dev libgtk-3-dev \
libatlas-base-dev gfortran
sudo apt-get install libopenblas-dev liblapack-dev liblapacke-dev
sudo apt-get install qt5-default
sudo apt-get install python3-dev python3-pip python3-tk
sudo pip3 install numpy
sudo pip3 install matplotlib

Some of these libraries do not have support for the Jetson Tx2, and I haven’t run into problems in which it stopped my OpenCV from compiling, so I have not taken issue with the commands above. After successfully installing matplotlib, you’ll need to edit the matplotlibrc file and modify the backend to be “backend : TkAgg”. It may not be in the exact same place but I used the following command:

sudo vim /usr/local/lib/python3.6/dist-packages/matplotlib/mpl-data/matplotlibrc

There seems to be an issue with Jetson where you have to apply a particular patch. It deals with fixing a symbolic link. Now, when I was trying to apply this, it actually would not let me make OpenCV successfully. I would try without fixing it first because I think Nvidia actually resolved this problem (albeit, I am not 100% confident on this). I installed curl so that I could do the following (and get OpenCV).

sudo apt-get install -y curl
cd $folder
curl -L -o
cd opencv-3.4.0/

If this works, make a directory inside of this folder and cd into it.

mkdir release
cd release/

My cmake is as follows; however, you can make it how you want:


After doing this, you can find cv2 (if you are using Python3.6) in /python3.6/site-packages. I found that the blog post had it in dist-packages for Python3.5 and it took me a while to find where it was located on mine. Last two commands:

make -j4
sudo make install

Hopefully, you install it successfully and you would have installed OpenCV 3.4.0 on your Nvidia Jetson Tx2.



Connie Xu

Software engineer @ Big Tech. Exploring tech, financial freedom, and everything in between.