Skip to content

Commit

Permalink
Tx2 install dev (#384)
Browse files Browse the repository at this point in the history
* Installation script for TX2.
Updated installation.md and changed import statements in object_detection_2d gem and detr.

* Update installation.md

* Updated tx2 installation script

Tested it twice on two different TX2 boards successfully.

* Update install_tx2.sh

* Update installation.md

* Update installation.md

* Update installation.md

* Update docs/reference/installation.md

Co-authored-by: ad-daniel <44834743+ad-daniel@users.noreply.github.com>

* Update bin/install_tx2.sh

Co-authored-by: ad-daniel <44834743+ad-daniel@users.noreply.github.com>

* Update bin/install_tx2.sh

Co-authored-by: ad-daniel <44834743+ad-daniel@users.noreply.github.com>

* Update bin/install_tx2.sh

Co-authored-by: ad-daniel <44834743+ad-daniel@users.noreply.github.com>

* Update install_tx2.sh

* Update install_tx2.sh

* Update install_tx2.sh

* Update install_tx2.sh

* Update install_tx2.sh

* Update edgespeechnets_learner.py

* Update install_tx2.sh

* This PR includes the docker file for tx-2.

Tools that were tested under opendr/projects/perception and work:
- [x] Activity recognition
- [x] Face recognition
- [x] Lightweight Open Pose
- [x] Multimodal human centric
- [x] Object Detection 2D
   - [x] CenterNet
   - [x] Detr
   - [x] Gem
   - [x] RetinaFace
   - [x] SSD
   - [x] YOLOv3
- [x] Object tracking 2d
- [x] Semantic segmentation - Bisenet
- [x] Speech command recognition

The rest of the demos are not complete, i.e. missing an inference demo and/or data to run it.

* This PR includes the docker file for tx-2.

Tools that were tested under opendr/projects/perception and work:
- [x] Activity recognition
- [x] Face recognition
- [x] Lightweight Open Pose
- [x] Multimodal human centric
- [x] Object Detection 2D
   - [x] CenterNet
   - [x] Detr
   - [x] Gem
   - [x] RetinaFace
   - [x] SSD
   - [x] YOLOv3
- [x] Object tracking 2d
- [x] Semantic segmentation - Bisenet
- [x] Speech command recognition

The rest of the demos are not complete, i.e. missing an inference demo and/or data to run it.

* This PR includes the docker file for tx-2.

Tools that were tested under opendr/projects/perception and work:
- [x] Activity recognition
- [x] Face recognition
- [x] Lightweight Open Pose
- [x] Multimodal human centric
- [x] Object Detection 2D
   - [x] CenterNet
   - [x] Detr
   - [x] Gem
   - [x] RetinaFace
   - [x] SSD
   - [x] YOLOv3
- [x] Object tracking 2d
- [x] Semantic segmentation - Bisenet
- [x] Speech command recognition

The rest of the demos are not complete, i.e. missing an inference demo and/or data to run it.

* Added argument for tx2, agx and nx support.
Added instructions on installation.md

* Added argument for tx2, agx and nx support.
Added instructions on installation.md

* Added argument for tx2, agx and nx support.
Added instructions on installation.md

* Update installation.md

* Update activate_nvidia.sh

Corrected python to point to python3 on Nvidia

* Working ROS and correct export of Python version

* Working ROS and correct export of Python version

* Working ROS and correct export of Python version

* Update Dockerfile-embedded

* Update Dockerfile-embedded

* Update Dockerfile-embedded

* Working ROS and correct export of Python version

* Fixed catkin_make, added it to dockerfile.

* Added missing HINT from installation.md

* Updates on default values for FairMOT ros node class ctor

* Fixed duplicate shortcut on deepsort ros node argparse

* Fixed missing shortcut on rgbd hand gesture reco ros node argparse

* Added "opendr_" to data gen package and "_node" to the node file name

* Renamed package to "opendr_perception" and added "_node" to scripts

* Applied fixes to yolov5

* Added "opendr_" to planning package

* Added "opendr_" to bridge package

* Added "opendr_" to simulation package

* Fixed old version of torch in pip_requirements.txt

* Renamed ros bridge package doc

* Renamed dirs, etc. from opendr_ros_bridge to opendr_bridge to match the actual package name

* Fixed ros readme link from customize.md

* Fixed index.md link for opendr-ros-bridge.md

* Minor typo fix in issues.md

* Fixed bridge package name in its doc

* Fixed bridge imports

* Updated for dev_branch

Fixed some missing dependencies

* Fixed some missing dependencies

* add detectron2 (test with new p3.8 Dockerfile)

* Detectron2 issues

* Update install_nvidia.sh

* python3.8 test

* Rolling back to Python3.6.9

* Update install_nvidia.sh

* Updated Dockerfile and dependencies for embedded devices
Changed python to python3 on all ROS nodes
Fixed a couple of issues
Added some exports in activate_nvidia.sh

* Various Fixes

* Removed torch import on data.py and the corresponding reference in Video class.
Added some docker run instructions

* Remove unused import

* Remove Typehint for pyhton compatibilty

* Apply suggestions from code review

Dockerfile-embedded suggested changes

Co-authored-by: Nikolaos Passalis <passalis@users.noreply.github.com>

* Fixed suggested changes

* Format

Co-authored-by: ad-daniel <44834743+ad-daniel@users.noreply.github.com>
Co-authored-by: ad-daniel <daniel.dias@epfl.ch>
Co-authored-by: Nikolaos Passalis <passalis@users.noreply.github.com>
Co-authored-by: tsampazk <tsampaka@csd.auth.gr>
Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com>
  • Loading branch information
6 people authored Dec 23, 2022
1 parent 07840d3 commit 381e1f5
Show file tree
Hide file tree
Showing 38 changed files with 651 additions and 47 deletions.
201 changes: 201 additions & 0 deletions Dockerfile-embedded
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
#
# This dockerfile roughly follows the 'Installing from source' ROS instructions from:
# http://wiki.ros.org/noetic/Installation/Source
#
ARG BASE_IMAGE=nvcr.io/nvidia/l4t-base:r32.6.1
FROM ${BASE_IMAGE}
ARG device=nx

ARG ROS_PKG=ros_base
ENV ROS_DISTRO=noetic
ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}
ENV ROS_PYTHON_VERSION=3

ENV DEBIAN_FRONTEND=noninteractive

ENV CUDA_HOME="/usr/local/cuda"
ENV PATH="/usr/local/cuda/bin:${PATH}"
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"

WORKDIR /workspace

#
# OpenCV - https://github.com/mdegans/nano_build_opencv/blob/master/build_opencv.sh
#
ARG OPENCV_VERSION="4.4.0"

# install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
gfortran \
cmake \
git \
file \
tar \
libatlas-base-dev \
libavcodec-dev \
libavformat-dev \
libavresample-dev \
libcanberra-gtk3-module \
libdc1394-22-dev \
libeigen3-dev \
libglew-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-good1.0-dev \
libgstreamer1.0-dev \
libgtk-3-dev \
libjpeg-dev \
libjpeg8-dev \
libjpeg-turbo8-dev \
liblapack-dev \
liblapacke-dev \
libopenblas-dev \
libpng-dev \
libpostproc-dev \
libswscale-dev \
libtbb-dev \
libtbb2 \
libtesseract-dev \
libtiff-dev \
libv4l-dev \
libxine2-dev \
libxvidcore-dev \
libx264-dev \
libgtkglext1 \
libgtkglext1-dev \
pkg-config \
qv4l2 \
v4l-utils \
zlib1g-dev

RUN apt-get install ca-certificates -y

# OpenCV looks for the cuDNN version in cudnn_version.h, but it's been renamed to cudnn_version_v8.h
RUN ln -s /usr/include/$(uname -i)-linux-gnu/cudnn_version_v8.h /usr/include/$(uname -i)-linux-gnu/cudnn_version.h

# Architecture-specific build options
ARG CUDA_ARCH_BIN=""
ARG ENABLE_NEON="OFF"

# Clone and configure OpenCV repo
RUN git clone --depth 1 --branch ${OPENCV_VERSION} https://github.com/opencv/opencv.git && \
git clone --depth 1 --branch ${OPENCV_VERSION} https://github.com/opencv/opencv_contrib.git && \
cd opencv && \
mkdir build && \
cd build && \
echo "configuring OpenCV ${OPENCV_VERSION}, CUDA_ARCH_BIN=${CUDA_ARCH_BIN}, ENABLE_NEON=${ENABLE_NEON}" && \
cmake \
-D CPACK_BINARY_DEB=ON \
-D BUILD_EXAMPLES=OFF \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_java=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D CUDA_ARCH_BIN=${CUDA_ARCH_BIN} \
-D CUDA_ARCH_PTX= \
-D CUDA_FAST_MATH=ON \
-D CUDNN_INCLUDE_DIR=/usr/include/$(uname -i)-linux-gnu \
-D EIGEN_INCLUDE_PATH=/usr/include/eigen3 \
-D WITH_EIGEN=ON \
-D ENABLE_NEON=${ENABLE_NEON} \
-D OPENCV_DNN_CUDA=ON \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=/workspace/opencv_contrib/modules \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D WITH_CUBLAS=ON \
-D WITH_CUDA=ON \
-D WITH_CUDNN=ON \
-D WITH_GSTREAMER=ON \
-D WITH_LIBV4L=ON \
-D WITH_OPENGL=ON \
-D WITH_OPENCL=OFF \
-D WITH_IPP=OFF \
-D WITH_TBB=ON \
-D BUILD_TIFF=ON \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF \
../

RUN cd opencv/build && make -j$(nproc)
RUN cd opencv/build && make install
RUN cd opencv/build && make package

RUN cd opencv/build && tar -czvf OpenCV-${OPENCV_VERSION}-$(uname -i).tar.gz *.deb

RUN apt-get update -y
RUN apt-get install software-properties-common -y && \
apt-get update

# Add the ROS deb repo to the apt sources list

RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
cmake \
build-essential \
curl \
wget \
gnupg2 \
lsb-release \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

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

#
# Install bootstrap dependencies
#
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libpython3-dev \
python3-rosdep \
python3-rosinstall-generator \
python3-vcstool \
libyaml-cpp-dev \
build-essential && \
rosdep init && \
rosdep update && \
rm -rf /var/lib/apt/lists/*

#
# Download/build the ROS source
#
RUN mkdir ros_catkin_ws && \
cd ros_catkin_ws && \
# try below for ros-noetic-vision-msgs ros-noetic-geometry-msgs ros-noetic-sensor-msgs ros-noetic-audio-common-msgs \
rosinstall_generator ${ROS_PKG} audio_common_msgs --rosdistro ${ROS_DISTRO} --deps --tar > ${ROS_DISTRO}-${ROS_PKG}.rosinstall && \
rosinstall_generator ${ROS_PKG} sensor_msgs --rosdistro ${ROS_DISTRO} --deps --tar > ${ROS_DISTRO}-${ROS_PKG}.rosinstall && \
rosinstall_generator ${ROS_PKG} geometry_msgs --rosdistro ${ROS_DISTRO} --deps --tar > ${ROS_DISTRO}-${ROS_PKG}.rosinstall && \
rosinstall_generator ${ROS_PKG} vision_msgs --rosdistro ${ROS_DISTRO} --deps --tar > ${ROS_DISTRO}-${ROS_PKG}.rosinstall && \
mkdir src && \
cd src && \
git clone https://github.com/ros/resource_retriever && \
cd ../ && \
vcs import --input ${ROS_DISTRO}-${ROS_PKG}.rosinstall ./src && \
apt-get update && \
apt-get install -y gir1.2-gstreamer-1.0 && \
rosdep install --from-paths ./src --ignore-packages-from-source --rosdistro ${ROS_DISTRO} --skip-keys python3-pykdl -y && \
python3 ./src/catkin/bin/catkin_make_isolated --install --install-space ${ROS_ROOT} -DCMAKE_BUILD_TYPE=Release && \
rm -rf /var/lib/apt/lists/*


RUN echo 'source /opt/ros/${ROS_DISTRO}/setup.bash' >> /root/.bashrc
CMD ["bash"]
WORKDIR /

RUN git clone --depth 1 --recurse-submodules -j8 --branch tx2_install_dev https://github.com/opendr-eu/opendr
RUN apt-get update
RUN cd ./opendr && ./bin/install_nvidia.sh $device
RUN cd ./opendr/projects/opendr_ws/src && \
git clone --branch noetic https://github.com/ros-perception/vision_opencv && \
git clone --branch develop https://github.com/bosch-ros-pkg/usb_cam.git && \
cd ./usb_cam && git reset --hard 3ce8ee1 && cd ../ && \
git clone https://github.com/ros-perception/image_common.git && \
git clone https://github.com/ros-drivers/audio_common && \
sed -i 's/(Boost REQUIRED python37)/(Boost REQUIRED python3)/' ./vision_opencv/cv_bridge/CMakeLists.txt && \
cd ../

RUN /bin/bash -c '. /opt/ros/noetic/setup.bash; cd /opendr/projects/opendr_ws; catkin_make'
12 changes: 12 additions & 0 deletions bin/activate_nvidia.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
export OPENDR_HOME=$PWD
export PYTHONPATH=$OPENDR_HOME/src:$PYTHONPATH
alias python=python3
export LD_LIBRARY_PATH=$OPENDR_HOME/lib:$LD_LIBRARY_PATH

export PATH=/usr/local/cuda/bin:$PATH
export MXNET_HOME=$OPENDR_HOME/mxnet/
export PYTHONPATH=$MXNET_HOME/python:$PYTHONPATH
export MXNET_CUDNN_AUTOTUNE_DEFAULT=0
export LC_ALL="C.UTF-8"
export MPLBACKEND=TkAgg
Loading

0 comments on commit 381e1f5

Please sign in to comment.