Skip to content

[Jetpack 4.5] Install from source

koide3 edited this page Jun 28, 2021 · 25 revisions

This document is WIP

Important Note

  • This installation process takes a few hours and forces you to build and install ROS noetic from source
  • We strongly recommend using docker image koide3/monocular_person_following:jp45. See this tutorial
  • If you face some unmentioned problems, refer to the Dockerfile that describes the complete installation process

Environment

Tested on Jetson Xavier with Jetpack 4.5.1

Installation

Update system

sudo apt-get update
sudo apt-get upgrade

Flann & OpenBlas

sudo apt-get install libflann-dev libopenblas-base libopenblas-dev

dlib

mkdir ~/libs && cd ~/libs

wget http://dlib.net/files/dlib-19.22.tar.bz2
tar xvf dlib-19.22.tar.bz2

echo "export DLIB_ROOT=~/libs/dlib-19.22" >> ~/.bashrc
source ~/.bashrc

tensorflow 1.x

Follow NVIDIA's official instruction: https://docs.nvidia.com/deeplearning/frameworks/install-tf-jetson-platform/index.html

sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
sudo apt-get install python3-pip
sudo pip3 install -U pip testresources setuptools==49.6.0
sudo pip3 install -U numpy==1.19.4 future==0.18.2 mock==3.0.5 h5py==2.10.0 keras_preprocessing==1.1.1 keras_applications==1.0.8 gast==0.2.2 futures protobuf pybind11

sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v45 "tensorflow<2"

ROS noetic

Because tensorflow wheel for python2 no longer be provided, you need to use python3 and ROS noetic
Jetpack still remains on Ubuntu 18.04 and you need to build ROS noetic from source

ROS noetic installation adapted from https://github.com/dusty-nv/jetson-containers/blob/master/Dockerfile.ros.noetic

export ROS_PKG=desktop
export ROS_DISTRO=noetic
export ROS_ROOT=/opt/ros/${ROS_DISTRO}
export ROS_PYTHON_VERSION=3

sudo apt install git cmake build-essential curl wget gnupg2 lsb-release ca-certificates \
  libpython3-dev python3-rosdep python3-rosinstall-generator python3-vcstool build-essential
sudo rosdep init && rosdep update

sudo apt install python-genmsg
sudo pip3 install numpy

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

sudo ln -s /usr/lib/aarch64-linux-gnu/libboost_python3.a /usr/lib/aarch64-linux-gnu/libboost_python37.a
sudo ln -s /usr/lib/aarch64-linux-gnu/libboost_python3.so /usr/lib/aarch64-linux-gnu/libboost_python37.so

mkdir ~/libs/ros_catkin_ws && cd ~/libs/ros_catkin_ws
rosinstall_generator ${ROS_PKG} vision_msgs --rosdistro ${ROS_DISTRO} --deps --tar > ${ROS_DISTRO}-${ROS_PKG}.rosinstall

mkdir src
vcs import --input ${ROS_DISTRO}-${ROS_PKG}.rosinstall ./src

sudo apt-get update

rosdep install --from-paths ./src --ignore-packages-from-source --rosdistro ${ROS_DISTRO} --skip-keys python3-pykdl -y
sudo python3 ./src/catkin/bin/catkin_make_isolated --install --install-space ${ROS_ROOT} -DCMAKE_BUILD_TYPE=Release

tf-pose-estimation

# llvm-config required for installing llvmlite
sudo apt install llvm-10
sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-10 50

# the latest numba has some tbb version mismatch issues
sudo pip3 install numba==0.45.0

# swig required for building pafprocess
sudo apt install swig
cd catkin_ws/src
git clone https://github.com/koide3/tf-pose-estimation

# Follow the official installation instruction
cd tf-pose-estimation
sudo pip3 install -r requirements.txt

# In case you met scipy build issue
# sudo apt-get install gfortran

cd tf_pose/pafprocess
swig -python -c++ pafprocess.i && python3 setup.py build_ext --inplace

cd ../..
sudo python3 setup.py install

# You may need to comment out python package dependencies in setup.py like as follows:
# 21: #   'dill==0.2.7.1',

cd models/graph/cmu
bash download.sh

other packages

sudo apt-get install ros-melodic-image-transport ros-melodic-image-transport-plugins ros-melodic-image-proc

# To deal with cv_bridge's improper include directory isssue
sudo ln -s /usr/include/opencv4 /usr/include/opencv

cd catkin_ws/src
git clone https://github.com/koide3/open_face_recognition.git
git clone https://github.com/koide3/ccf_person_identification.git
git clone https://github.com/koide3/monocular_people_tracking.git --recursive
git clone https://github.com/koide3/monocular_person_following.git

cd ..
catkin_make -DCMAKE_BUILD_TYPE=Release