---
title: "Two Models, Two NPUs"
description: "Run two models at the same time on an E1M-V2M: one on the RZ/V2N's on-die DRP-AI3 and one on the DEEPX DX-M1, each in its own thread, through ``. Prints per-NPU latency and the combined FPS. A Linux/Yocto user-space app on the Cortex-A55 cluster."
source: https://docs.alplab.ai/sdk/examples/v2n/v2n-two-models
---

# `v2n-two-models`

Run two models at the same time on an **E1M-V2M**: one on the RZ/V2N's on-die **DRP-AI3** and one on the **DEEPX DX-M1**, each in its own thread, through [`<alp/inference.h>`](https://docs.alplab.ai/sdk/api/inference). Prints per-NPU latency and the combined FPS. A Linux/Yocto user-space app on the Cortex-A55 cluster.

Source: [`examples/v2n/v2n-two-models/`](https://github.com/alplabai/alp-sdk/tree/main/examples/v2n/v2n-two-models). New in alp-sdk v0.17.0.

:::warning[`[UNTESTED on silicon]`]
Nothing here has run on an E1M-V2M, and the two backends have never been run together. Each NPU has been run alone on silicon (DRP-AI3 with YOLOX-S, the DX-M1 with yolo11n). The HIL specs exist but are not bench-verified.
:::

## What it shows

1. **NPU per handle, chosen by model format.** `backend` stays `ALP_INFERENCE_BACKEND_AUTO` and `format` names the model: `ALP_INFERENCE_MODEL_DRPAI` resolves to DRP-AI3, `ALP_INFERENCE_MODEL_DXNN` to the DX-M1. There is no SoM-specific code; on a SoM without one of the NPUs, that open fails with `ALP_ERR_NOSUPPORT`.
2. **One thread per NPU.** The two NPUs are independent hardware, so a thread on each overlaps their work. Two threads on the *same* NPU would only take turns.
3. **Only the NPUs a mode needs are opened**, so one process per NPU is safe. DRP-AI is one process per board — a second process opening DRP-AI gets `ALP_ERR_BUSY`.
4. **Solo, then both.** The default `all` mode runs DRP-AI alone, the DX-M1 alone, then both, so the numbers show what sharing the A55 cores and DDR costs each NPU.
5. **CPU budget.** Unless you exported them, the program sets `TVM_NUM_THREADS=2` and `TVM_BIND_THREADS=0` so the DRP-AI TVM runtime's worker pool does not fight the DX-M1 runtime for the four A55 cores. The values are a starting point; their effect is unmeasured.
6. **A failed DRP-AI job is not detectable** — the runtime's `Run()` returns `void` — so a fast result is not proof of a correct one.

## Run

No compiled model ships in the repository. Provide both:

| Argument | What |
|---|---|
| `<drpai-model.tar>` | a `drpai_dir` bundle (see [`v2n-drpai-inference`](https://docs.alplab.ai/sdk/examples/v2n/v2n-drpai-inference#no-bundle-ships-and-the-sdk-cannot-compile-one-for-this-model-yet)) |
| `<drpai-frame.bin>` | the raw bytes of that model's input tensor |
| `<model.dxnn>` | a DEEPX model compiled with `dxcom` |
| `<dxnn-frame.bin>` | the raw bytes of that model's input tensor |
| `[seconds]` | length of each phase, default 10 |
| `[mode]` | `all` (default), `solo-drpai`, `solo-dx` or `both` |

```
v2n-two-models drpai.tar drpai_frame.bin yolo11n.dxnn dx_frame.bin 30
```

## Expected output

Shape only — the numbers depend on the models:

```
[two-npu] v2n-two-models: mode all, 30 s per phase
[two-npu] drpai: handle open (1 input, 1 output)
[two-npu] deepx: handle open (1 input, 1 output)
[two-npu] temp start: thermal_zone0 = <n> mC
[two-npu] phase: solo drpai
[two-npu] drpai: <n> invokes, avg <ms> ms, max <ms> ms, <fps> FPS
[two-npu] phase: solo deepx
[two-npu] deepx: <n> invokes, avg <ms> ms, max <ms> ms, <fps> FPS
[two-npu] phase: both
[two-npu] drpai: ...
[two-npu] deepx: ...
[two-npu] combined: <n> invokes in <s> s = <fps> FPS
[two-npu] temp end: thermal_zone0 = <n> mC
[two-npu] done
```

## `board.yaml`

```yaml
som:
  sku: E1M-V2M103

preset: e1m-x-evk

cores:
  a55_cluster:
    app: ./src                      # Linux userspace app -- <alp/inference.h> only
    recipe: alp-two-models-inference # meta-alp-sdk/recipes-examples/alp-two-models-inference
  m33_sm:
    os: "off"                       # Both NPUs are A55/Linux-owned; no M33 app.

diagnostics:
  log_level: info
```

## Image requirements

Linux-only — there is no Zephyr target. Build it with the `alp-two-models-inference` recipe (add the package to your image). Both NPU stacks must be in the image **and** in `libalp_sdk`:

- **DEEPX:** `meta-deepx-m1` in `bblayers.conf` (the V2M machine configs enable it).
- **DRP-AI3:** `meta-rz-drpai` in `bblayers.conf`, **and** `RUHMI_DRPAI_TVM_DIR` set to an account-gated Renesas RUHMI checkout. Without RUHMI the SDK's DRP-AI backend is not compiled and a DRP-AI model fails with `ALP_ERR_NOSUPPORT`.

On V2M, `libdxrt` turns `SIGSEGV` / `SIGBUS` / `SIGABRT` into a silent `exit(1)` for every SDK application — see [E1M-X V2N-M1](https://docs.alplab.ai/e1m/e1m-x-v2n-m1#dx-m1-on-silicon).

## See also

- [`v2n-drpai-inference`](https://docs.alplab.ai/sdk/examples/v2n/v2n-drpai-inference) — DRP-AI3 alone
- [`v2n-m1-deepx-inference`](https://docs.alplab.ai/sdk/examples/v2n/v2n-m1-deepx-inference) — the DEEPX bring-up example
- [`<alp/inference.h>` reference](https://docs.alplab.ai/sdk/api/inference)
- [Examples overview](https://docs.alplab.ai/sdk/examples/overview)
