Pages

Wednesday, 15 May 2019

Getting started with the Jetson Nano - part 3

Jetson Nano image courtesy of NVIDIA/Pimoroni
In part 2 of this series you prepared your Jetson Nano for software installation.

In this part you'll install Jupyter Notebook, Jupyter lab, TensorFlow and some other software that is needed to run the first TensorFlow notebook.

Once started, you can leave the software installation to run; it takes about an hour on a Nano in 10W power mode. It probably takes a little longer if you're using a 2.5A supply.

There's a final manual stage which takes a couple of minutes.

When that's complete you'll be able to work through the TensorFlow example, training a Neural Net to recognise item images from a Fashion database and then testing it in previously unseen images.

Here's what you'll do, in a little more detail.

Installing the software


Open a terminal window on the Nano  (A short-cut,  crl-alt-T should do it).

You'll be in your home directory; type

git clone https://github.com/romilly/nano.git

You should see a message 'cloning into nano' followed by some descriptive text.

Next, change into the newly-created nano directory and list the contents. Type

cd nano
ls 

You should see a display like this: 



Now change into the scripts directory, prepare the scripts for execution, and check the contents. Type

cd scripts
chmod a+x *.sh
ls

The result should look like this:







If you're cautious (and you should be!) you can check the contents of the scripts before you run any of them. You can use the linux cat command. Type

cat nano-tf-01.sh

The result should look like this:


The script has comments which explain what each line does.

You're ready to start installation.

Type

sudo -H ./nano-tf-01.sh


You will be asked for your password. Enter it.

The installation process will start. You can go and drink a coffee, cook a meal, or do a run - the installation should need no input, but it will take an hour or more.

The final screen should look something like this:


 Nearly there! The next steps will only take a couple of minutes.


Configure Jupyter 



Now you need to configure Jupyter Notebook ready for use.

You had to run the previous command as the super-user, using the sudo command, but you shouldn't do that for the next command. Just type

./configure-jupyter.sh

That will set up the Jupyter notebook with nano as its password.

If you want a different password - foo for example - you could instead type

./configure-jupyter.sh foo

One more step and you'll be ready to go. The next step will install the Jupyter server as a service. In other words, Jupyter will start up whenever the Nano is rebooted. Since you are changing the system configuration, you will need to run the final script as sudo. Type

sudo ./install-service.sh

Which will install the service and start it.

To check that it's running, go to a computer on your local network and open a browser on

http://:8888

Where is the hostname you chose when installing Ubuntu on your Nano.

You'll be asked for a password. Enter nano, or the password you chose just now when configuring Jupyter, if you decided not to accept the default.

You should see a screen like this:


Fantastic! You now have a powerful Deep Learning laboratory ready for your experiments.

And there's more good news. From now on, you have a choice. You can continue to use your Nano with a monitor, mouse and keyboard, or you can use it remotely from any computer on your network. That's how I work.

If you want to un-clutter your workspace by removing the monitor, mouse and keyboard, the next step will involve

  1. shutting down your Nano (see below)
  2. removing power.
  3. unplugging the peripherals, and then
  4. reapplying power

There are two ways you can shut down the Nano. You could use the mouse to click on the power icon at the top right of the Ubuntu desktop, but that won't work once you start running the Nano headless (without keyboard, mouse and monitor attached).

Instead you can shut the nano down from the browser window! Here's a short video:



To do that,

  1. Click on the terminal icon in the launcher window. A terminal window will open.
  2. In the terminal window, type sudo shutdown now -h 
  3. When prompted, enter your password.
In a couple of seconds yoiu should see the green light on the Nano go out, It is now safe to remove poser by unplugging the power supply. You can close the browser tab containing the Jupyter interface.

Unplug the monitor, mouse and keyboard. If you want to, you can move the Nano to a new home at this stage. Remember that it will need power and an Ethernet connection in its new home!

Once the Nano is where you want it, make sure the Ethernet cable is plugged in and apply power. The green light on the Nano will come on again.

Give the nano a few seconds to boot up and open a browser window on the same url as before: http://:8888

Once again, you'll be asked for the Jupyter password. Next you'll open a Jupyter Notebook and run your first TensorFlow example.

Below, you'll find step by step instructions. First, a video.



Here's what you need to do:

  1. In the left-hand pane, click on notebooks.
  2. Click on basic-classification.ipynb. The notebook will open.
  3. Click on the run menu and chose run all cells.
Jupyter will run each code cell in the notebook, displaying the results as the code completes. You'll see some of the fashion images that the notebook is using to traint the network, and at the end you'll see how well images are classified once training is complete.

If you're new to Deep Learning, Jupyter or TensorFlow you may not follow everything that's going on.

Don't worry.

The next posts will take a much slower-paced run through another notebook, with more detailed explanation, and introduce the ideas of model import and export, and  transfer learning.

To make sure you don't miss out on future posts, follow me (@rareblog) on twitter.



















Monday, 13 May 2019

Getting Started with the Jetson Nano - Part 2

Learning with the Nano
It's taken a while to get here, but I now have a simple, repeatable set-up process for installing and running TensorFlow on the Jetson Nano using Jupyter Notebooks.

It's simple and repeatable but slow. Jupyter Notebook saves a lot of time and angst once it's available but it takes a while to install.

Fortunately I now have a script that automates the installation so you can go away and drink a coffee while the installation runs.

Before you can install the software, though, you need to complete the installation of Ubuntu. That's what this post covers.

My first post about the Nano described the hardware you need and pointed you to instructions that explain how to prepare your SD card.

Once you've got your hardware and have prepared the SD card, it's time to fire up the Nano.

Getting ready

Plug in the HDMI cable, the Ethernet cable, the keyboard and the mouse. There's a good illustration on the Jetson Nano 'getting started' page.

SD card before it's pushed in
Next, insert the SD card in its socket. The socket is not easy to find  and the picture on the NVIDIA site is a bit confusing.

I hope this picture makes things clearer >>>

This is taken from the bottom of the Nano. When you look at the Nano from above, the SD card should have its shiny contacts facing you.

Once the card is in its slot, push it in. It should click home. It is then almost invisible.

Now you're ready to apply power.


Powering up



The power-up process is slightly different depending on whether you are using the recommended 4A supply with a barrel Jack or a 2.5A supply with a micro USB connector.

Using a 4A supply


4A barrel jack power + jumper
If you are using a 5V 4A supply you should place a jumper on J48. It's just behind the Power Jack Socket and it's marked ADD JUMPER TO DISABLE USB POWER.

Now insert the power jack. The green light should come on and the Nano will boot.

Skip the next paragraph and carry on with the steps below headed 'Nano - first boot'

 Using a 2.5A supply


USB power
If you're using a 5V 2.5A supply, insert the USB micro-connector into the Nano's USB socket. The Nano should look like this.

Once again, the green light should come on and the Jetson will boot.


 

Nano - first boot


As the Nano starts up you'll see messages scroll by.  After about 20 seconds you should see a dialog box asking you to accept the NVIDIA license agreement.

Next Ubuntu will ask you questions to help it manage the installation process. You'll need to specify what language you want to use, what keyboard you're using, and which timezone you're in.

After that you'll be asked for your name, the hostname you want the nano to have oin your network, and a password. I don't recommend passwordless login; even on a home network, I don't think it's safe.

The installation will carry on for a few minutes and the Nano should then reboot. The process sometimes appears to hang with a dialog waiting for an auto-update. If so, you can just cancel the dialog. You can update the Jetson software at the start of the TensorFlow installation process.

Once the Jetson has booted you should see a standard Ubuntu login page. Select your username, enter your password, and you'll see the Ubuntu desktop.

Coming next


In the next post you will install TensorFlow and Jupyter notebook. Then you'll start the notebooks server and train a TensorFlow model which will recognise images of fashion items and classify them.

Don't miss the next steps:  follow me (@rareblog) on Twitter.









Monday, 6 May 2019

Getting Started with the Jetson Nano


If you want to get to grips with Deep Learning at the Edge, NVIDIA's Jetson Nano is an excellent choice.

It combines a powerful, fast Quad Core Arm processor with a powerful NVIDIA GPU capable of just under 0.5 Teraflops.

Better yet, it has 4 GigaBytes of RAM. That's enough to do serious work with TensorFlow or PyTorch, both of which are supported on the platform.

And it costs around $100 in the USA, or around £120 with shipping in the UK!

There are instructions for setup on the NVIDIA Jetson Nano website, but I found them a bit daunting, and they miss out on a couple of bits of advice I wish I'd had when I started.

Before you start

The first time you boot your Nano you'll want
  1. A micro-SD card. I recommend at least 32 GB; 64 GB would be better.
  2. An HDMI monitor. It must be HDMI. You cannot use a DVI monitor with a DVI-to-HDMI adaptor of the sort you might use with a Raspberry Pi or a workstation.
  3. A USB mouse.
  4. A USB keyboard.
  5. An ethernet cable.
  6. A suitable 5V power supply.

A 5V 2.5A supply with a micro USB connector will work. A 4A supply with a 5.5mm outer diameter (OD) x 2.1 mm inner diameter connector is better, for reasons I've set out below.


If you decide to go with a 4A supply you'll also need a Jumper.

Here's why I advise you to get a 4A supply.

Out of the box your Nano will use 2A of current. However, your mouse and keyboard may take the current draw over 2A. If the voltage drops your Nano will shut itself down. This happened to me on my first attempt, and it's very disconcerting.

A 2.5A supply should avoid that problem, but there's another.

The Nano has two power modes. The default mode only uses 2 amps but this restricts the CPU to single core operation. The max power configuration will give you full access to the Nano's processing power, but the Nano will then draw more than 2A of current.

If you decide to stick with a 2.5A power supply and you're based in North America you can use this one.

Alternatively you can use the official Raspberry Pi power supply for the Pi model 3B, since that also provides 2.5A.

I've recommended two 4A supplies below. One comes from North America, and the other is available from a UK supplier.
  1. In North America: Adafruit 5V 4A Switching PSU
  2. In the UK: 5V 4A 4000mA AC-DC Switching Adaptor Power Supply
The Adafruit supply was out of stock when I wrote this, possible due to the demand from Nano owners, but you can ask to be notified when stock is available.

If you're going to power the Nano with a 4A supply you'll also need a jumper to tell the Nano to power itself from its power Jack socket instead of the micro-USB socket.

The NVIDIA website has details, but I suggest you visit the excellent JetsonHacks website which has more information on power options and shows you just where to install the Jumper.

Prepare the SD card

 

You'll need to download the latest NVIDIA Jetson Nano image NVIDIA Jetson Nano image and write it onto the SDS card using an SD card writer and appropriate software on your computer.

If you've prepared an SD card for a Raspberry Pi the process is very similar.

The way you do it depends on the Operating System you're using. The NVIDIA website provides instructions for WIndows, MAC and Linux, and theyr'e pretty good.

Tomorrow I'll go through the remainder of the setup process and describe how to train your first Deep Learning model on the Nano. Later I'll be posting more details of my Nano experiments.

To stay up to date, you can follow me (@rareblog) on Twitter.