1. Introduction

In order to utilize the Snapdragon Hexagon NPU, a Qualcomm's proprietary .dlc format is required as there is no native support for common formats such as PyTorch, TensorFlow, or ONNX. The Qualcomm Hexagon SDK provides converter tools that handle this translation, but the build environment has minor caveats which can be time consuming to solve, especially for Windows users.

This guide expands on Qualcomm's official documentation and the SNPE plugin tutorial for UE5, covering how to configure a Windows/Linux environment capable of building ML models for Snapdragon Android devices. Because the Qualcomm Hexagon SDK does not support cross-compilation for Android on Windows directly, WSL (Windows Subsystem for Linux) is used to run an Ubuntu environment.

Read Section 3 before beginning installation. It documents workarounds for common issues that will block progress if encountered mid-install.

2. Installation instructions

  1. Download the Qualcomm Neural Processing SDK from here and unzip to a chosen directory.
  2. Building and quantizing models for Android is only supported on Linux, so install WSL on your windows machine. Follow these instructions: WSL installation
  3. Once installed WSL run it and install the environment to run the Neural Processing SDK on linux. https://docs.qualcomm.com/doc/80-63442-10/topic/setup_linux.html

Source: https://github.com/SnapdragonGameStudios/snapdragon-game-plugins-for-unreal-engine/blob/engine/5.4/Plugins/SNPE/tutorial.md

3. Additional notes (read first)

  1. WSL: install Ubuntu 22.04, dependency warnings otherwise

    wsl --install -d Ubuntu-22.04
    
  2. Before creating venv go to $HOME folder and create it there, otherwise Python dependencies fail to install later in the process

  3. Qualcomm Package Manager - if direct link in the setup does not work, use the following link and download latest version

    https://softwarecenter.qualcomm.com/catalog/item/QPM3?osArch=X86&osDist=Debian&osType=Linux&version=3.0.131.3

  4. Before installing Qualcomm Package Manager run this command to install dependencies

    sudo apt update && sudo apt install xdg-utils
    
  5. Install Hexagon SDK and toolchain using command-line Package Manager. This method is recommended over the GUI method because it is more reliable on WSL and less time consuming to set up:

4.1. Use powershell session with WSL and venv enabled

qpm-cli --logout
qpm-cli --login
qpm-cli --license-refresh
qpm-cli --license-activate hexagonsdk6.x
qpm-cli --install hexagonSDK6.x

Take note of the installation path printed at the end (SUCCESS: Installed HexagonSDK6.x.Core at [path])

/local/mnt/workspace/Qualcomm/Hexagon_SDK/6.5.0.1

Also install Hexagon toolchain

qpm-cli --install hexagon8.4

→ path can be /root/Qualcomm/HEXAGON_Tools/8.4.12

Source for qpm-cli instructions: https://docs.qualcomm.com/nav/home/setup_linux.html?product=1601111740010412

  1. Follow steps in Readme setup file

    open /local/mnt/workspace/Qualcomm/Hexagon_SDK/6.5.0.1/docs/tools/Setup.html
    
  2. Install dependency for onnx converter

    pip3 install onnxsim
    
  3. Use built-in converter to conver onnx to dlc format

    ./x86_64-linux-clang/snpe-onnx-to-dlc --input_dim 'input' 1,3,720,1280 --input_network path_to_input_file.onnx --output_path path_to_output_file.dlc
    

    Note: The --input_dim name and shape must match exactly what was specified when the PyTorch model was exported. Mismatches here are a common source of converter errors.

image.png