Skip to content

Instantly share code, notes, and snippets.

@tikurahul
Last active July 22, 2021 03:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tikurahul/fa4644f77cb3865d6ab412bddd8b6706 to your computer and use it in GitHub Desktop.
Save tikurahul/fa4644f77cb3865d6ab412bddd8b6706 to your computer and use it in GitHub Desktop.
OpenCV 4.1 + Tensorflow on Jetson Nano

Step 1: Setup CUDA on Jetson Nano

  • Setup some environment variables so nvcc is on $PATH. Add the following lines to your ~/.bashrc file.
# Add this to your .bashrc file
export CUDA_HOME=/usr/local/cuda
# Adds the CUDA compiler to the PATH
export PATH=$CUDA_HOME/bin:$PATH
# Adds the libraries
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
  • Test the changes to your .bashrc.
source ~/.bashrc
nvcc --version

You should see something like:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on ...
Cuda compilation tools, release 10.0, Vxxxxx

Step 2: Configuration

cmake -D CMAKE_BUILD_TYPE=RELEASE \
	-D WITH_CUDA=ON \
	-D CUDA_ARCH_BIN="5.3" \
	-D CUDA_ARCH_PTX="" \
	-D CMAKE_INSTALL_PREFIX=/usr/local \
	-D INSTALL_PYTHON_EXAMPLES=OFF \
	-D INSTALL_C_EXAMPLES=OFF \
	-D OPENCV_ENABLE_NONFREE=ON \
	-D OPENCV_EXTRA_MODULES_PATH=/home/rahulrav/Workspace/OpenCV/opencv_contrib/modules \
	-D PYTHON_EXECUTABLE=/home/rahulrav/.virtualenvs/donkeycar/bin/python \
	-D BUILD_EXAMPLES=OFF ..

Step 3: Install Tensorflow

Look for the latest version of Tensorflow from here.

Switch to your virtualenv and run:

pip install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu==1.14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment