Qualcomm Robotics RB5/RB6 - Neural Processing SDK: Getting Started

From RidgeRun Developer Wiki


Index





The Neural Processing SDK for Artifical Intelligence provides a set of tools to work on Machine Learning/AI Applications on the RB5/RB6 [1]. For this guide, we are using Qualcomm Neural Processing SDK for Linux v2.05.0, that is the latest version as of February, 2023. In this section, we are covering how to download the SDK and its dependencies. The Neural Processing SDK runs on your host computer, not in the Robotics RB5/RB6 platform. The host computer must have:

  • Required Operating System (OS): Ubuntu Linux 18.04.
  • Disk-space: CHECK
  • Python: Version 3.6
  • One of the following frameworks: Caffe and Caffe2, TensorFlow, ONNX, PyTorch, or TensorFlow Lite.

First, we are going to install and check the requirements needed to work with the Neural Processing SDK. In the section Install Python 3.6 we are going to see the steps on how to check your Python version and install the 3.6 one if you do not have it. Later, in section Install frameworks we are going to see how to install each of the supported frameworks to develop ML models; you can choose whichever one you prefer, it is not necesarry to install all of them. Finally, in section Get the Neural Processing SDK we are going to download the Neural Processing SDK.

Python

One of the requirements for the SDK is Python version 3.6. Python 3 is included in Ubuntu 18.04 by default, but here we are quickly showing you how to get it if you do not have it and also, how to make it your default version.

Install Python3.6

1. First, you can check which versions of Python come with your desktop using the following command:

ls /usr/lib/ | grep python

The output of the above command should be similar to the following:

python2.7
python3
python3.6
python3.7
python3.8

You can also run the following command to check the version of Python 3:

user@desktop:~$ python3 --version
Python 3.6.9

As you can see, in my computer I have Python 3.6 installed. If that is not your case, please continue with step 2.

WARNING
Do NOT delete any of the versions of Python already installed in your Ubuntu host computer for any reason. This could break your Ubuntu install.

2. Run the next commands in your host computer to download and install Python 3.6

sudo apt-get update
sudo apt-get install python3.6

You can check if the installation was successful with the commands from step 1.

Make Python3.6 default version

Python version 3.6 should be the one pointed when you run commands like python or check /usr/bin/python. To achieve this, you can use the following steps:

1. Create a list of alternatives for Python with the following commands:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2

2. Check the list you just created with the next command:

update-alternatives --list python

The output should be similar to the following:

/usr/bin/python2.7
/usr/bin/python3.6

3. Select the Python version 3.6:

sudo update-alternatives --config python

The output of the above command should look similar as below. Please choose option with version 3.6.

There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.6   2         auto mode
  1            /usr/bin/python2.7   1         manual mode
  2            /usr/bin/python3.6   2         manual mode

Press <enter> to keep the current choice[*], or type selection number: 0


Install packages

We need some Ubuntu and Python packages to work with the Neural Processing SDK, everyone of them is listed in the command below.

1. Run the following command to install the SDK's dependencies.

sudo apt-get install python3-dev python3-matplotlib python3-numpy python3-protobuf python3-scipy python3-skimage python3-sphinx wget zip

Install frameworks

As mentioned, you need one of the following frameworks to work with the Neural Processing SDK: Caffe and Caffe2, TensorFlow, ONNX, PyTorch, or TensorFlow Lite. In this section, we are showing you how to install any of them.

Caffe and Caffe2

For Caffe, please run the next command:

sudo apt install caffe-cpu

You can check if the installation was successful running the next command:

caffe --version

The output should be similar to the following::

caffe version 1.0.0


TensorFlow

To install TensroFlow, please use the command below. We are using version 2.3 since it's the one that has been tested with the Neural Processing SDK.

python3.6 -m pip install tensorflow==2.3

You can check if the installation was successful running the next command:

python3.6 -m pip show tensorflow

The output should be similar to the following::

Name: tensorflow
Version: 2.3.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /home/edson/.local/lib/python3.6/site-packages
Requires: absl-py, astunparse, gast, google-pasta, grpcio, h5py, keras-preprocessing, numpy, opt-einsum, protobuf, scipy, six, tensorboard, tensorflow-estimator, termcolor, wheel, wrapt
Required-by:


ONNX

To install ONNX, please use the command below.

python3.6 -m pip install onnx

You can check if the installation was successful running the next command:

python3.6 -m pip show onnx

The output should be similar to the following::

Name: onnx
Version: 1.13.1
Summary: Open Neural Network Exchange
Home-page: https://github.com/onnx/onnx
Author: ONNX
Author-email: onnx-technical-discuss@lists.lfaidata.foundation
License: Apache License v2.0
Location: /home/user/.local/lib/python3.8/site-packages
Requires: numpy, protobuf, typing-extensions
Required-by:


PyTorch

To install PyTorch, you can access the following link. In Figure 1, you can see that a table with options is presented.

PyTorch Get Started page.
Figure 1: PyTorch Get Started page.

In my case, I chose the stable version of PyTorch, for Linux OS, pip package manager for Python and to run in the CPU. Whichever options you choose, it will give you the command you need to run. The command to run is:

python3.6 -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu


You can check if the installation was successful running the next command:

python3.6 -m pip show torch

The output should be similar to the following::

Name: torch
Version: 1.13.1+cpu
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: https://pytorch.org/
Author: PyTorch Team
Author-email: packages@pytorch.org
License: BSD-3
Location: /home/user/.local/lib/python3.8/site-packages
Requires: typing-extensions
Required-by: torchaudio, torchvision


TensorFlow Lite

To install TensroFlow Lite, please use the command below. We are using version 2.3.0 since it's the one that has been tested with the Neural Processing SDK.

python3.6 -m pip install tflite==2.3.0

You can check if the installation was successful running the next command:

python3.6 -m pip show tflite

The output should be similar to the following::

Name: tflite
Version: 2.3.0
Summary: Parsing TensorFlow Lite Models (*.tflite) Easily
Home-page: https://jackwish.net/tflite
Author: 王振华(Zhenhua WANG)
Author-email: i@jackwish.net
License: UNKNOWN
Location: /home/edson/.local/lib/python3.6/site-packages
Requires: flatbuffers, numpy
Required-by:


Get the Neural Processing SDK

This section assumes that you are working on a host computer that meets the requirements above. The steps to get the Neural Processing SDK installed on your host computer are[2]:

Note
Note: This guide uses version 2.05.0 of the Neural Processing SDK.

1. Download the SDK's Linux version on your host computer. You can download version 2.05.0 from this link. Otherwise, you can check the Tools & Resources page for other versions.

Note
Note: The Xs are the version number of the SDK you downloaded.

2. After the download is complete, you should have a zip file with a name similar to snpe-<version>.zip. To unzip it, please run the following command:

unzip -X snpe-<version>.zip

If you downloaded version 2.05.0, you can use the next command:

unzip -X snpe-2.5.0.4052.zip


3. Verify that the downloading was successful by checking the files in the directory. For this, you can run the following commands:

Note
Note: Make sure to replace the directory <snpe-2.5.0.4052> with the appropriate name according to the zip file downloaded in step 1.
user@desktop:~/work/QRB5$ cd snpe-2.5.0.4052/
user@desktop:~/work/QRB5/snpe-2.5.0.4052$ ls
android     doc       lib          NOTICE.txt
benchmarks  examples  LICENSE.pdf  ReleaseNotes.txt
bin         include   models       share


At this point, you should have the Neural Processing SDK downloaded and all of the requirements. The next step is optional, and it is to download and install Android Studio. Android Studio provides a set of tools like a SDK and NDK to work with the Neural Processing SDK, but is completely optional and only required if you are going to build the examples provided in the Neural Processing SDK. Please check our wiki page on how to download Android Studio. Then, you can check our next section Setup Environment where we show how to setup everything you need to start working with the SDK and the QRBR5 board.

References

  1. Qualcomm Neural Processing SDK. Retrieved February 28, 2023, from [1]
  2. Qualcomm Neural Processing SDK for AI: Getting Started. Retrieved February 28, 2023, from [2]


Index