Open a terminal window, and run the following command to see the version of the GCC C/C++ compiler you have.
gcc --version
If gcc is not installed, follow the instructions in the next section.
Install the GCC/G++ Compilers
Open a new terminal window, and type:
sudo apt-get update
Now use this command to install a bunch of packages, including GCC, G++, and GNU Make:
sudo apt install build-essential
You might see some sort of error about things being locked if you try the following command. If you do, kill all processes that are using the APT package management tool using this command:
sudo killall apt apt-get
Remove the lock files:
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock*
Reconfigure the packages and update:
sudo dpkg --configure -a
sudo apt update
Now use this command to install numerous packages, including GCC, G++, and GNU Make:
sudo apt install build-essential
Press Y to continue.
Wait while the whole thing downloads.
Now, install the manual pages about using GNU/Linux for development (note: it might already be installed):
sudo apt-get install manpages-dev
Check to see if both GCC and G++ are installed.
whereis gcc
whereis g++
Check what version you have.
gcc --version
g++ --version
Install the C/C++ Debugger
In this section, we will install the C/C++ debugger. It is called GNU Debugger (GDB) and enables us to detect problems or bugs in the code that we write.
In the terminal window, type the following command:
sudo apt-get install gdb
You will be asked to type your password, and then click Enter.
Type the following command to verify that it is installed:
gdb
Type this command to quit.
quit
Press Enter.
Exit the terminal.
exit
Install Gedit
Install gedit, a text editor that will enable us to write code in C/C++.
Open a terminal window, and type:
sudo apt-get install gedit
Write a Hello World Program in C
Let’s write a program that does nothing but print “Hello Automatic Addison” (i.e. my version of a “Hello World” program) to the screen.
Open a new terminal window, and create a new folder.
mkdir cpp_basics
Move to that folder.
cd cpp_basics
Open a new C program.
gedit hello_automaticaddison_c.c
#include<stdio.h>
int main()
{
printf("Hello Automatic Addison\n");
return 0;
}
// Simple C++ program to display "Hello Automatic Addison"
// Header file for input output functions
#include<iostream>
using namespace std;
// main function
// where the execution of program begins
int main()
{
// prints hello world
cout<<"Hello Automatic Addison";
return 0;
}
Save the file, and close it.
See if your file is in there.
ls
Compile the program. All of this is just a single command.
To install Python, open a new terminal window and type:
sudo apt-get install python python3
To find out where the Python interpreter is located, type this command.
which python
You should see:
/usr/bin/python
Install Gedit
Install gedit, a text editor that will enable us to write code in Python.
sudo apt-get install gedit
Install Pip
Let’s begin by installing pip. Pip is a tool that will help us manage software packages for Python.
Software packages are bundles of code written by someone else that are designed to solve a specific problem. Why write code to solve a specific problem from scratch, when someone else has already written code to solve that exact same problem? That is where software packages come into play. They prevent you from having to reinvent the wheel.
Open up a fresh Linux terminal window.
Type the following command to update the list of available packages that can be installed on your system.
sudo apt-get update
Type your password.
Upgrade all the packages. The -y flag in the following command is used to confirm to our computer that we want to upgrade all the packages.
sudo apt-get -y upgrade
Type the following command to check the version of Python you have installed.
python3 --version
My version is 3.6.9. Your version might be different. That’s fine.
Now, let’s install pip.
sudo apt-get install -y python3-pip
If at any point in the future you want to install a Python-related package using pip, you can use the following command:
pip3 install package_name
Create a Virtual Environment
In this section, we will set up a virtual environment. You can think of a virtual environment as an independent workspace with its own set of libraries, settings, packages, and programming language versions installed.
For example, you might have a project that needs to run using an older version of Python, like Python 2.7. You might have another project that requires Python 3.8. Setting up separate virtual environments for each project will make sure that the projects stay isolated from one another.
Let’s install the virtual environment package.
sudo apt-get install -y python3-venv
With the software installed, we can now create the virtual environment using the following command. The dot(.) in front of py3venv makes the directory a hidden directory (the dot is optional):
python3 -m venv .py3venv
Type the following command to get a list of all the directories. You should see the .py3venv folder there.
ls -a
List all the contents inside the .py3venv folder.
ls .py3venv/
Now that the virtual environment has been created, we can activate it using the following command:
source ~/.py3venv/bin/activate
Look what happened. There is a prefix on the current line that has the name of the virtual environment we created. This prefix means that the .py3venv virtual environment is currently active.
When a virtual environment is active that means that when we create software programs here in Python, these programs will use the settings and packages of just this virtual environment.
Keep your terminal window open. We’re not ready to close it just yet. Move on to the next section so that we can write our first program in Python.
Write a “Hello World” Program
Let’s write a program that does nothing but print “Hello Automatic Addison” (i.e. my version of a “Hello World” program) to the screen.
In this tutorial, I will show you everything you need to know to get started with the NVIDIA Jetson Nano. The official tutorial is here, but I will run through all the steps below. I recommend you go through these steps slowly. It took me a full day to set up the Jetson Nano, so be patient and enjoy the journey.
You Will Need
This section is the complete list of components you will need for this project (#ad).
Disclosure (#ad): As an Amazon Associate I earn from qualifying purchases.
Write the Operating System Image to the microSD Card
The first thing we need to do is to prepare the operating system. The Jetson Nano uses a microSD card for storing the operating system.
Grab your SD/Micro SD Card Reader with Standard USB Connector.
Grab your tiny 128GB MicroSD Card, and slide it into the adapter.
Put the adapter into the SD card reader.
Plug the SD card reader into your PC.
Check to see if the SD card reader appears in your lists of disks. Make a note of where this is on your PC. My SD card reader shows up as my F drive.
Download the Jetson Nano Developer Kit SD card image file (often called “JetPack”) to your PC. Mine will save to my Desktop. It is a large file and will take a long time to download. Just go get something to eat and come back when it is finished.
Now, we need to write the image to our microSD card. The instructions will vary depending if you have Windows, Mac OS, or Linux. I have a Windows PC, so here is what I will do next.
Click “Flash from file” and choose the zipped Nano Jetson image file you downloaded earlier.
Insert your microSD card if not already inserted.
Click “Select target” and choose the SD card’s drive. Remember mine is on the F drive.
Click “Flash!” It will take Etcher a while to write and validate the image, so go do something else and come back.
After Etcher finishes, Windows may let you know it doesn’t know how to read the SD Card. Just click Cancel all those screens and remove the microSD card.
Just cancel all of these weird pop ups.
Setup and First Boot
Unfold the paper stand, and place the Nano Jetson inside the developer kit box.
Set the developer kit on top of the paper stand.
Insert the microSD card (with system image already written to it) into the slot on the underside of the Jetson Nano module.
Make sure the jumper is pushed into the J48 Power Select Header pins.
Connect the Jetson Nano into your monitor. I am using an HDMI cable to connect my monitor to my Jetson Nano. If you don’t have one, you can buy one off Amazon or any other electronic retailer.
Connect the Jetson Nano into your keyboard.
Connect the Jetson Nano into your mouse.
Grab the “Power Supply Applicable for Jetson Nano 5V/4A OD 5.5mm ID 2.1mm”.
Connect the power supply to the 5V/4A Power Jack. The developer kit will power on automatically.
Allow 1 minute for the developer kit to boot.
A green LED next to the Micro-USB connector will light as soon as the developer kit powers on. When you boot the first time, the developer kit will take you through some initial setup, including:
Review and accept NVIDIA Jetson software End User License Agreement.
Select the system language.
Select the keyboard layout.
Select the time zone.
Create a username, password, and computer name. Be sure to select “Log in automatically.”
Select APP partition size. NVIDIA recommends to use the maximum size.
Here is the screen you should see now.
Update QSPI process and click Continue.
Keep the default setting for the Nvpmodel Mode, and click Continue.
Your Nvidia will automatically reboot to the Ubuntu desktop.
Click the Terminal icon in the bottom-left.
Restart the computer again.
sudo reboot
Set Up WiFi
Grab your WiFi adapter.
Plug it into one of the USB ports on the Jetson Nano.
To set up WiFi, you can use the following command in a terminal window (sudo nmtui), or follow the steps below.
Click the settings (gear) icon in the upper right corner of the desktop.
Click System Settings in the drop down menu.
Click the Network dialog in the dialog box.
Set up the network connection.
Reboot the computer.
sudo reboot
Your computer might pop up a Software Updater dialog. You can click Install Now.
Right click on the Desktop.
Open the Terminal.
Check if your WiFi setup is fine.
ping google.com
Turn off the power save mode to get stability.
sudo iw dev wlan0 set power_save off
sudo reboot
Run Updates
Let’s update our package list and upgrade the software on the system.
Open the terminal, and type:
sudo apt-get update
sudo apt-get upgrade
Type Y and press Enter to upgrade everything.
Reboot the computer.
sudo reboot
Collect Information About Your Jetson Nano
Open a terminal window, and type the following command.
hostname -I
Make a note of your internal IP address.
Change the Power Supply Settings
If you are using the 5V/4A power supply like I am, open your terminal window, and type:
sudo nvpmodel -q
If you see the following, you are good to go.
NV Power Mode: MAXN
Otherwise, type the following command:
sudo nvpmodel -m 0
This command will give you high power performance. If you want to change it to low performance because you are using microUSB to power the Jetson Nano, here is the command:
sudo nvpmodel -m 1
Create a Swap File
Some of the applications I will use on my Jetson Nano require a lot of memory. To keep the Nano from crashing, we need to create a swap file.
See if your Nano already has swap space.
free -h
If you don’t have swap space, add a 4GB swap file.
Once the Nano is done rebooting, see if you have swap space.
free -h
Connect to Your NVIDIA Jetson Nano Remotely From Your PC
Now I will show you everything you need to know to connect to your NVIDIA Jetson Nano desktop remotely from your own PC (on the same WiFi network) using an application called VNC Viewer.
Save RAM By Using the LXDE Desktop
First, let’s free up some RAM to keep our Nano from crashing.
Type the following command. Your computer will then reboot to a login screen.
$DESKTOP_SESSION
On the login screen, click the gear icon next to “Sign In”.
Scroll down, and select LXDE.
Type your password, and click Sign In.
LXDE is now your desktop environment.
Reboot.
sudo reboot
Open a terminal window in your Nano, and type the following command to see what desktop environment you’re using.
echo $XDG_CURRENT_DESKTOP
See how much free memory you have.
free
Now open a terminal window, and change the display manager from gdm3 (GNOME display manager) to lightdm.
If you’re using Windows, go to your PC, and download and install VNC Viewer.
Launch the VNC viewer and type in the IP address of your Jetson Nano. You can also go to File -> New Connection
If you have configured the VNC server for authentication, provide the VNC password.
The remote desktop connection lag might be very strong.You change the desktop resolution by clicking in the bottom-left and going to Preference -> Monitor settings.
I’m not a huge fan of the remote desktop for the Jetson Nano. Raspberry Pi is far superior. Hopefully the guys at NVIDIA fix that in the future by building in WiFi to their boards.
Now, power OFF your Jetson Nano.
sudo shutdown -h now
Remove the power supply, and then plug it back in.
After you have downloaded it, launch the NoMachine application on your PC.
Double click on your Jetson Nano icon (i.e. Ubuntu 18.04).
Click Yes.
Type in the username and password for the Jetson Nano machine.
Click through the prompts, and you will see your Desktop appear.
Now, power OFF your Jetson Nano.
sudo shutdown -h now
Remove the power supply, and then plug it back in.
Install Putty (Optional)
Putty is a program that will enable us to connect to the Jetson Nano’s terminal only.
Go to putty.org and download the installer for your machine. I am using a 64-bit Windows computer so that is what I will select.
Follow the instructions to download Putty. Once you’ve finished, open up Putty. If you’re using Windows, you can usually find it in the Start Menu.
The first thing you will do is type in the IP address of your Jetson Nano.
Select the SSH radio button.
Click the Open button.
If you get a popup window, click “Yes” and then you will go to a black terminal window.
Type in the username and password of your Jetson Nano.
That’s it. You’re logged in to your Jetson Nano via the command line interface.
You are now good to go.
Next Steps
A lot of Jetson Nano projects involve heavy computation (e.g. deep learning and robotics), which can make the board heat up pretty quickly. I recommend buying and setting up your Jetson Nano with a cooling fan and case.
Whew! That was a lot of work setting up the NVIDIA Jetson Nano.