Setup¶
This page outlines the required setup to use the Qualcomm® Neural Processing SDK. The page is split into Linux Platform Dependencies , Windows Platform Dependencies and Environment Setup.
Linux Platform Dependencies¶
Host OS¶
The Qualcomm® Neural Processing SDK is verified with the Ubuntu 22.04 LTS (Focal) Linux host operating system. The Qualcomm® Neural Processing SDK is also verified to work in the Windows Subsystem for Linux (WSL2) environment, version 1.1.3.0, but currently limited to Linux host runnable artifacts such as converters, model generation and run tools. To set up your own WSL2 environment, follow the instructions provided by Microsoft at https://learn.microsoft.com/en-us/windows/wsl/install.
Python¶
The Qualcomm® Neural Processing SDK distribution is supported on python3. Download and installation instructions vary based on the host OS. The SDK has been tested with python3.10. If python3.10 is not already installed on your system, you may install it with the following commands:
$ sudo apt-get update
$ sudo apt-get install python3.10 python3-distutils libpython3.10
Virtual Environment (VENV)
Whether managing multiple python installations or just to keep your system python installation clean we recommend using python virtual environments.
$ sudo apt-get install python3.10-venv
$ python3.10 -m venv "<PYTHON3.10_VENV_ROOT>"
$ source <PYTHON3.10_VENV_ROOT>/bin/activate
Note
If your environment is in WSL, <PYTHON3.10_VENV_ROOT> must be under $HOME.
Additional Packages: To interact with Qualcomm® Neural Processing components and tools, additional python3 packages must be available in your environment. This Qualcomm® Neural Processing SDK release is verified to work with the following package versions:
Package |
Version |
|---|---|
absl-py |
2.1.0 |
decorator |
4.4.2 |
invoke |
2.0.0 |
joblib |
1.4.0 |
lxml |
4.6.3 |
Mako |
1.1.0 |
matplotlib |
3.3.4 |
numpy |
1.26.4 |
opencv-python |
4.5.4.58 |
packaging |
24.0 |
pandas |
2.0.1 |
pathlib2 |
2.3.6 |
Pillow |
10.2.0 |
protobuf |
3.19.6 |
PyYAML |
5.3 |
scipy |
1.10.1 |
six |
1.16.0 |
tabulate |
0.8.5 |
typing-extensions |
4.10.0 |
xlsxwriter |
1.2.2 |
Run the following script to check and install missing dependencies:
$ python3 -m pip install --upgrade pip
$ ${SNPE_ROOT}/bin/check-python-dependency
Note
To set SNPE_ROOT see Environment Setup for Linux.
Matplotlib with 3.5.0 and Pandas with 2.0.2 have been verified on Windows.
Linux¶
Clang++ is required to compile artifacts for the x86_64 target. This Qualcomm® Neural Processing SDK release is verified to work with Clang 14.
Run the following script to check and install missing Linux dependencies:
# Note: Run the following command as administrator/root to install system libraries.
$ sudo bash ${SNPE_ROOT}/bin/check-linux-dependency.sh
Note
To set SNPE_ROOT see Environment Setup for Linux.
ML Frameworks¶
To convert ML models trained on different frameworks into intermediate representations consumable by the Qualcomm® Neural Processing SDK you may need to download and install the corresponding frameworks on your host machine.
This Qualcomm® Neural Processing SDK release is verified to work with the following versions of the ML training frameworks:
TensorFlow: tf-2.10.1
TFLite: tflite-2.3.0
PyTorch: torch-1.13.1
ONNX: onnx-1.16.1
ONNX Runtime: onnxruntime-1.18.0
The Qualcomm® Neural Processing SDK allows users to compile user defined operation packages to use with the runtimes such as CPU, GPU, and DSP. You may need to install appropriate cross-compilation toolchains to compile such packages for a particular backend.
MAKE:
Operation packages are compiled with a front-end that is written with makefiles. If make is not available on your host machine, install it using the following command:
$ sudo apt-get install make
OE Linux
Following section provides steps to acquire the gcc toolchain for targets which are based on Linux distributions like Yocto or Ubuntu. In this case taking Yocto Kirkstone as an example, which requires GCC toolchain. To support Yocto Kirkstone based devices, the SDK libraries are required to compile with GCC-11.2.
If the required compiler is not available in your system PATH, please use the below steps to install the dependency and make them available in your PATH.
Please follow the below steps to download and install eSDK that contains cross compiler toolchain -
wget https://artifacts.codelinaro.org/artifactory/qli-ci/flashable-binaries/qimpsdk/qcm6490/x86/qcom-6.6.28-QLI.1.1-Ver.1.1_qim-product-sdk-1.1.3.zip unzip qcom-6.6.28-QLI.1.1-Ver.1.1_qim-product-sdk-1.1.3.zip umask a+rx sh qcom-wayland-x86_64-qcom-multimedia-image-armv8-2a-qcm6490-toolchain-ext-1.0.sh export ESDK_ROOT=<path of installation directory> cd $ESDK_ROOT source environment-setup-armv8-2a-qcom-linux
Android NDK:
This Qualcomm® Neural Processing SDK release is verified to work with Android NDK version r26c, which is available at https://dl.google.com/android/repository/android-ndk-r26c-linux.zip. After download, extract the zip file and add the extracted location to your PATH environment variable.
Use the following commands to set the environment to use Android NDK and check configuration:
$ export ANDROID_NDK_ROOT=<PATH-TO-NDK>
$ export PATH=${ANDROID_NDK_ROOT}:${PATH}
$ ${SNPE_ROOT}/bin/envcheck -n
Clang 14:
This Qualcomm® Neural Processing SDK release is verified to work with Clang 14. See Environment Setup for Linux for Clang installation.
To check if the environment is setup properly to use clang-14, the following command can be used:
$ ${SNPE_ROOT}/bin/envcheck -c
CPU: Compiler used for X86_64 is clang 14. ARM CPU targets are built using Android NDK (see Android NDK).
GPU: GPU backend kernels are written based on OpenCL. The GPU operations must be implemented based on OpenCL headers with OpenCL version 1.2 or higher.
DSP: Compiling for DSP requires the use of the Hexagon toolchain available from Qualcomm® Hexagon SDK.
Hexagon SDK installation on Linux
The Hexagon SDK versions are available at https://developer.qualcomm.com/software/hexagon-dsp-sdk/tools.
Hexagon SDK installation on WSL2 Ubuntu 22.04
Download Hexagon SDKs from https://qpm.qualcomm.com in a Linux PC.
Copy Hexagon SDKs from Linux PC to Windows PC.
This Qualcomm® Neural Processing release is verified to work with:
Backend |
Hexagon Architecture |
Hexagon SDK Version |
Hexagon Tools Version |
|---|---|---|---|
DSP |
V75 |
5.4.0 |
8.7.03 |
DSP |
V73 |
5.4.0 |
8.6.02 |
DSP |
V69 |
4.3.0 |
8.5.03 |
DSP |
v68 |
4.2.0 |
8.4.09 |
DSP |
v66 |
4.1.0 |
8.4.06 |
Additionally, compiling for DSP requires clang++.
Further setup instructions are available at $HEXAGON_SDK_ROOT/docs/readme.html, where
HEXAGON_SDK_ROOT is the location of the Hexagon SDK installation.
Note
Hexagon SDK tools version 8.7.03/8.6.02/8.5.03/8.4.09/8.4.06 is not currently pre-packaged into Hexagon SDK version 5.4.0/4.3.0/4.2.0/4.1.0 respectively. It needs to be downloaded separately and placed at the location $HEXAGON_SDK_ROOT/tools/HEXAGON_Tools/ .
Java¶
Java environment is required to integrate Qualcomm® Neural Processing SDK with Android applications (for example Image Classifiers). This Qualcomm® Neural Processing SDK release is verified to work with Java 8. If Java 8 is not available on your host machine, install it using the following command:
$ sudo apt-get install openjdk-8-jdk
Windows Platform Dependencies¶
Host OS¶
Qualcomm® Neural Processing SDK is verified with Windows 10 and Windows 11 OS on a x86 host platform and with Windows 11 OS on a Snapdragon platform.
Python¶
The Qualcomm® Neural Processing SDK distributions are only supported on Python3. The SDK has been tested with Python 3.10. Install Python 3.10 from: https://www.python.org/ftp/python/3.10.11/python-3.10.11-amd64.exe.
After installation, check dependencies by running the following script in PowerShell terminal window.
$ py -3.10 -m venv "<PYTHON3.10_VENV_ROOT>"
$ & "<PYTHON3.10_VENV_ROOT>\Scripts\Activate.ps1"
$ python -m pip install --upgrade pip
$ python "${SNPE_ROOT}\bin\check-python-dependency"
To work with TensorFlow 1.15.0, download Python 3.6 at https://www.python.org/ftp/python/3.6.8/python-3.6.8-amd64.exe
After installation, as above, check dependencies by running the following script in PowerShell terminal window.
$ py -3.6 -m venv "<PYTHON3.6_VENV_ROOT>"
$ & "<PYTHON3.6_VENV_ROOT>\Scripts\Activate.ps1"
$ python -m pip install --upgrade pip
$ python "${SNPE_ROOT}\bin\check-python-dependency"
Note
SNPE_ROOT environment variable can be set by following Environment Setup for Windows.
Windows¶
Compiling artifacts for the Windows targets requires Visual Studio setup.
Qualcomm® Neural Processing SDK was verified with the following build environment.
Visual Studio 2022 17.5.1
MSVC v143 - VS 2022 C++ x64/x86 build tools - 14.34
MSVC v143 - VS 2022 C++ ARM64/ARM64EC build tools - 14.34
Windows SDK 10.0.22621.0
MSBuild support for LLVM (clang-cl) toolset
C++ Clang Compiler for Windows (15.0.1)
C++ CMake tools for Windows
Run the following script in Powershell terminal as Administrator to check and install missing Windows dependencies:
$ & "${SNPE_ROOT}/bin/check-windows-dependency.ps1"
Note
You can set SNPE_ROOT environment variable by following Environment Setup for Windows.
To just check if the environment satisfies the requirements, run the following command in your Developer Powershell terminal:
$ & "${SNPE_ROOT}/bin/envcheck.ps1" -m
Environment Setup¶
Linux¶
After Linux Platform Dependencies have been satisfied, the user environment can be set with the provided envsetup.sh script.
Open a command shell on Linux host and run:
$ source ${SNPE_ROOT}/bin/envsetup.sh
This will set/update the following environment variables:
SNPE_ROOT
PYTHONPATH
PATH
LD_LIBRARY_PATH
${SNPE_ROOT}represents the full path to Qualcomm® Neural Processing SDK root.
The SNPE API headers are in ${SNPE_ROOT}/include/SNPE.
The tools are in ${SNPE_ROOT}/bin/x86_64-linux-clang.
Target specific libraries are in ${SNPE_ROOT}/lib/*/.
Windows¶
After Windows Platform Dependencies have been satisfied, the user environment can be set with the provided envsetup.ps1 script.
First, Open Developer PowerShell for VS2022 as Administrator.
$ Set-ExecutionPolicy RemoteSigned
Then, execute the following script:
$ & "${SNPE_ROOT}\bin\envsetup.ps1"
This will set/update the following environment variables:
SNPE_ROOT
${SNPE_ROOT} represents the full path to Qualcomm® Neural Processing SDK root.
The SNPE API headers are in ${SNPE_ROOT}/include/SNPE.
The tools are in ${SNPE_ROOT}/bin/x86_64-linux-clang.
Target specific libraries are in ${SNPE_ROOT}/lib/*/.
Note
envsetup.ps1 is only required to be executed on Windows host.
Machine Learning Frameworks¶
For information on which versions Qualcomm® Neural Processing SDK was verified with see ML Frameworks.
Install TensorFlow as a standalone Python module using https://pypi.org/project/tensorflow/2.10.1/ If installing tf-1.15.0, refer to the Python 3.6 installation section above. To ensure TensorFlow is in your PYTHONPATH by running the following command.
python -c "import tensorflow"
Note
Installing versions of TensorFlow besides 1.15.0 or 2.10.1 may update dependencies (e.g. numpy).
Install ONNX as a standalone Python module using https://pypi.org/project/onnx/1.16.1/ and ensure ONNX is in your PYTHONPATH by running the following command:
python -c "import onnx"
Install ONNX Runtime as a standalone Python module using https://pypi.org/project/onnxruntime/1.18.0/ and ensure ONNX Runtime is in your PYTHONPATH by running the following command.
python -c "import onnxruntime"
Install TFLite as a standalone Python module using https://pypi.org/project/tflite/2.3.0/ and ensure TFLite is in your PYTHONPATH by running the following command:
python -c "import tflite"
Install PyTorch v1.13.1 as a standalone Python module using https://pytorch.org/get-started/previous-versions/#v1131 and ensure PyTorch is in your PYTHONPATH by running the following command:
python -c "import torch"