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”)

  1. Go to the SNPE product page.

  2. Click “Get Software” to download the QAIRT SDK (which contains SNPE).

    1. The zipped file should have a name like v2.32.0.250228.

    2. Note: the QAIRT SDK is ~1.1GB when zipped and ~2.5GB when unzipped.

  3. Open File Explorer.

  4. In File Explorer, go to the Downloads folder.

  5. Unzip the downloaded SDK into the folder where you want the SDK to live.

  6. In File Explorer, navigate to the bin folder inside your unzipped SDK directory.

    1. The full path will look something like \path\to\unzipped\folder\v2.32.0.250228\qairt\2.32.0.250228\bin.

    2. The numbers will correspond to your release of the SDK.

  7. Click the address bar at the top to reveal the full path.

  8. Copy the complete path to the bin folder for later.

    1. 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.

  9. 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.

    1. Pressing the “Windows” key to search for applications.

    2. Searching for “Powershell”.

    3. Right-clicking “Windows Powershell” and selecting “Run as Administrator”.

    4. If a pop-up appears asking for permission, select “Yes”.

  10. cd to the bin folder using the path you copied earlier, for example:

    cd C:\Users\UserName\Downloads\v2.32.0.250228\qairt\2.32.0.250228\bin
    
  11. Allow execution of scripts on this system by running:

    Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
    
  12. Type y to accept the risk.

  13. Run the following commands to set QAIRT_SDK_ROOT and other useful variables:

    Unblock-File .\envsetup.ps1
    .\envsetup.ps1
    

    On some systems, the Unblock-File command is needed to have permission to execute scripts from the internet.

    Warning

    The envsetup.ps1 script only updates environment variables for this Powershell session. If you need to set QAIRT_SDK_ROOT again, re-run \bin\envsetup.ps1.

  14. Run the following command to install the core Windows build tools:

    & "$env:QAIRT_SDK_ROOT\bin\check-windows-dependency.ps1"
    
    1. You may be asked to install Visual Studio 2022 Community Edition. Press y to accept.

    2. Click the “Modify” button in the lower right corner of the Visual Studio Installer to continue the process.

    3. When you have installed all the necessary dependencies, the script will say “All Done”.

    4. If you don’t see “All Done”, you may have to re-run the command.

  15. 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

  1. Check whether you have Python 3.10 installed by running:

    py --list
    

    Warning

    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.

  2. If you do not have Python 3.10, you can install it by running:

    winget install --id Python.Python.3.10 -e
    
  3. Verify the installation worked by running:

    py --list
    
    • You should see an entry that starts with -V:3.10 or Python 3.10 as one of the options.

  4. Run the following commands to initialize a virtual environment using Python 3.10 and 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.

  1. 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.0

    Note

    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.dll that 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:

  1. Download the Android NDK: Android NDK r26c

  2. Unzip the file.

    Warning

    If your environment is in WSL, the Android NDK must be unzipped under $HOME with the WSL unzip command.

  3. Copy the path to your unzipped Android NDK root (the folder should be named android-ndk-r26c).

  4. Go to your Powershell session.

  5. Set the path to the Android NDK root as an environment variable:

    1. Replace the text in “<…>”. For example, /home/usr/Documents/android-ndk-r26c.

      $env:ANDROID_NDK_ROOT = "<path-to-your-android-ndk-root-folder>"
      
  6. 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")
    
  7. 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.

    1. If the output does not have ANDROID_NDK_ROOT specified, replace $env:ANDROID_NDK_ROOT in Step 6 with the path to your Android NDK folder (in all 3 sub-commands) and re-run them.

  8. 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.

  1. 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
    
  2. Review the clang-v1 version in the output:

    1. 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
      
    2. If you see an error, please install the recommended version following the “(Optional) How to install clang++” steps below.

  3. If make is not already installed on your system, install it by running:

    winget install --id=GnuWin32.Make
    
  4. (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:

  1. Find the LLVM version that matches the recommended version (ex: 15.0.1).

  2. Click on the link to the GitHub release page.

  3. Press Ctrl + F and search for either win32 or win64, depending on your system’s architecture.

  4. Click on the .exe file that matches your system’s architecture above (ex: LLVM-15.0.1-win64.exe), and it will automatically download the LLVM installer.

  5. Open the downloaded .exe file and follow the setup instructions.

  6. Select “Add LLVM to the system PATH for all users” when prompted.

  7. Open a new PowerShell instance and run:

    clang++ --version
    

    You 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 version matches your installed version, you’ve succeeded!

  8. Copy the InstalledDir path.

  9. In your original PowerShell instance, manually update the current session’s PATH variable by running:

    $env:PATH = "path\to\LLVM\bin;$env:PATH"
    

    Where path\to\LLVM\bin can be found at InstalledDir in 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:

  1. Download the SDK package.

  2. Extract the ZIP file.

  3. Install Windows Subsystem for Linux (WSL) by following the instructions here.

    1. The eSDK can only be extracted with Linux-like systems since it only comes with a .sh installer.

  4. 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
    
  5. 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.

  1. To install clang++14, follow the “(Optional) How to install clang++14” steps in the “Linux” section of Part 4 above.

  2. 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:

  1. If you do not already have Qualcomm Package Manager 3 (QPM3) installed, install it by following the steps below:

    1. Sign into Qualcomm Package Manager 3

    Warning

    You may have to click the link again after logging in to have it load properly.

    1. Download the Windows version of Qualcomm Package Manager 3 (QPM3).

  2. Start QPM3 by running the QPM3 executable. It should have a similar name to QPM.3.0.92.3.Windows-AnyCPU.exe.

  3. Log in with your Qualcomm ID within the QPM 3 app when prompted.

  4. Once logged in to QPM3, click on “Tools.”

  5. Look up which “Hexagon Architecture” your chip supports in the supported Snapdragon devices table (it should look like “V00”).

  6. 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

  7. Search for “Hexagon SDK” in QPM3.

  8. Download the proper version for your target device based on the above table.

    1. You will have to accept terms and conditions to use the downloaded files.

    2. You will likely want to leave the files in the default location.

    3. 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.

  9. Write down the path to the Hexagon SDK, you will need it later.

  10. In QPM3, go back to the search bar and search for “Hexagon Toolchain”.

  11. 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/.

  1. Download the corresponding version of the “Hexagon Toolchain”.

  2. Ensure you have installed clang++ so you can compile code for DSP hardware (see “Working with a Linux Target”).

  3. Follow the rest of the instructions at $HEXAGON_SDK_ROOT/docs/readme.html (where $HEXAGON_SDK_ROOT is 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.