Windows Setup¶
Instructions for Windows Host (10, 11, and Snapdragon)¶
Follow these instructions to install the Qualcomm Neural Processing SDK (commonly referred to as SNPE) and all necessary dependencies.
SNPE allows you to convert an AI model (e.g., a .pt model from PyTorch) into instructions that can be run on a target device’s various processing units (CPU, GPU, DSP).
Note
This guide is for a host machine running Windows 10, 11, or Windows on Snapdragon. If you are using a Linux machine or a WSL environment, follow the instructions here.
There are several parts to this guide to install SNPE and all its corresponding dependencies:
Part 1: Install the SNPE SDK.
Part 2: Install SNPE dependencies.
Part 3: Install model frameworks to interpret your AI model files. (e.g.,
PyTorch).Part 4: Install Target Device OS-Specific Toolchain Code.
Part 5: Install Dependencies for Target Hardware Processors.
These steps will require admin access in order to run some of the installation commands.
Note
To learn about acronyms which are new to you, see the glossary.
Note
This guide contains many recommendations about specific versions of code to use that have been verified to work. Other versions of those dependencies may or may not work, so use them at your own risk.
Part 1: Install the Qualcomm Neural Processing Engine (aka “SNPE”)¶
Go to the SNPE product page.
Click “Get Software” to download the QAIRT SDK (which contains SNPE).
The zipped file should have a name like
v2.32.0.250228.Note: the QAIRT SDK is ~1.1GB when zipped and ~2.5GB when unzipped.
Open File Explorer.
In File Explorer, go to the Downloads folder.
Unzip the downloaded SDK into the folder where you want the SDK to live.
In File Explorer, navigate to the
binfolder inside your unzipped SDK directory.The full path will look something like
\path\to\unzipped\folder\v2.32.0.250228\qairt\2.32.0.250228\bin.The numbers will correspond to your release of the SDK.
Click the address bar at the top to reveal the full path.
Copy the complete path to the
binfolder for later.Click the address bar in File Explorer and press Ctrl + C. For example:
C:\Users\UserName\Downloads\v2.32.0.250228\qairt\2.32.0.250228\bin.
Open an admin Powershell session by:
Note
Please keep this terminal open, as it will contain environment variables you’ll need in later steps and tutorials.
Pressing the “Windows” key to search for applications.
Searching for “Powershell”.
Right-clicking “Windows Powershell” and selecting “Run as Administrator”.
If a pop-up appears asking for permission, select “Yes”.
cdto thebinfolder using the path you copied earlier, for example:cd C:\Users\UserName\Downloads\v2.32.0.250228\qairt\2.32.0.250228\bin
Allow execution of scripts on this system by running:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Type
yto accept the risk.Run the following commands to set
QAIRT_SDK_ROOTand other useful variables:Unblock-File .\envsetup.ps1 .\envsetup.ps1
On some systems, the
Unblock-Filecommand is needed to have permission to execute scripts from the internet.Warning
The
envsetup.ps1script only updates environment variables for this Powershell session. If you need to setQAIRT_SDK_ROOTagain, re-run\bin\envsetup.ps1.Run the following command to install the core Windows build tools:
& "$env:QAIRT_SDK_ROOT\bin\check-windows-dependency.ps1"
You may be asked to install Visual Studio 2022 Community Edition. Press
yto accept.Click the “Modify” button in the lower right corner of the Visual Studio Installer to continue the process.
When you have installed all the necessary dependencies, the script will say “All Done”.
If you don’t see “All Done”, you may have to re-run the command.
Verify that you have installed the Microsoft Visual Studio C++ (MSVC) toolchain successfully.
Unblock-File "$env:QAIRT_SDK_ROOT\bin\envcheck.ps1" & "$env:QAIRT_SDK_ROOT\bin\envcheck.ps1" -m
Note
It’s normal to see that only one of “Visual C++(x86)” and “Visual C++(arm64)” is installed. The installed version should match the hardware of your host machine.
You should see an output like this:
Checking MSVC Toolchain -------------------------------------------------------------- WARNING: The version of VS BuildTools 14.40.33807 found has not been validated. Recommended to use known stable VS BuildTools version 14.34 WARNING: The version of Visual C++(x64) 19.40.33812 found has not been validated. Recommended to use known stable Visual C++(x64) version 19.34 WARNING: The version of CMake 3.28.3 found has not been validated. Recommended to use known stable CMake version 3.21 WARNING: The version of clang-cl 17.0.3 found has not been validated. Recommended to use known stable clang-cl version 15.0.1 Name Version ---- ------- Visual Studio 17.13.35931.197 VS Build Tools 14.43.34808 Visual C++(x86) 19.40.33812 Visual C++(arm64) Not Installed Windows SDK 10.0.22621 CMake 3.30.5 clang-cl 19.1.1 --------------------------------------------------------------
Part 2: Install SNPE SDK dependencies¶
Check whether you have Python 3.10 installed by running:
py --listWarning
SNPE distributions are only supported on Python3, and has been tested with Python 3.10. Other releases may not work as expected. By default, use Python 3.10.
If you do not have Python 3.10, you can install it by running:
winget install --id Python.Python.3.10 -e
Verify the installation worked by running:
py --listYou should see an entry that starts with
-V:3.10orPython 3.10as one of the options.
Run the following commands to initialize a virtual environment using Python
3.10and install SNPE’s dependencies.# Set up your virtual environment with Python 3.10 py -3.10 -m venv "venv" & "venv\Scripts\Activate.ps1" python -m pip install --upgrade pip # Install dependencies python "$env:QAIRT_SDK_ROOT\bin\check-python-dependency"
Part 3: Install Model Frameworks¶
SNPE supports the following model frameworks.
Install the ones that are relevant for the AI model files you want to use.
Warning
You do not need to install all packages here.
Note
You can install a package by running
pip3 install package==version. e.g.,pip3 install torch==2.4.0Note
You can verify your installation by running
python -c "import <model>"(replacing<model>with the import you downloaded above). If the script executes without any errors, that means it was installed correctly.Warning
If you see the error
Missing cudart64_110.dllthat error is safe to ignore. It means that the library tried to find GPU support (CUDA 11.0), but was unable to find it. This only matters if it shows up on the target device and you are trying to use the GPU processor.
Part 4: Install Target Device OS-Specific Toolchain Code¶
Depending on the target device’s operating system there may be additional installation requirements. These dependencies are mostly used for cross-compilation.
You only need to read the section that corresponds to your target device OS. SNPE supports versions of Android, Linux, OE Linux, and Windows target devices.
Note
For Windows target devices, you do not need to do any additional installations, you can skip to Part 5.
Working with an Android Target Device¶
For working with Android devices, you will need to install a corresponding Android NDK (Native Developer Kit). You can install the recommended version (Android NDK version r26c) by following these steps:
Download the Android NDK: Android NDK r26c
Unzip the file.
Warning
If your environment is in WSL, the Android NDK must be unzipped under
$HOMEwith the WSLunzipcommand.Copy the path to your unzipped Android NDK root (the folder should be named
android-ndk-r26c).Go to your Powershell session.
Set the path to the Android NDK root as an environment variable:
Replace the text in “<…>”. For example,
/home/usr/Documents/android-ndk-r26c.$env:ANDROID_NDK_ROOT = "<path-to-your-android-ndk-root-folder>"
Add the location of the unzipped file to your PATH by running:
[System.Environment]::SetEnvironmentVariable("ANDROID_NDK_ROOT", "$env:ANDROID_NDK_ROOT", "User") $env:PATH = "$env:ANDROID_NDK_ROOT;$env:PATH" [System.Environment]::SetEnvironmentVariable("PATH", "$env:ANDROID_NDK_ROOT;$env:PATH", "User")
You can verify the PATH has been updated by running
$env:PATH -split ';'and checking the top of the list to see if the path to the Android NDK is in the list.If the output does not have
ANDROID_NDK_ROOTspecified, replace$env:ANDROID_NDK_ROOTin Step 6 with the path to your Android NDK folder (in all 3 sub-commands) and re-run them.
Install Java 8 by running:
winget install --id EclipseAdoptium.Temurin.8.JDK
Note
Java 8 has been verified with SNPE, other versions may not work as expected. Java is essential if you want to use SNPE with an Android application.
Working with a Linux Target Device¶
When building models for Linux target devices with SNPE, you need a compatible clang++ version. Using an unvalidated version may cause build errors.
Check your environment toolchain by running the SNPE environment check script:
Unblock-File "$env:QAIRT_SDK_ROOT\bin\envcheck.ps1" & "$env:QAIRT_SDK_ROOT\bin\envcheck.ps1" -m
Review the
clang-v1version in the output:You should see something like this (with no errors):
Name Version ---- ------- Visual Studio 17.13.35931.197 VS Build Tools 14.43.34808 Visual C++(x86) 19.43.34810 Visual C++(arm64) 19.43.34810 Windows SDK 10.0.22621 CMake 3.30.5 clang-cl 15.0.1
If you see an error, please install the recommended version following the “(Optional) How to install clang++” steps below.
If
makeis not already installed on your system, install it by running:winget install --id=GnuWin32.Make
(Optional) You can update your Visual Studio to use a specific version of
clang++by following these instructions.
(Optional) How to install clang++¶
Warning
You only need to follow these steps if you saw errors/warnings for clang-c1 from the steps above.
Download and install the recommended version of clang++ from the official LLVM site:
Find the LLVM version that matches the recommended version (ex: 15.0.1).
Click on the link to the GitHub release page.
Press
Ctrl + Fand search for eitherwin32orwin64, depending on your system’s architecture.Click on the
.exefile that matches your system’s architecture above (ex:LLVM-15.0.1-win64.exe), and it will automatically download the LLVM installer.Open the downloaded
.exefile and follow the setup instructions.Select “Add LLVM to the system PATH for all users” when prompted.
Open a new PowerShell instance and run:
clang++ --versionYou should see something like:
clang version 15.0.1 Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: C:\Program Files\LLVM\bin
If
clang versionmatches your installed version, you’ve succeeded!Copy the
InstalledDirpath.In your original PowerShell instance, manually update the current session’s
PATHvariable by running:$env:PATH = "path\to\LLVM\bin;$env:PATH"
Where
path\to\LLVM\bincan be found atInstalledDirin the previous Powershell output.For example:
$env:PATH = "C:\Program Files\LLVM\bin;$env:PATH"
This makes sure that your Powershell session can see the right version of
clang++that you just installed.
Working with an OE Linux Target Device¶
Some Linux target devices, such as those based on Yocto Kirkstone, require cross-compilation using a GCC-based toolchain. The Qualcomm Neural Processing SDK has been verified to work with GCC 11.2 for these systems.
If you do not already have the required toolchain installed or available in your system PATH, follow these steps to download and install the cross-compiler using Qualcomm’s eSDK:
Download the SDK package.
Extract the ZIP file.
Install Windows Subsystem for Linux (WSL) by following the instructions here.
The eSDK can only be extracted with Linux-like systems since it only comes with a
.shinstaller.
Run the toolchain installer script within WSL:
cd /mnt/c/Users/Username/Downloads/qcom-6.6.28-QLI.1.1-Ver.1.1_qim-product-sdk-1.1.3 sh qcom-wayland-x86_64-qcom-multimedia-image-armv8-2a-qcm6490-toolchain-ext-1.0.sh
Set your eSDK root and source the toolchain environment using WSL:
export ESDK_ROOT=<path-to-installed-esdk> cd $ESDK_ROOT source environment-setup-armv8-2a-qcom-linux
This sets up the correct cross-compilation environment to build and deploy models for Yocto-based Linux targets.
Working with a Windows Target Device¶
For Windows target devices, you do not need to do any additional installation.
Part 5: Install Dependencies for Target Hardware Processors¶
Some of the target processors (CPU, GPU, or DSP) require additional dependencies to build models.
CPU (Central Processing Unit)¶
The x86_64 targets are built using clang-14. You can update your Visual Studio to use a specific version of clang++ by following these instructions.
To install
clang++14, follow the “(Optional) How to install clang++14” steps in the “Linux” section of Part 4 above.The ARM CPU targets are built using the Android NDK (see the Working with an Android Target Device section above).
GPU (Graphics Processing Unit)¶
The GPU backend kernels are written based on OpenCL. The GPU operations must be implemented based on OpenCL headers with minimum version OpenCL 1.2.
DSP¶
Compiling for DSP hardware requires the use of the Qualcomm Hexagon SDK and Hexagon SDK Tools which you can install by following these steps:
If you do not already have Qualcomm Package Manager 3 (QPM3) installed, install it by following the steps below:
Sign into Qualcomm Package Manager 3
Warning
You may have to click the link again after logging in to have it load properly.
Download the Windows version of Qualcomm Package Manager 3 (QPM3).
Start QPM3 by running the QPM3 executable. It should have a similar name to
QPM.3.0.92.3.Windows-AnyCPU.exe.Log in with your Qualcomm ID within the QPM 3 app when prompted.
Once logged in to QPM3, click on “Tools.”
Look up which “Hexagon Architecture” your chip supports in the supported Snapdragon devices table (it should look like “V00”).
Use the Hexagon Architecture you just looked up to determine which version of the “Hexagon SDK” you need from this table:
Hexagon Architecture
Hexagon SDK Version
V75
5.4.0
V73
5.4.0
V69
4.3.0
v68
4.2.0
v66
4.1.0
Search for “Hexagon SDK” in QPM3.
Download the proper version for your target device based on the above table.
You will have to accept terms and conditions to use the downloaded files.
You will likely want to leave the files in the default location.
The download should pre-select which add-ons are relevant. You may download the “Full NDK” as an alternative to the “Minimal NDK” depending on your use case.
Write down the path to the Hexagon SDK, you will need it later.
In QPM3, go back to the search bar and search for “Hexagon Toolchain”.
Based on your Hexagon Architecture, choose the corresponding version of the Hexagon Toolchain to click into:
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/.
Download the corresponding version of the “Hexagon Toolchain”.
Ensure you have installed
clang++so you can compile code for DSP hardware (see “Working with a Linux Target”).Follow the rest of the instructions at
$HEXAGON_SDK_ROOT/docs/readme.html(where$HEXAGON_SDK_ROOTis the location of the Hexagon SDK installation) to complete the installation.
Next Steps¶
Now that you have finished setting up SNPE and its dependencies, you can start using SNPE. Follow the “Building and Executing a Model” Tutorial to learn how to transform your AI models build them for your target device, and use them to generate inferences on the information processing cores you choose. Use SNPE to allow your AI models to execute on your specific target device’s cores.