Last active
April 11, 2022 17:16
-
-
Save teuteuguy/dcb1e5a3e769e3061f40101d7a729fa5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
if [[ $(/usr/bin/id -u) -ne 0 ]]; then | |
echo "You must sudo this script" | |
exit | |
fi | |
CMAKE_VERSION="3.18.0" | |
NODE_VERSION="12.18.3" | |
OPENCV_VERSION="4.4.0" | |
# The nvpmodel command handles two power options for your Jetson Nano: | |
# (1) 5W is mode 1 and | |
# (2) 10W is mode 0. | |
# The default is the higher wattage mode, but it is always best to force the mode before running the jetson_clocks command. | |
nvpmodel -m 0 | |
jetson_clocks | |
# Get rid of extra stuff | |
apt-get purge -y libreoffice* thunderbird* | |
apt-get clean | |
apt-get update | |
apt-get -y upgrade | |
apt autoremove -y | |
# CMAKE | |
cd ~/Downloads | |
apt-get install -y git gcc g++ libssl-dev build-essential curl ca-certificates | |
wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION.tar.gz | |
tar -zxvf cmake-$CMAKE_VERSION.tar.gz | |
cd cmake-$CMAKE_VERSION | |
./bootstrap | |
make -j4 | |
make install | |
# NodeJS | |
cd ~/Downloads | |
wget https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-arm64.tar.gz | |
tar -xzf node-v$NODE_VERSION-linux-arm64.tar.gz | |
cd node-v$NODE_VERSION-linux-arm64/ | |
cp -R * /usr/local/ | |
ln -s /usr/local/bin/node /usr/local/bin/nodejs12.x | |
# Python3.7 | |
cd ~/Downloads | |
apt-get install -y python3.7-dev | |
wget https://bootstrap.pypa.io/get-pip.py | |
python3.7 get-pip.py | |
alias python3=python3.7 | |
# update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 | |
# update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2 | |
# update-alternatives --set python3 /usr/bin/python3.7 | |
# echo "Select Python3.7" | |
# sudo update-alternatives --config python3 # select python3.7 here | |
# Java | |
cd ~/Downloads | |
apt-get install -y openjdk-8-jdk | |
ln -s /usr/bin/java /usr/bin/java8 | |
# # Cython | |
# cd ~/Downloads | |
# wget https://files.pythonhosted.org/packages/3f/61/16a435de52fcda15246597a602aab6132cea50bedeb0919cb8874a068a20/Cython-0.29.20.tar.gz | |
# tar -xvf Cython-0.29.20.tar.gz | |
# cd Cython-0.29.20 | |
# python3.7 setup.py install | |
python3.7 -m pip install Cython | |
# # Numpy | |
# cd ~/Downloads | |
# wget https://github.com/numpy/numpy/releases/download/v1.18.4/numpy-1.18.4.tar.gz | |
# tar -xvf numpy-1.18.4.tar.gz | |
# cd numpy-1.18.4 | |
# python3.7 setup.py install | |
python3.7 -m pip install numpy | |
# Neo DLR | |
cd ~/Downloads | |
git clone https://github.com/neo-ai/neo-ai-dlr | |
cd neo-ai-dlr | |
git checkout 862da2de13d8f4fadb52b30baabc30a3c45821c4 | |
git submodule update --init --recursive | |
mkdir build | |
cd build | |
cmake .. -DUSE_CUDA=ON -DUSE_CUDNN=ON -DUSE_TENSORRT=ON | |
make -j4 | |
cd ../python | |
python3.7 setup.py install | |
# OpenCV | |
cd ~/Downloads | |
apt-get install -y build-essential pkg-config | |
apt-get install -y libtbb2 libtbb-dev | |
apt-get install -y libavcodec-dev libavformat-dev libswscale-dev | |
apt-get install -y libxvidcore-dev libavresample-dev | |
apt-get install -y libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev | |
apt-get install -y libpng-dev libjpeg-dev libopenexr-dev libtiff-dev libwebp-dev | |
apt-get install -y python-tk libgtk-3-dev | |
apt-get install -y libgtk-3-dev libcanberra-gtk-module libcanberra-gtk3-module | |
apt-get install -y libv4l-dev libdc1394-22-dev | |
apt-get install -y libv4l-dev v4l-utils qv4l2 v4l2ucp libdc1394-22-dev | |
wget -O opencv-$OPENCV_VERSION.tar.gz https://github.com/opencv/opencv/archive/$OPENCV_VERSION.tar.gz | |
wget -O opencv_contrib-$OPENCV_VERSION.tar.gz https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.tar.gz | |
tar -xvf opencv-$OPENCV_VERSION.tar.gz | |
tar -xvf opencv_contrib-$OPENCV_VERSION.tar.gz | |
cd opencv-$OPENCV_VERSION | |
mkdir build | |
cd build | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-$OPENCV_VERSION/modules \ | |
-D WITH_CUDA=ON \ | |
-D CUDA_ARCH_BIN=5.3 \ | |
-D CUDA_ARCH_PTX="" \ | |
-D WITH_CUBLAS=ON \ | |
-D ENABLE_FAST_MATH=ON \ | |
-D CUDA_FAST_MATH=ON \ | |
-D ENABLE_NEON=ON \ | |
-D WITH_GSTREAMER=ON \ | |
-D WITH_LIBV4L=ON \ | |
-D WITH_QT=OFF \ | |
-D WITH_OPENGL=OFF \ | |
-D BUILD_opencv_python2=OFF \ | |
-D BUILD_opencv_python3=ON \ | |
-D BUILD_TESTS=OFF \ | |
-D BUILD_PERF_TESTS=OFF \ | |
-D BUILD_EXAMPLES=OFF .. | |
make -j4 | |
make install | |
ldconfig | |
adduser --system ggc_user | |
addgroup --system ggc_group | |
# Add ggc_user to the video group so it can access CUDA ! | |
usermod -a -G video ggc_user | |
cd ~/Downloads | |
wget https://d1onfpft10uf5o.cloudfront.net/greengrass-core/downloads/1.10.2/greengrass-linux-aarch64-1.10.2.tar.gz | |
tar -xzvf greengrass-linux-aarch64-1.10.2.tar.gz -C / | |
wget -O /greengrass/certs/root.ca.pem https://www.amazontrust.com/repository/AmazonRootCA1.pem | |
wget -O greengrassd.service https://gist.githubusercontent.com/teuteuguy/0f2e52cebdf9bcd76b8734b25a793644/raw/08cd29d1ca056b127a4ed27807f3a542f76c9446/greengrassd.service | |
cp greengrassd.service /lib/systemd/system/ | |
systemctl enable greengrassd.service | |
# Utilities | |
# sudo -H pip install -U jetson-stats # enables jtop | |
# Notes | |
# | |
# For Greengrass, the resources needed to attach to the lambda function at minimum are the following: | |
# /dev/nvhost-ctrl | |
# /dev/nvhost-ctrl-gpu | |
# /dev/nvhost-prof-gpu | |
# /dev/nvmap | |
# /dev/nvhost-gpu | |
# /dev/nvhost-as-gpu | |
# | |
# the following 2 are optional, to avoid errors showing up, but inference still works without them: | |
# /dev/nvhost-vic | |
# /dev/tegra_dc_ctrl | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Proposed edit - Add the following 2 lines to install Java and create a symlink for Greengrass:
sudo apt install openjdk-8-jdk
sudo ln -s /usr/bin/java /usr/bin/java8