Skip to content

Instantly share code, notes, and snippets.

@liviaerxin
Last active March 8, 2023 06:51
Show Gist options
  • Save liviaerxin/24fd9a4839096ca319c32a07ad45129f to your computer and use it in GitHub Desktop.
Save liviaerxin/24fd9a4839096ca319c32a07ad45129f to your computer and use it in GitHub Desktop.
Jetson Nano Setup #jetson-nano

Jetson Nano

NVIDIA Jetson Linux Developer Guide!comprehensive and useful resources

Jetson Zoo

NVIDIA Jetson Nano Setup

JetPack SDK

JetPack SDK Introduction

JetPack SDK includes:

  • L4T
    • Ubuntu 18.04(Linux operating system)
    • bootloader
    • Linux kernel 4.9
    • necessary firmwares
    • NVIDIA drivers
  • CUDA accelerated libraries
    • TensorRT
    • cuDNN
    • CUDA
    • Multimedia API
    • Computer Vision
    • Developer Tools
    • DeepStream

How to Upgrade JetPack

  1. Upgrade L4T
  2. Upgrade JetPack

Over-The-Air Updates

Note: upgrade L4T on a system where Jetpack is not installed.

Setup

Setup and First Boot

  • Set power mode(5W or 10W)

    # To set Jetson Nano to 10W performance mode
    sudo nvpmodel -m 0
    sudo jetson_clocks
  • Set CUDA toolkits in environment path

    in ~/.bashrc,

    export PATH=/usr/local/cuda/bin:${PATH}
    export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}

    use script,

    #!/bin/bash
    set -e
    
    if ! grep 'cuda/bin' ${HOME}/.bashrc > /dev/null ; then
      echo "** Add CUDA stuffs into ~/.bashrc"
      echo >> ${HOME}/.bashrc
      echo "export PATH=/usr/local/cuda/bin:\${PATH}" >> ${HOME}/.bashrc
      echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64:\${LD_LIBRARY_PATH}" >> ${HOME}/.bashrc
    fi

Connect to Jetson

  1. Ethernet/WiFi It needs Jetson to connect to the same network as your desktop pc via Ethernet or WiFi.

    # `jetson-desktop` is hostname of Jetson 
    ssh [email protected]
  2. USB device mode Jetson Nano Micro-USB Login

Install Softwares

Docker

  • Docker setting

    # setup docker without sudo
    sudo usermod -aG docker $USER
    # upgrade docker
    sudo apt-get --only-upgrade install docker.io
  • Docker Compose

    Install Docker Compose

TensorFlow

Pytorch

JupyterLab

  1. install NodeJS through installing nvm

  2. install JupyterLab

  3. configure JupyterLab

    Running a notebook server

    # configure /home/$USER/jupyter_notebook_config.py
    ...
    c.NotebookApp.ip = '*'
    c.NotebookApp.port = 8888
    c.NotebookApp.open_browser = False
    ...
    
    # configure password
    $ jupyter notebook password

    Run jupyterlab as ubuntu service

    # 1. create script
    $ vim /home/$USER/jupyterlab.sh
    
    #!/bin/sh
    /home/jetson/.local/bin/jupyter lab --ip=0.0.0.0 --port=8888 --no-browser
    
    $ sudo chmod +x /home/$USER/jupyterlab.sh
    
    # 2. create service
    $ sudo vim /etc/systemd/system/jupyterlab.service
    # replace $USER
    
    [Unit]
    Description=Jupyterlab
    After=syslog.target network.target
    
    [Service]
    User=jetson
    ExecStart=/bin/bash /home/$USER/jupyterlab.sh
    WorkingDirectory=/home/$USER/
    
    [Install]
    WantedBy=multi-user.target
    
    # 3. enable service
    $ sudo systemctl enable jupyterlab.service
    $ sudo service jupyterlab start
  4. install JupyterLab extensions

    # install ipywidgets and enable
    jupyter labextension install @jupyter-widgets/jupyterlab-manager

    Language Server Protocol integration for Jupyter(Lab)

OpenVPN

sudo apt-get install openvpn

# Then you can connect like this:
sudo openvpn --config /path/to/config.ovpn

Samba

sudo apt install samba samba-common-bin
sudo nano /etc/samba/smb.conf

# edit `/etc/samba/smb.conf` file
workgroup = your_workgroup_name
wins support = yes

[pihome]
   comment= Pi Home
   path=/home/pi
   browseable=Yes
   writeable=Yes
   only guest=no
   create mask=0777
   directory mask=0777
   public=no

# save and exit
sudo smbpasswd -a pi

Samba Installation Anonymous Read-Write Document Server

OpenCV(GPU)

Using GPU with OpenCV on Jetson Xavier - Jetson AGX Xavier - NVIDIA Developer Forums

GitHub - mdegans/nano_build_opencv: Build OpenCV on Nvidia Jetson Nano

tips: make the CMake version >3.20 or support ssl. Otherwise it will not support https download for xfeatures2d in opencv

software installation - How do I install the latest version of cmake from the command line? - Ask Ubuntu

Check OpenCV Build Information: getBuildInformation()

python3 -c 'import cv2; print(cv2.getBuildInformation())'

Some Tips

Connect to WiFi from terminal

nmcli device wifi rescan
nmcli device wifi list
nmcli device wifi connect <ssid_name> password <password>

Check L4T Version

dpkg-query --show nvidia-l4t-core
JETSON_L4T_STRING=$(head -n 1 /etc/nv_tegra_release)
JETSON_L4T_RELEASE=$(echo $JETSON_L4T_STRING | cut -f 2 -d ' ' | grep -Po '(?<=R)[^;]+')
JETSON_L4T_REVISION=$(echo $JETSON_L4T_STRING | cut -f 2 -d ',' | grep -Po '(?<=REVISION: )[^;]+')
JETSON_L4T_VERSION="$JETSON_L4T_RELEASE.$JETSON_L4T_REVISION"
echo $JETSON_L4T_VERSION

or

JETSON_L4T_STRING=$(dpkg-query --showformat='${Version}' --show nvidia-l4t-core)
JETSON_L4T_ARRAY=$(echo $JETSON_L4T_STRING | cut -f 1 -d '-')
JETSON_L4T_RELEASE=$(echo $JETSON_L4T_ARRAY | cut -f 1 -d '.')
JETSON_L4T_REVISION=${JETSON_L4T_ARRAY#"$JETSON_L4T_RELEASE."}
JETSON_L4T_VERSION="$JETSON_L4T_RELEASE.$JETSON_L4T_REVISION"
echo $JETSON_L4T_VERSION

Check JetPack Version

sudo apt-cache show nvidia-jetpack

Check Cudnn Version

cat /usr/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

Install Pycuda

export CPATH=$CPATH:/usr/local/cuda/include
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda/lib64

pip3 install pycuda --user

Disable GUI/Install lightdm instead of gdm

sudo systemctl set-default multi-user.target
sudo systemctl get-default

Disable GUI in Ubuntu 18.04. desktop? (SSH/Webmin headless setup) How to disable GUI from starting on boot?

Troubleshooting

Camera failed to create CaptureSession

# restart camera daemon
sudo systemctl restart nvargus-daemon

xRDP disconnects immediately after connection

# find reason from logs
sudo journalctl -S -3m

# add user xrdp into ssl-cert group
sudo adduser xrdp ssl-cert

# configure desktop session for xRDP
# rdp works better with XFCE
sudo apt-get install xfce4
echo xfce4-session > ~/.xsession
sudo sh -c 'cat /dev/null > /etc/xrdp/startwm.sh'

cat <<EOF > /tmp/startwm.sh
#!/bin/sh
if [ -r /etc/default/locale ]; then
  . /etc/default/locale
  export LANG LANGUAGE
fi
startxfce4

EOF

sudo mv /tmp/startwm.sh /etc/xrdp/startwm.sh
sudo systemctl restart xrdp.service

xRDP cannot read /etc/xrdp/key.pem. Permission denied error explained

How to Use Remote Desktop Connection in Ubuntu Linux: Complete Walkthrough

How to configure XRDP to start cinnamon as default desktop session

SSH Connection Hangs

Check this issue by opening ssh daemon log(/var/log/auth.log in ubuntu) to solve. In some cases, upgrade libs (sudo apt-get upgrade, systemd,...etc) or install missing libs(sudo apt-get install libpam-kwallet5)

ssh connection takes forever to initiate, stuck at “pledge: network”

AI-IOT

JetCam ! camera interface for NVIDIA Jetson

JetBot

Getting Started with AI on Jetson Nano

jetson-inference

Test JetPack On Jetson Nano

JetPack-4.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment