Stephen Smith's Blog

Musings on Machine Learning…

Archive for March 2019

Can NVidia Bake a Better Pi Than Raspberry?

with 6 comments

Introduction

I love my Raspberry Pi, but I find it’s limited 1Gig of RAM can be quite restricting. It is still pretty amazing what you can do with these $35 computers. I was disappointed when the Raspberry Foundation announced that the Raspberry Pi 4 is still over a year away, so I started to look at Raspberry Pi alternatives. I wanted something with 4Gig of RAM and a faster ARM processor. I was considering purchasing an Odroid N2, when I saw the press release from NVidia’s Developer Conference that they just released their NVidia Jetson Nano Developer Kit. This board has a faster ARM A57 quad core processor, 4 Gig of RAM plus the bonus of a 128 core Maxwell GPU. The claim being that this is an ideal DIY computer for those interested in AI and machine learning (i.e. me). It showed up for sale on arrow.com, so I bought one and received it via FedEx in 2 days.

Setup

If you already have a Raspberry Pi, setup is easy, since you can unplug things from the Pi and plug them into the Nano, namely the power supply, keyboard, monitor and mouse. Like the Pi, the Nano runs from a microSD card, so I reformatted one of my Pi cards to a download of the variant of Ubuntu Linux that NVidia provides for these. Once the operating system was burned to the microSD card, I plugged it into the Nano and away I went.

One difference from the Pi is that the Nano does not have built in Wifi or Bluetooth. Fortunately the room I’m setting this up in has a wired Internet port, so I went into the garage and found a long Internet cable in my box of random cables, plugged it in and was all connected to the Internet. You can plug a USB Wifi dongle in if you need Wifi, or there is an M.2 E slot (which is hard to access) for an M.2 Wifi card. Just be careful of compatibility, since the drivers need to be compiled for ARM64 Linux.

The board doesn’t come with a case, but the box folds into a stand to hold the board. For now that is how I’m running. If they sell enough of these, I’m sure cases will appear, but you will need to ensure there is enough ventilation for the huge heat sink.

Initial Impressions

The Jetson Nano certainly feels faster than the Raspberry Pi. This is all helped by the faster ARM processor, the quadrupled memory, using the GPU cores for graphics acceleration and that the version of Linux is 64 Bit (unlike Raspbian which is 32 Bit). It ran the pre installed Chromium Browser quite well.

As I installed more software, I found that writing large amounts of data to the microSD card can be a real bottleneck, and I would often have to wait for it to catch up. This is more pronounced than on the Pi, probably because other things are quite slow as well. It would be nice if there was an M.2 M interface for an NVMe SSD drive, but there isn’t. I ordered a faster microSD card (over three times faster than what I have) and hope that helps. I can also try putting some things on a USB SSD, but again this isn’t the fastest.

I tried running the TensorFlow MNIST tutorial program. The version of TensorFlow for this is 1.11. If I want to try TensorFlow 2.0, I’ll have to compile it myself for ARM64, which I haven’t attempted yet. Anyway, TensorFlow automatically used the GPU and executed the tutorial orders of magnitude faster than the Pi (a few minutes versus several hours). So I was impressed with that.

This showed up another gotcha. The GPU cores and CPU share the same memory. So when TensorFlow used the GPU, that took a lot of memory away from the CPU. I was running the tutorial in a Jupyter notebook running locally, so that meant I was running a web server, Chromium, Python, and then TensorFlow with bits on the CPU and GPU. This tended to use up all memory and then things would grind to a halt until garbage collection sorted things out. Running from scratch was fine, but running iteratively felt like it kept hitting a wall. I think the lesson here is that to do machine learning training on this board, I really have to use a lighter Python environment than Jupyter.

The documentation mentions a utility to control the processor speeds of the ARM cores and GPU cores, so you can tune the heat produced. I think this is more for if you embed the board inside something, but beware this sucker can run hot if you keep all the various processors busy.

How is it so Cheap?

The NVidia Jetson Nano costs $99 USD. The Odroid is $79 so it is fairly competitive with other boards trying to be super-Pis. However, it is cheaper than pretty much any NVidia graphics card and even their Nano compute board (which has no ports and costs $129 in quantities of 1000).

The obvious cost saving is no Wifi and no bluetooth. Another is the lack of a SATA or M.2 M interface. It does have a camera interface, a serial interface and a Pi like GPIO block.

The Nano has 128 Maxwell GPU cores. Sounds impressive, but remember most graphics cards have 700 to 4000 cores. Further Maxwell is the oldest supported platform (version 5) where as the newest is the version 7 Volta core.

I think NVidia is keeping the cost low, to get the DIY crowd using their technologies, they’ve seen the success of the Raspberry Pi community and want to duplicate it for their various processor boards. I also think they want to be in the ARM board game, so as better ARM processors come out, they might hope to supplant Intel in producing motherboards for desktop and laptop computers.

Summary

If the Raspberry Pi 4 team can produce something like this for $35 they will have a real winner. I’m enjoying playing with the board and learning what it can do. So far I’ve been pretty impressed. There are some limitations, but given the $100 price tag, I don’t think you can lose. You can play with parallel processing with the GPU cores, you can interface to robots with the GPIO pins, or play with object recognition via the camera interface.

For an DIY board, there are a lot of projects you can take on.

 

Ghidra

with one comment

Introduction

In my novel “Influence”, the lead character J@ck Tr@de searches for an easter egg in a server operating system. To do this he uses a disassembler which converts machine code back into source code. Normally you write computer programs in a programming language which a compiler (another program) reads through and converts to the bits and bytes that computers actually execute. In my novel, the disassembler uses AI to do an especially good job. I don’t know of any disassembler that uses AI yet, but a new really powerful disassembler has just been released by the NSA as open source. So I thought I’d spend a bit of time blogging on this, since it’s open source, perhaps someone will add some AI to it, so it is a powerful as the tool J@ck uses.

Most disassemblers either aren’t very good, or are quite expensive. This just changed when the NSA released their internally developed tool Ghidra as open source. I don’t know where the word Ghidra comes from, but the icon for the program is a dragon. I downloaded this and gave it a run. It was easy to install, ran well and looks really powerful. Why did the NSA do this? Don’t they usually guard their internal tools with their lives? They claim it’s to help security researchers at Universities and such do a better job discovering vulnerabilities in software, making us all safer as a result. I wonder if it’s the NSA trying to get some good publicity, since they are generally untrusted and most Americans got upset when it was revealed that the NSA could access any photo on any cell phones, including dick-pics. This really upset a lot of people, probably the only good thing a dick-pic has ever done.

For anyone interested, my novel, Influence, is available either as a paperback or as a Kindle download on Amazon.com:

Paperback – https://www.amazon.com/dp/1730927661
Kindle – https://www.amazon.com/dp/B07L477CF6

Installation

Ghidra is a Java program, so you need to have the Java 11 JDK installed first. I’m doing this on Ubuntu and didn’t already have Java installed. The Java that is installed by default apt-get is Java 10, so it didn’t work. To install Java 11, took a bit of Googling, but the following commands worked:

sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt-get install oracle-java11-installer

This adds an additional repository and then installs Java 11 from it. Then download Ghidra, uncompress it somewhere and run the shell script to start it.

Running

To play around with it, I created a new project and imported the executable file “head” from /usr/bin. This gave me some basic information on the executable:

It then takes a second to analyse the file and then I can launch the code browser and look through a split screen with the assembler code on the left and the generated C code on the right.

I can view a function call graph of the current function (the functions that call it and the functions that it calls).

I can view a function graph of the entire program that I can zoom in and out and browse around in.

I can annotate the program, add any insights I see. I can patch the program. All very powerful. Ghidra has full scripting support, the built in scripting language is Java, after all it is a Java program. But the API has support to add other scripting languages. There is a plug-in architecture so you can write extensions. It supports many executable formats and knows about many processor instruction sets.

Trust the NSA?

After I downloaded Ghidra, I watched a couple of YouTube videos on it. One of the presenters ran WireShark so he could see if Ghidra was making any network connections back to the NSA. After all, could this be a trojan horse that the NSA will use to find out what hackers are up to? At least this presenter didn’t see any network calls while he was running. But to a real hacker this could be major concern. As of this writing all the Java code has been open sourced, but some of the extra addons that are in other languages still need to be posted, so right now you can’t build Ghidra as it’s distributed, but the NSA say this should be remedied in a few weeks.

Summary

Although, perhaps not as powerful as what J@ck was using, this is a really powerful tool to reverse engineer programs and even operating systems. The generated source code isn’t great, but it’s helpful compared to just assembler. I think the expensive commercial disassembler vendors must be pretty upset as I really don’t see any reason for them to exist now? I think this will be a big boon to black and white hat hackers as well as to anyone that needs to reverse engineer some code (perhaps to figure out an undocumented API). Happy Hacking.

Written by smist08

March 6, 2019 at 9:19 pm