Skip to main content
You can run a wide range of Large Language Models (LLMs) and Vision Language Models (VLMs) on your Dragonwing development boards using llama.cpp. llama.cpp supports three backends on Dragonwing devices: CPU, GPU (via OpenCL), and NPU (via the Hexagon HTP backend). You can run a subset of models on the NPU via GENIE as well.

Choose a backend

  • CPU: no special drivers or extra build flags needed. Useful as a baseline to compare against GPU or NPU performance.
  • GPU (OpenCL): build llama.cpp with the OpenCL backend to offload layers to the Adreno GPU. The same build also runs on CPU by skipping GPU offload.
  • NPU (Hexagon HTP): build llama.cpp with the Snapdragon toolchain container to offload layers to the Hexagon HTP device (HTP0) for the best performance on supported models.

Overview

Build llama.cpp for Dragonwing devices with the Hexagon HTP backend, then run GGUF large language models on HTP0.
These instructions focus on the Snapdragon and Dragonwing llama.cpp build that exposes the Hexagon HTP device as HTP0. This is different from the OpenCL GPU workflow in the GPU tab.

Prerequisites

Before you begin, make sure you have:
  • Completed the first time setup for your Dragonwing device:
  • Access to the device by SSH, or by a directly connected display, keyboard, and mouse.
    • The setup guides linked above include instructions for networking, serial console access, display setup, and SSH access.
  • Installed the required Dragonwing software packages on the device:
  • Installed Docker on the build host.
  • Enough free space for the build output and models. Plan for several GB per model.
The required software package setup installs the QNN runtime and tools, including libqnn-dev and qnn-tools, that llama.cpp needs for accelerated inference.

Prepare the build host

On your build host, clone llama.cpp or update an existing checkout.
If you need a reproducible build, record the commit you built:

Build llama.cpp with the Snapdragon toolchain container

The easiest way to build llama.cpp for Dragonwing is to use the Snapdragon ARM64 Linux toolchain container. The container includes the ARM64 cross compiler, CMake, OpenCL SDK, and Hexagon SDK pieces needed by the Snapdragon preset. The Docker command below explicitly requests the linux/amd64 image.From the root of your llama.cpp checkout, start the container:
Inside the container, configure and build llama.cpp:
Create an installable package:
Exit the container when the package is complete:
The package archive is now available on the host at:

Rebuild when upstream llama.cpp changes

llama.cpp changes frequently. To rebuild with the latest upstream code, repeat this update and build flow from your host checkout:
Then, inside the container:
If you are testing a branch, tag, or local llama.cpp changes, check out that source before running the Docker build command.

Copy the package to the Dragonwing device

Replace ubuntu@DEVICE_IP with your SSH user and target IP address.
Log in to the target device:
Unpack the package:
Set the runtime library paths for the current shell:
Verify that the package runs:
List the available llama.cpp devices:
Expected output includes:

Make this the default llama.cpp install on the device

The packaged binaries need LD_LIBRARY_PATH and ADSP_LIBRARY_PATH so they can find the packaged llama.cpp and Hexagon backend libraries. The safest way to make this the default install is to move the package into /opt and create wrapper commands in /usr/local/bin.Run the following on the Dragonwing device:
Create a shared environment file:
Create wrapper commands for llama-cli and llama-server:
Confirm that the default commands now resolve to the wrappers:
Expected paths:
/usr/local/bin usually appears before /usr/bin in PATH, so these wrappers become the default commands without replacing system packages.

Download a model

llama.cpp uses models in GGUF format. A small instruct model is a good first test.Create a model directory on the Dragonwing device:
Download a Llama 3.2 3B instruct GGUF model:
Model support and performance vary by architecture, quantization, context length, and llama.cpp commit. If you find a model or quantization that runs particularly well on Dragonwing devices, share it with the community.

Run your first prompt on HTP0

Run llama-cli and offload layers to the Hexagon HTP device:
Useful options:
  • --device HTP0 selects the Hexagon HTP backend.
  • -ngl 99 asks llama.cpp to offload model layers to the selected device.
  • -m points to your GGUF model file.
  • -p passes a prompt for single prompt testing.

Start llama-server

llama-server exposes a local web UI and an OpenAI compatible API.Start a server on the Dragonwing device:
Find the device IP address:
From another machine on the same network, open:
You can also test the API with curl:

Update the default install after a rebuild

After you rebuild and copy a new pkg-snapdragon.zip to the device, update /opt/llama.cpp-snapdragon:
The wrapper commands in /usr/local/bin do not need to be recreated unless you change the install path.

Troubleshooting

error while loading shared librariesIf you run binaries directly from the package directory, set the library paths first:
If you are using the default install wrappers, confirm the wrapper is being used:
It should print /usr/local/bin/llama-cli.HTP0 does not appearConfirm that the required Dragonwing software packages are installed, especially libqnn-dev and qnn-tools. Then check devices again:
Also confirm the package contains Hexagon backend libraries:
The command uses the wrong llama.cpp binaryCheck command resolution:
If another path appears before /usr/local/bin, update your PATH or call /usr/local/bin/llama-cli explicitly.