Skip to content

Instantly share code, notes, and snippets.

@teuteuguy
Last active July 3, 2022 07:26
Show Gist options
  • Save teuteuguy/903bd2cd0745fad0595a513c5b094fdd to your computer and use it in GitHub Desktop.
Save teuteuguy/903bd2cd0745fad0595a513c5b094fdd to your computer and use it in GitHub Desktop.
jetson-nano-setup-v2.sh

Setup Jetson Nano Headless

1 - Download and flash image from Jetson Download Center

2 - On your other computer, use the serial terminal application to connect via host serial port to the Jetson Nano (115200)

  • Review and accept NVIDIA Jetson software EULA

  • Select system language, keyboard layout, and time zone

  • Create username, password, and computer name

  • Select APP partition size—it is recommended to use the max size suggested

  • Select primary interface as dummy0 (Wi-Fi will configure later)

  • Choose “do not configure network at this time” and proceed

  • Login with username and password

3 - Insert wifi dongle in to usb port

  • Setup WiFi: steps (but not necessary)
  • Check dongle with
$ nmcli d
  • Turn on the wifi
$ nmcli r wifi on
  • Requires a reboot
$ sudo reboot
  • List out wifi
$ nmcli d wifi list
  • Enter ssid and password
$ sudo nmcli d wifi connect <ssid> password <password>
  • Check ip with
$ ifconfig wlan0

4 - Reboot and login via ssh

In my experience NOMACHINE is better than VNC. If you wand NOMACHINE checkout the link

  • Update with
$ sudo apt update
  • Get rid of un-necessary stuff in ubuntu
# Get rid of extra stuff
sudo apt purge -y libreoffice* thunderbird* && sudo apt clean
  • Install nano text editor
$ sudo apt-get install nano
  • Upgrade with
$ sudo apt upgrade

5- Enabling Desktop Sharing: steps

  • Install vino (can skip this, as latest already has vino installed)
$ sudo apt install vino
  • Open the schema in nano editor
$ sudo nano /usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml

and go ahead and add the following key into the XML file

<key name='enabled' type='b'>
  <summary>Enable remote access to the desktop</summary>
  <description>
    If true, allows remote access to the desktop via the RFB
    protocol. Users on remote machines may then connect to the
    desktop using a VNC viewer.
  </description>
  <default>false</default>
</key>
  • Then compile the Gnome schemas
$ sudo glib-compile-schemas /usr/share/glib-2.0/schemas
  • Disable encryption for the VNC server
$ gsettings set org.gnome.Vino require-encryption false
$ gsettings set org.gnome.Vino prompt-enabled false
$ gsettings set org.gnome.Vino disable-background true

$ mkdir -p ~/.config/autostart
$ ln -s /usr/share/applications/vino-server.desktop ~/.config/autostart/
  • Enable Automatic Login (necessary)
# Open the custom.conf file in the Nano editor
$ sudo nano /etc/gdm3/custom.conf

Comment out the lines and replace user1 with your username

# Enabling automatic login
#  AutomaticLoginEnable = true
#  AutomaticLogin = user1

# Enabling automatic login
AutomaticLoginEnable = true
AutomaticLogin = username
  • Set the VNC resolution to fix low resolution issue modify xorg.conf file
$ sudo nano /etc/X11/xorg.conf

and add these lines to end of the file (you can also choose resolution by changing 1280 800)

Section "Monitor"
    Identifier "DSI-0"
    Option    "Ignore"
EndSection

Section "Screen"
    Identifier    "Default Screen"
    Monitor        "Configured Monitor"
    Device        "Default Device"
    SubSection "Display"
        Depth    24
        Virtual 1280 800
    EndSubSection
EndSection
  • Reboot
$ sudo reboot
  • Turn ON VNC manually once
$ export DISPLAY=:0.0 && /usr/lib/vino/vino-server
  • Connect over VNC to the nano

  • Go to settings, and setup VNC their with chosen password

  • Reboot

$ sudo reboot
  • You should be able to connect to VNC now.

6 - Docker (Portainer)

  • Pull the image
$ sudo docker pull portainer/portainer-ce:latest
  • Launch it
$ sudo docker run -d -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

6 - Python 3.7

  • Get Pip
$ cd ~/Downloads
$ sudo apt-get install -y python3.7-dev
$ sudo apt install python3-pip
# $ wget https://bootstrap.pypa.io/get-pip.py
# $ sudo python3.7 get-pip.py
# $ alias python3=python3.7
  • Reboot
$ sudo reboot
  • Install Jetson-Stats
$ sudo -H pip install -U jetson-stats
  • numpy
$ pip install numpy
  • jetson-inference
# jetson-inference
$ cd ~/Downloads
$ git clone --recursive https://github.com/dusty-nv/jetson-inference
$ cd jetson-inference
$ docker/run.sh --volume /home/username/Downloads:/downloads
# $ git submodule update --init
# $ mkdir build
# $ cd build
# $ cmake ..
# # Just press enter for default models to download for now
# # Skip pytorch for now
# $ make -j4
# $ sudo make install
# $ sudo ldconfig
#!/bin/bash
set -e
# if [[ $(/usr/bin/id -u) -ne 0 ]]; then
# echo "You must sudo this script"
# exit
# fi
CMAKE_VERSION="3.22.5"
NODE_VERSION="16.15.1"
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.
sudo nvpmodel -m 0
sudo jetson_clocks
# Get rid of extra stuff
sudo apt-get purge -y libreoffice* thunderbird*
sudo apt-get clean
sudo apt-get update
sudo apt-get -y upgrade
sudo apt autoremove -y
# CMAKE
cd ~/Downloads
sudo 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
sudo 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/
sudo cp -R * /usr/local/
# Python3.7
cd ~/Downloads
sudo 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
# # 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
# OpenCV
cd ~/Downloads
sudo apt-get install -y build-essential pkg-config
sudo apt-get install -y libtbb2 libtbb-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libxvidcore-dev libavresample-dev
sudo apt-get install -y libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
sudo apt-get install -y libpng-dev libjpeg-dev libopenexr-dev libtiff-dev libwebp-dev
sudo apt-get install -y python-tk libgtk-3-dev
sudo apt-get install -y libgtk-3-dev libcanberra-gtk-module libcanberra-gtk3-module
sudo apt-get install -y libv4l-dev libdc1394-22-dev
sudo 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
sudo make install
sudo ldconfig
# Utilities
# sudo -H pip install -U jetson-stats # enables jtop
# NVCC
echo "" >> ~/.bashrc
echo "# NVCC" >> ~/.bashrc
echo "export PATH=\${PATH}:/usr/local/cuda/bin" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:/usr/local/cuda/lib64" >> ~/.bashrc
# export PATH=${PATH}:/usr/local/cuda/bin
# export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64
#Virtual Env
pip install virtualenv virtualenvwrapper
echo "" >> ~/.bashrc
echo "# virtualenv and virtualenvwrapper" >> ~/.bashrc
echo "export WORKON_HOME=\$HOME/.virtualenvs" >> ~/.bashrc
echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.7" >> ~/.bashrc
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc
source ~/.bashrc
mkvirtualenv deep_learning -p python3.7
pip install numpy
# jetson-inference
cd ~/Downloads
git clone --recursive https://github.com/dusty-nv/jetson-inference
cd jetson-inference
git submodule update --init
mkdir build
cd build
cmake ..
# Just press enter for default models to download for now
# Skip pytorch for now
make -j4
sudo make install
sudo ldconfig

Setup Node JS on Ubuntu 18.04

$ export NODE_VERSION="16.15.1"
$ # 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/
$ sudo cp -R * /usr/local/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment