Snapdragon Neural Processing Engine SDK
Reference Guide
SNPE Setup

Installation

The chapter walks through the setup of tools required for SNPE and the SDK installation.

Prerequisites

  1. Currently the SNPE SDK development environment is limited to Ubuntu, specifically version 14.04.
  2. The SDK requires either Caffe, Caffe2, ONNX or TensorFlow.
    1. Instructions for Caffe: Caffe and Caffe2 Setup
    2. Instructions for TensorFlow: TensorFlow Setup
    3. Instructions for ONNX: ONNX Setup
  3. Python 2.7 or Python 3.4
    • "/usr/bin/python" and "python" should point to intended version. It can be achieved using following steps :-
                Create list of alternatives for python
                    $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
                    $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2
      
                Check the python list
                    $ update-alternatives --list python
      
                update alternative to select required python version
                    $ sudo update-alternatives --config python
  4. Android NDK (android-ndk-r17c-linux-x86) is optional and only required to build the native CPP example that ships with the SDK
    • SDK Android binaries built with clang require libc++_shared.so which is shipped with the SDK. (See Platform Runtime Libraries below).
  5. Android SDK (SDK version 23 and build tools version 23.0.2) is optional and only required to build the Android APK that ships with the SDK.

Setup SDK Environment and Dependencies

Instructions for setting up the SDK environment are as follows.

  1. Extract the SDK to a directory. The directory the SDK is extracted to is referred to as $SNPE_ROOT. Note the use of "X.Y.Z" in this section. It refers to the release zip that is in use (eg. snpe-1.0.0.zip).
    unzip -X snpe-X.Y.Z.zip
    
  2. Run the dependencies script to check the system for Ubuntu package dependencies. It will ask to install ones that are missing. Install the missing packages.
    source snpe-X.Y.Z/bin/dependencies.sh
    
  3. Run the python dependency checker to check the system for python package dependencies. Install the missing packages.

    source snpe-X.Y.Z/bin/check_python_depends.sh
    

    Python package versions tested with the SNPE SDK are:

    • numpy v1.8.1
    • sphinx v1.2.2
    • scipy v0.13.3
    • matplotlib v1.3.1
    • skimage v0.9.3
    • protobuf v2.5.0
    • pyyaml v3.10

Platform Runtime Libraries

$SNPE_ROOT refers to the directory path where the SNPE SDK is installed.

  • Aarch64 Linux Runtime Library Requirement
    The SDK requires libatomic.so.1. The SDK does not ship with this library so it needs to be copied into the library folder of SNPE SDK aarch64-linux
    cp <path_to_libatomic>/libatomic.so.1 $SNPE_ROOT/lib/aarch64-linux-gcc4.9/

Setup Environment

Building the Native C++ Example (Building Your First SNPE Native App) on Android requires the Android NDK installed with the ANDROID_NDK_ROOT exported as per the command below.

  export ANDROID_NDK_ROOT=<path_to_ndk>

If the ANDROID_NDK_ROOT is not set the environment setup script will attempt to find the NDK path by searching for ndk-build.

Environment setup for Caffe

  • Using the SNPE SDK with Caffe models requires a valid Caffe installation (see Caffe and Caffe2 Setup.)
  • Go to $SNPE_ROOT and run the following script to setup the SNPE SDK environment. The location of the Caffe directory must be provided.

    source bin/envsetup.sh -c $CAFFE_DIR
    
           where $CAFFE_DIR is the path to the Caffe installation.
    

  • The script may show warnings about mismatched Caffe SHA. The SHA that the script checks for is the SHA that the SDK has been tested with. It is ok to use a different version of Caffe, including a version built from source. This warning can be ignored.
  • The script sets up the following environment variables:
      SNPE_ROOT: root directory of the SNPE SDK installation
      CAFFE_HOME: root directory of the Caffe installation you provided ($CAFFE_DIR)
    
  • The script also updates PATH, LD_LIBRARY_PATH, and PYTHONPATH.

Environment setup for Caffe2

  • Using the SNPE SDK with Caffe2 models requires a valid Caffe2 installation. (see Caffe and Caffe2 Setup.)
  • Go to $SNPE_ROOT and run the following script to setup the SNPE SDK environment. The location of the Caffe2 directory must be provided.

    source bin/envsetup.sh -f $CAFFE2_DIR
    
           where $CAFFE2_DIR is the path to the Caffe2 installation.
    

  • The script sets up the following environment variables:
      SNPE_ROOT: root directory of the SNPE SDK installation
      CAFFE2_HOME: root directory of the Caffe2 installation you provided ($CAFFE2_DIR)
    
  • The script also updates PATH, LD_LIBRARY_PATH, and PYTHONPATH.

Environment setup for TensorFlow

  • Using the SNPE SDK with TensorFlow models requires a valid TensorFlow installation (see TensorFlow Setup.)
  • Go to $SNPE_ROOT and run the following script to setup the SNPE SDK environment. The location of the TensorFlow directory must be provided.
    source bin/envsetup.sh -t $TENSORFLOW_DIR
    
           where $TENSORFLOW_DIR is the path to the TensorFlow installation.
    
  • The script sets up the following environment variables.
      SNPE_ROOT: root directory of the SNPE SDK installation
      TENSORFLOW_HOME: root directory of the TensorFlow installation provided
    
  • The script also updates PATH, LD_LIBRARY_PATH, and PYTHONPATH.

Environment setup for ONNX

  • Using the SNPE SDK with ONNX models requires a valid ONNX installation (see ONNX Setup.)
  • Go to $SNPE_ROOT and run the following script to setup the SNPE SDK environment. The location of the ONNX directory must be provided.
    source bin/envsetup.sh -o $ONNX_DIR
    
           where $ONNX_DIR is the path to the ONNX installation.
    
  • The script sets up the following environment variables.
      SNPE_ROOT: root directory of the SNPE SDK installation
      ONNX_HOME: root directory of the TensorFlow installation provided
    
  • The script also updates PATH, LD_LIBRARY_PATH, and PYTHONPATH.