Install OpenCV on Nvidia TX1 with CUDA

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Resources.

https://github.com/opencv/opencv

https://docs.opencv.org/4.2.0/d7/d9f/tutorial_linux_install.html

https://www.jetsonhacks.com/2017/09/05/build-opencv-on-the-nvidia-jetson-tx1/

https://www.pyimagesearch.com/2018/09/26/install-opencv-4-on-your-raspberry-pi/

https://medium.com/@manivannan_data/install-opencv-and-tensorflow-on-jetson-tx1-and-jetson-tx2-bb4586aa396b

https://github.com/jetsonhacks/buildOpenCVTX1

https://www.howtoinstall.co/en/ubuntu/xenial/cmake-qt-gui

Prepare an SD Card

You will need an SD card with a recommended capacity of 62GB to build OpenCV as there is no enough disk space on the TX1. You will need to format it to ext4.

Use AOMEI partition assistant standard edition to format your SD card.

https://www.aomeitech.com/aomei-partition-assistant.html

Update and Install Dependencies

sudo apt-get install build-essential

sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

Removing an existing directory

If a directory already exists from a previous version or you need to start again, use the following command to remove the existing folder. Once removed, retry the install.

sudo rm -r opencv

Download OpenCV from Github

There is not enough disk space on the TX1 to compile OpenCV. You will need to build OpenCV on a SD card which has 64GB capacity.

To find your SD card path, enter the following commands.

df
cd /media/nvidia/CANON8
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git

Error Message:

fatal: destination path ‘opencv’ already exists and is not an empty directory.

Solution:

Use command above to remove an existing directory.

Install cmake-gui

Install cmake-gui

https://www.howtoinstall.co/en/ubuntu/xenial/cmake-qt-gui

sudo apt-get install cmake-qt-gui
cmake-gui

Create a build folder on SD card

cd opencv
mkdir build

Open Cmake-gui

From the linux CLI in the ‘/opencv/build’ folder enter the following command.

cmake-gui

Nominate your source and build folders, then hit configure. After you have chosen your settings, choose generate.

We did not change any settings from the default settings.

Once you have generated the makefile, close the cmake-gui application.

Compile.

Type ‘nproc’ from the CLI to detemine how many processor you have. Always use 1 less to prevent a crash. For example, I have four (4) processors, so I use ‘-j3’.

nproc
make -j3

Install from Build.

sudo make install

Test

Try the following command from Linux to see which active OpenCV version you have installed.

python3 -c 'import cv2; print(cv2.__version__)'

Open jtop and see if CUDA is working. Navigate to the last page to see if OpenCV has been installed with CUDA.

To install ‘jtop’, click the link below and follow the instructions.

http://brisbaneroboticsclub.id.au/measure-nvidia-nano-gpu-performance/

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.