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 18.04.
    We have also verified the SDK to work seamlessly on the Windows Subsystem for Linux(WSL2) environment version 1.1.3.0.
    If you wish to set up your own WSL2 environment, you can follow the instructions provided by Microsoft at
    https://learn.microsoft.com/en-us/windows/wsl/install.
  2. The SDK requires either Caffe, Caffe2, ONNX, PyTorch, TensorFlow or TFLite.
    1. Instructions for Caffe: Caffe and Caffe2 Setup
    2. Instructions for TensorFlow: TensorFlow Setup
    3. Instructions for ONNX: ONNX Setup
    4. Instructions for TFLite: TFLite Setup
    5. Instructions for PyTorch: PyTorch Setup
  3. Python 3.6
    • "/usr/bin/python" and "python" should point to Python 3. 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.6 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.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

Platform Runtime Libraries

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

  • Aarch64 Linux Runtime Library Requirement
    libatomic.so.1 is required for Aarch64 Linux targets. On newer target devices, this is available in the platform SW in the library path. For those platforms (for example which use aarch64-oe-linux-gcc8.2 toolchain), on which this library is not available on the device, it needs to be copied explicitly from SNPE SDK.

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.

Environment setup for TFLite

  • Using the SNPE SDK with TFLite models requires a valid TFLite installation (see TFLite Setup.)
  • Go to $SNPE_ROOT and run the following script to setup the SNPE SDK environment.
    source bin/envsetup.sh
    
  • The script sets up the following environment variables.
    SNPE_ROOT: root directory of the SNPE SDK installation
    
  • The script also updates PATH, LD_LIBRARY_PATH, and PYTHONPATH.

Environment setup for PyTorch

  • Using the SNPE SDK with PyTorch models requires a valid PyTorch installation (see PyTorch Setup.)
  • Go to $SNPE_ROOT and run the following script to setup the SNPE SDK environment.
    source bin/envsetup.sh
    
  • The script sets up the following environment variables.
    SNPE_ROOT: root directory of the SNPE SDK installation
    
  • The script also updates PATH, LD_LIBRARY_PATH, and PYTHONPATH.