You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/embedded-and-microcontrollers/deploy-ml-model-to-npu-with-topo/_index.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
-
title: Deploy an ML application to the Ethos-U65 NPU on NXP FRDM i.MX 93 with Topo
2
+
title: Deploy a machine learning application to the Arm Ethos-U65 NPU on NXP FRDM i.MX 93 with Topo
3
3
4
4
draft: true
5
5
cascade:
6
6
draft: true
7
7
8
-
description: Use Topo to deploy a Cortex-A web application that sends MobileNetV2 image classification requests to Cortex-M33 firmware accelerated by the Ethos-U65 NPU.
8
+
description: Use Topo to build and deploy a Cortex-A web application that sends MobileNetV2 image classification requests to Cortex-M33 firmware accelerated by the Ethos-U65 NPU.
9
9
10
10
minutes_to_complete: 60
11
11
@@ -21,12 +21,12 @@ prerequisites:
21
21
- A host machine (x86 or Arm) with Linux, macOS, or Windows
22
22
- An NXP FRDM i.MX 93 target board with Linux setup, accessible over SSH with root access. To do this, see [Use Linux on the NXP FRDM i.MX 93 board](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/linux-nxp-board/).
23
23
- Docker installed on the host and target. For installation steps, see [Install Docker](https://learn.arm.com/install-guides/docker/).
24
-
- At least 25 GB of free disk space on the host if you are building without cache images.
24
+
- At least 25 GB of free disk space on the host if you're building without cache images.
25
25
- The Device Tree Compiler (`dtc`) installed on the host.
26
26
- lscpu installed on the target (pre-installed on most Linux distributions)
27
27
- Topo installed on the host. For installation steps, see [Deploy containerized workloads to Arm-based Linux targets with Topo](https://learn.arm.com/learning-paths/cross-platform/deploy-containerized-workloads-with-topo/).
28
28
- Basic familiarity with containers, SSH, and CLI tools
29
-
- (Optional) Access to an Agent, such as Codex, or Claude Code
29
+
- (Optional) Access to an agent, such as Codex or Claude Code
Copy file name to clipboardExpand all lines: content/learning-paths/embedded-and-microcontrollers/deploy-ml-model-to-npu-with-topo/build-the-template.md
+32-23Lines changed: 32 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
---
2
2
title: Build the Topo Template from scratch
3
+
description: Create a Topo Template from the web application and Cortex-M33 firmware sources by adding Compose services, build artifacts, remoteproc-runtime metadata, and Topo arguments.
3
4
weight: 4
4
5
5
6
### FIXED, DO NOT MODIFY
@@ -8,16 +9,18 @@ layout: learningpathall
8
9
9
10
## What you will build
10
11
11
-
In this section, you will build the `topo-imx93-npu-deployment` Template starting from two non-Topo, non-Compose projects:
12
+
In this section, you'll build the `topo-imx93-npu-deployment` Topo Template starting from two non-Topo, non-Compose projects:
12
13
13
14
- a Cortex-A web application that prepares images, writes model and tensor data into shared memory, and sends inference commands over `RPMsg`
14
15
- a Cortex-M33 ExecuTorch runner firmware project for the FRDM i.MX 93
15
16
16
-
You will combine those sources into one repository, then make the repository a normal Compose project, and only then add the Topo metadata and Remoteproc Runtime services.
17
+
You'll combine those sources into one repository, then make the repository a normal Compose project. Then, you'll add the Topo metadata and Remoteproc Runtime services.
17
18
18
19
## Create the repository from the base projects
19
20
20
-
We will copy the original base projects from the Topo Template. Clone the Topo Template Format repository for the validation schema, clone the original Topo Template for the source files, and start a new empty repository:
21
+
Start by copying the original base projects from the Topo Template.
22
+
23
+
Clone the Topo Template Format repository for the validation schema, clone the original Topo Template for the source files, and start a new empty repository:
We have now obtained a typical starting point. We have two sets of source code, combined into one repository. It is not a Compose project and it is not a Topo Template. We will now create a Compose project and Topo Template around the source code.
61
+
You have two sets of source code combined into one repository. It's not a Compose project and it's not a Topo Template.
62
+
63
+
You'll now create a Compose project and Topo Template around the source code.
59
64
60
65
The Compose project provides the container build and runtime structure. A Dockerfile describes how to build one image. A Compose file describes the services that use those images, their build contexts, ports, volumes, dependencies, and runtime settings. In this Template:
61
66
62
67
-`webapp/Dockerfile` builds the Flask image.
63
68
-`webapp/compose.yaml` keeps the web app's build context and Linux runtime settings close to the web app source.
64
69
-`executorch-runner/Dockerfile` builds the ExecuTorch `.pte` model and Cortex-M33 runner ELF through multi-stage Docker builds.
65
-
- the root `compose.yaml` is the Template entry point. It combines the web app, artifact build services, the Remoteproc Runtime service, and the root-level `x-topo` metadata.
70
+
- the root `compose.yaml` is the Topo Template entry point. It combines the web app, artifact build services, the Remoteproc Runtime service, and the root-level `x-topo` metadata.
66
71
67
72
For a general introduction to Compose projects, services, and the `compose.yaml` file, see Docker's [How Compose works](https://docs.docker.com/compose/intro/compose-application-model/) documentation.
68
73
69
-
When a step below says to create a file, paste the complete file contents shown. When a step says to add or update part of an existing Compose file, merge the YAML into the existing top-level key shown by the snippet. For example, if a snippet starts with `services:`, add the named service under the existing top-level `services:` map. Do not create a second `services:` block in the same file.
74
+
{{% notice Note %}}
75
+
When you creating a file for any of the following steps, paste the complete file contents as shown.
76
+
77
+
When you update part of an existing Compose file for a step, merge the YAML into the existing top-level key shown by the snippet. For example, if a snippet starts with `services:`, add the named service under the existing top-level `services:` map. Don't create a second `services:` block in the same file.
78
+
{{% /notice %}}
70
79
71
80
## Turn the sources into a Compose project
72
81
@@ -128,7 +137,7 @@ Check that Compose can read the project:
128
137
docker compose config
129
138
```
130
139
131
-
You should see output that includes the resolved `webapp` service:
140
+
The output includes the resolved `webapp` service, and is similar to:
132
141
133
142
```output
134
143
services:
@@ -142,7 +151,7 @@ services:
142
151
published: "3001"
143
152
```
144
153
145
-
At this point, Compose can build and run the Cortex-A web application as a normal Linux container. The image runs `webapp/src/app.py`, packages the Jinja templates from `webapp/src/templates/`, the static assets from `webapp/src/static/`, and the ImageNet labels from `webapp/src/data/imagenet_classes.txt`. The container listens on port `3000`, and Compose publishes it on host port `3001` unless you set `WEBAPP_PORT` to another value.
154
+
At this point, Compose can build and run the Cortex-A web application as a normal Linux container. The image runs `webapp/src/app.py`. It packages the Jinja templates from `webapp/src/templates/`, the static assets from `webapp/src/static/`, and the ImageNet labels from `webapp/src/data/imagenet_classes.txt`. The container listens on port `3000`, and Compose publishes it on host port `3001` unless you set `WEBAPP_PORT` to another value.
Do not replace the existing root `webapp` service with the snippet above. The root file should now have three service names under the same top-level `services:` map: `webapp`, `pte-artifacts`, and `runner-artifacts`.
218
+
Don't replace the existing root `webapp` service with this snippet. The root file should now have three service names under the same top-level `services:` map: `webapp`, `pte-artifacts`, and `runner-artifacts`.
210
219
211
-
These services are used only to build artifacts. They do not run as part of the deployed application. `scale: 0` tells Compose not to start containers for them, while still allowing other services to copy files from their build outputs.
220
+
These services are used only to build artifacts. They don't run as part of the deployed application. `scale: 0` tells Compose not to start containers for them, while still allowing other services to copy files from their build outputs.
212
221
213
222
Replace `webapp/compose.yaml` with the following version so the Flask image imports the `.pte` artifact:
214
223
@@ -257,9 +266,9 @@ services:
257
266
remoteproc.name: imx-rproc
258
267
```
259
268
260
-
Keep the existing `webapp`, `pte-artifacts`, and `runner-artifacts` services in the same file. This step adds one more service; it does not replace any of the previous services.
269
+
Keep the existing `webapp`, `pte-artifacts`, and `runner-artifacts` services in the same file. This step adds one more service and doesn't replace any of the previous services.
261
270
262
-
This is the heterogeneous deployment hook. Docker still builds an image, but the service is not started as a Linux userspace process. The runtime `io.containerd.remoteproc.v1` selects Remoteproc Runtime, and the `remoteproc.name` annotation tells the shim to use the i.MX remote processor driver.
271
+
This is the heterogeneous deployment hook. Docker still builds an image, but the service doesn't start as a Linux userspace process. The runtime `io.containerd.remoteproc.v1` selects Remoteproc Runtime, and the `remoteproc.name` annotation tells the shim to use the i.MX remote processor driver.
263
272
264
273
Update the existing root `webapp` service so it depends on the CM33 runner and passes the cache image values into the build. Keep the existing `extends` block, then add `depends_on` and `build.args` as shown:
265
274
@@ -280,14 +289,14 @@ services:
280
289
281
290
The web app is privileged and mounts `/sys` and `/dev` because it checks the device tree, reads remoteproc state through `/sys/class/remoteproc`, talks to `/dev/ttyRPMSG*`, writes shared memory through `/dev/mem`, and checks for `/dev/ethosu0`.
282
291
283
-
Keep the web app build context in `webapp/compose.yaml`. The root `webapp.build.args` block above only supplies Topo-collected build arguments; it should not replace the extended build context and Dockerfile from `webapp/compose.yaml`.
292
+
Keep the web app build context in `webapp/compose.yaml`. The root `webapp.build.args` block supplies only Topo-collected build arguments. It shouldn't replace the extended build context and Dockerfile from `webapp/compose.yaml`.
284
293
285
294
## Add Topo metadata and arguments
286
295
287
296
After the Compose services are complete, add the root-level `x-topo` block.
288
297
Keep it at the root of `compose.yaml`, as a sibling of `services`, not under `services`.
289
298
290
-
If you want to use an agent skill to perform this step, skip to the optional step below.
299
+
If you want to use an agent skill to perform this step, skip to the optional step.
The `features` value tells Topo that this Template requires `remoteproc-runtime` support on the target. This is useful when checking for project compatibility with the `topo templates --target <target>` command.
318
+
The `features` value tells Topo that this template requires `remoteproc-runtime` support on the target. This is useful when checking for project compatibility with the `topo templates --target <target>` command.
310
319
311
-
The `args` entries describe configurable build inputs. Compose consumes those values through the `cache_from` interpolation you added earlier:
320
+
The `args` entries describe configurable build inputs. Compose consumes those values through the `cache_from` interpolation that you added earlier:
312
321
313
322
```output
314
323
cache_from:
@@ -317,13 +326,13 @@ cache_from:
317
326
318
327
The root `webapp.build.args` block also makes the Topo-provided values visible in the Compose build model while preserving the `webapp/` build context inherited through `extends`.
319
328
320
-
Keep runtime settings such as `WEBAPP_PORT` as normal Compose interpolation unless you intentionally want Topo to collect them as Template setup arguments.
329
+
Keep runtime settings such as `WEBAPP_PORT` as normal Compose interpolation unless you intentionally want Topo to collect them as Topo Template setup arguments.
321
330
322
331
## (Optional) Use an Agent Skill to add the Topo metadata
323
332
324
333
The [Topo Template Format](https://github.com/arm/topo-template-format) repository includes public authoring skills for agents that support skill installation:
325
334
326
-
- `topo-template-context`: provides Topo and Topo Template reference context for `x-topo` metadata, schema, docs, and CLI Template behavior.
335
+
- `topo-template-context`: provides Topo and Topo Template reference context for `x-topo` metadata, schema, docs, and CLI template behavior.
327
336
- `topo-template-bootstrap`: converts a Compose repository into a Topo Template by adding or improving `compose.yaml` and `x-topo` metadata.
328
337
- `topo-template-lint`: reviews a Topo Template for schema correctness, metadata consistency, deployment success messages, and build argument wiring.
329
338
@@ -333,7 +342,7 @@ Install the skills with `npx skills`:
333
342
npx skills add arm/topo-template-format
334
343
```
335
344
336
-
If your agent does not use `npx skills`, manually copy or symlink the directories under `../topo-template-format/skills/` into your agent's skills directory.
345
+
If your agent doesn't use `npx skills`, manually copy or symlink the directories under `../topo-template-format/skills/` into your agent's skills directory.
337
346
338
347
Restart your agent after installing or updating the skills.
339
348
@@ -354,7 +363,7 @@ Validate compose.yaml against the Topo Template Format schema.
354
363
Check README alignment, Remoteproc Runtime metadata, and x-topo.args wiring.
355
364
```
356
365
357
-
## Validate the final Template
366
+
## Validate the final Topo Template
358
367
359
368
Check the Compose model and check that the Topo metadata is present:
360
369
@@ -368,7 +377,7 @@ In the `docker compose config` output, check that the resolved `webapp` service
368
377
- `build.dockerfile`set to `Dockerfile`
369
378
- `build.additional_contexts.pte_artifacts`set to `service:pte-artifacts`
370
379
371
-
Install `check-jsonschema` if it is not already available:
380
+
Install `check-jsonschema` if it's not already available:
372
381
373
382
{{< tabpane code=true >}}
374
383
{{< tab header="macOS" language="shell" >}}
@@ -407,4 +416,4 @@ Review these points:
407
416
408
417
You started with two non-Topo, non-Compose projects, made them a standard Compose project, and then converted that Compose project into a Topo Template. You created the web app image, added artifact builds for the ExecuTorch `.pte` model and Cortex-M33 ELF, packaged the firmware as a Remoteproc Runtime service, and exposed the build cache inputs as Topo arguments.
409
418
410
-
Next, you will prepare the FRDM i.MX 93 target, deploy the Template with Topo, and run the image classification application.
419
+
Next, you'll prepare the FRDM i.MX 93 target, deploy the template with Topo, and run the image classification application.
0 commit comments