jetson nano 2Gb

AIOT toy

Getting Started with AI on Jetson Nano

set up the device

Download image, write into your SD card, first boot setting

check SWAP

 1#  You should see 4071 as the size of the swap if you have 4GB configured
 2free -m
 4# Disable ZRAM:
 5sudo systemctl disable nvzramconfig
 7# Create 4GB swap file
 8sudo fallocate -l 4G /mnt/4GB.swap
 9sudo chmod 600 /mnt/4GB.swap
10sudo mkswap /mnt/4GB.swap
12# Append the following line to /etc/fstab
13sudo echo "/mnt/4GB.swap swap swap defaults 0 0" >> /etc/fstab

Headless mode

Use jetson nano 2Gb in “USB device mode”, connect the jetson nano to your computer through a USB cable just like a eGPU.

  1. power on, wait 30 seconds, connect with USB cable

  2. 1ssh <username>@
  3. 1mkdir -p ~/nvdli-data
  4.  1# create a script to run docker env
     2# check the container's tag here:
     4echo "sudo docker run --runtime nvidia -it --rm --network host \
     5    --volume ~/nvdli-data:/nvdli-nano/data \
     6    --device /dev/video0 \
     7" >
     8chmod +x
     9# run the script to activate the env

Use the JupyterLab from your laptop:

‚Äč open in browser, pwd = dlinano

Camera setup

check available device

1!ls -ltrh /dev/video*

first method to use the camera

create camera object

1from jetcam.usb_camera import USBCamera
3#TODO change capture_device if incorrect for your system
4camera = USBCamera(width=224, height=224, capture_width=640, capture_height=480, capture_device=0)

capture a frame

1image =

create a widget to view

1import ipywidgets
2from IPython.display import display
3from jetcam.utils import bgr8_to_jpeg
5image_widget = ipywidgets.Image(format='jpeg')
7image_widget.value = bgr8_to_jpeg(image)

use a function to update frame

1camera.running = True
3def update_image(change):
4    image = change['new']
5    image_widget.value = bgr8_to_jpeg(image)
7camera.observe(update_image, names='value')

stop the stream

1camera.unobserve(update_image, names='value')

Second way to use the camera

1import traitlets
2#  traitlets dlink method to connect the camera to the widget, using a transform as one of the parameters. This eliminates some steps in the process.
3camera_link = traitlets.dlink((camera, 'value'), (image_widget, 'value'), transform=bgr8_to_jpeg)
4# remove the link
6# reconnect

Release the camera

1import os

GUI setting

Disabling the Desktop GUI

If you are running low on memory while training, you may want to try disabling the Ubuntu desktop GUI while you are training. This will free up extra memory that the window manager and desktop uses (around ~800MB for Unity/GNOME or ~250MB for LXDE)

You can disable the desktop temporarily, run commands in the console, and then re-start the desktop when you are done training:

1$ sudo init 3     # stop the desktop
2# log your user back into the console
3# run the PyTorch training scripts
4$ sudo init 5     # restart the desktop

If you wish to make this persistent across reboots, you can use the follow commands to change the boot-up behavior:

1$ sudo systemctl set-default     # disable desktop on boot
2$ sudo systemctl set-default      # enable desktop on boot



The Latest