Qualcomm Robotics RB5/RB6 - Neural Processing SDK: Setup Environment

From RidgeRun Developer Connection
Jump to: navigation, search



Index






In this section, we will show the steps on how to setup the environment for the Neural Processing SDK. This section assumes that you already have the SDK downloaded, the needed Python version, and one framework for ML development. If not, please check our Downloading Requirements section first and then come back here. We need to setup the environment[1] to allow the SDK to work via Python APIs with any of the following frameworks: Caffe, TensorFlow, ONNX, PyTorch, and TensorFlow Lite. First, we are going to check the dependencies needed to work with the SDK and how to install them if they are missing. Then, how to setup the environment for each framework.

Setup Environment

1. Open a terminal an go to the directory where you downloaded and unzipped the Neural Processing SDK, and enter the directory.

Note
Make sure to change the directory path to where you downloaded and unpacked Android Studio.
cd ~/work/QRB5/snpe-2.5.0.4052

2. The SDK comes with scripts to check its dependencies. In here, we are checking dependencies with Ubuntu packages, when running the script it will ask you to install any missing package, please do it.

source bin/dependencies.sh

If everything is right, your output should look similar to the following:

Checking for python3-dev: install ok installed
Success: Version of python3-dev matches tested version
Checking for wget: install ok installed
Success: Version of wget matches tested version
Checking for zip: install ok installed
Success: Version of zip matches tested version
Checking for libc++-9-dev: install ok installed
Success: Version of libc++-9-dev matches tested version

If you need to install any package, you can use the following command:

sudo apt install <package>


3. Now, we are going to check the system for the Python package dependencies. If any package is missing, please install it.

source bin/check_python_depends.sh

The output should look similar to the following:

Supported version of Python found: 3.6
Checking for python3-numpy: install ok installed
WARNING: It appears the python module numpy is installed on this system using the apt-get distribution as well as pip. If you encounter errors, please use only one distribution.
===========================================
Checking for python-sphinx: 
sphinx installed via pip Version: 2.2.1
===========================================
Checking for python3-scipy: install ok installed
WARNING: It appears the python module scipy is installed on this system using the apt-get distribution as well as pip. If you encounter errors, please use only one distribution.
===========================================
Checking for python3-matplotlib: install ok installed
WARNING: It appears the python module matplotlib is installed on this system using the apt-get distribution as well as pip. If you encounter errors, please use only one distribution.
===========================================
Checking for python3-skimage: install ok installed
WARNING: It appears the python module scikit-image is installed on this system using the apt-get distribution as well as pip. If you encounter errors, please use only one distribution.
===========================================
dpkg-query: no packages found matching python-protobuf
Checking for python-protobuf: 
protobuf installed via pip Version: 3.19.6
===========================================
Checking for python3-yaml: install ok installed
WARNING: It appears the python module pyyaml is installed on this system using the apt-get distribution as well as pip. If you encounter errors, please use only one distribution.
===========================================
Checking for python3-mako: install ok installed
WARNING: It appears the python module mako is installed on this system using the apt-get distribution as well as pip. If you encounter errors, please use only one distribution.
Note
If you do not have the same version, it doesn't mean the SDK won't work.

Every package has different versions, the SDK has been tested with the following ones:

  • numpy v1.16.5
  • sphinx v2.2.1
  • scipy v1.3.1
  • matplotlib v3.0.3
  • skimage v0.15.0
  • protobuf v3.6.0
  • pyyaml v5.1

If you need to install any package, you can use the following command:

python3.6 -m pip install <package==version>

4. If you downloaded Android Studio, initialize the Qualcomm Neural Processing SDK environment by running the following command:

Note
Please change <path_to_Android_Studio_installation> to the path where you installed Android Studio.
export ANDROID_NDK_ROOT=<path_to_Android_Studio_installation>/Android/Sdk/ndk-bundle


5. Setup the environment for your chosen framework. This initialization will update the $PATH and other environment variables.

Note
We will use the environment variable SNPE_ROOT to refer to the path where you unzipped the Neural Processing SDK. Please change <path_to_SDK_installation> to where you unzipped the SDK and <version> with your downloaed version.

First, we are going to define SNPE_ROOT with the following command:

export SNPE_ROOT=<path_to_SDK_installation>/snpe-<version>

An example of the above command is:

export SNPE_ROOT=~/snpe-2.5.0.4052

Now, move to the SDK directory with:

cd $SNPE_ROOT

Finally, while you are in the $SNPE_ROOT directory, setup the environment for any framework. For each, you need to know their installation path, this can be done in two ways, the first one is with the following command:

which <package>

For example, testing with caffe:

user@desktop:~$ which caffe
/usr/bin/caffe

The other option, for Python packages is with the following command:

python3.6 -m pip show <package> | grep Location

To the above output, you should add the name of the package to the direction. For example, if you want to know the installation path of TensorFlow, you can run:

python3.6 -m pip show tensorflow | grep Location

The output of the above command is:

Location: /home/user/.local/lib/python3.6/site-packages

So the path of installation of TensorFlow will be:

/home/user/.local/lib/python3.6/site-packages/tensorflow

And you can define the variable like this:

export $TENSORFLOW_DIR=/home/user/.local/lib/python3.6/site-packages/tensorflow
  • Environment setup for Caffe

To setup Caffe, please run the following command:

source bin/envsetup.sh -c $CAFFE_DIR


  • Environment setup for Caffe2

To setup Caffe2, please run the following command:

source bin/envsetup.sh -f $CAFFE2_DIR


  • Environment setup for TensorFlow

To setup TensorFlow, please run the following command:

source bin/envsetup.sh -t $TENSORFLOW_DIR


  • Environment setup for ONNX

To setup ONNX, please run the following command:

source bin/envsetup.sh -o $ONNX_DIR


  • Environment setup for TensorFlow Lite

To setup TensorFlow Lite, please run the following command:

 source bin/envsetup.sh --tflite $TFLITE_DIR


6. You are done setting up your environment! If your board does not come with the GStreamer element qtimlesnpe, please check our Install qtimlesnpe section to check the steps to install it in your RB5/RB6 board. If you already have the element, continue with our Example Project wiki to see an example on how to use the SDK.

References

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


Index