Ubuntu machine setup

Use an Ubuntu AArch64/Arm64 or x86_64 machine for this module. An AWS Ubuntu instance is a suitable option if you do not already have an Ubuntu machine.

Suggested AWS configuration:

  • Ubuntu LTS
  • at least 4 vCPUs and 16 GB RAM
  • 100 GB disk

Remember to stop the instance after you finish the module.

Once on your Ubuntu machine, run the following commands. These commands install the build tools, install Python 3.12.14 with pyenv, and select that Python version before the ExecuTorch environment is created:

    

        
        
sudo apt update
sudo apt install -y \
  git curl ca-certificates build-essential cmake ninja-build \
  libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
  libncurses-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev \
  libffi-dev liblzma-dev

curl -fsSL https://pyenv.run | bash

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

pyenv install 3.12.14
pyenv shell 3.12.14
python --version

    

The final command should print Python 3.12.14. Keep this shell open for the ExecuTorch setup commands below so the virtual environment is created with the selected Python version.

Note

Troubleshooting

If pyenv install reports that the 3.12.14 definition was not found, update pyenv to the latest version and run the command again.

How this setup differs from Modules 1, 2, and 3

Modules 1, 2, and 3 used prebuilt Python packages inside virtual environments. In those modules, setup was mostly a pip install step: you installed ExecuTorch, PyTorch, and the Python dependencies needed to export, lower, and run CPU examples. Module 4 uses a different setup because the Ethos-U flow needs more than the Python package. You will clone the ExecuTorch source tree, install its Python package from that checkout, install the Arm backend tools, and build the bare-metal ExecuTorch runtime libraries used by the FVP runner.

The practical difference is:

ModulesSetup styleWhy
Modules 1, 2, and 3Install prebuilt Python packages into course virtual environmentsCPU examples use Python export, Python runtime checks, and Raspberry Pi scripts
Module 4Build from an ExecuTorch source checkoutEthos-U needs the Arm backend, Vela/FVP tooling, bare-metal runtime libraries, and executor-runner builds from the same tree

Clone ExecuTorch and check out the ExecuTorch 1.5.0 release used by this module:

    

        
        
EXECUTORCH_COMMIT=f7140a46ff38e919c557d45b102d3ff26097c8c9

git clone https://github.com/pytorch/executorch.git ~/executorch && \
  cd ~/executorch && \
  git checkout --detach "$EXECUTORCH_COMMIT" && \
  test "$(git rev-parse HEAD)" = "$EXECUTORCH_COMMIT" && \
  echo "Using ExecuTorch commit $(git rev-parse HEAD)"

    

The final line must print:

    

        
        
Using ExecuTorch commit f7140a46ff38e919c557d45b102d3ff26097c8c9

    

Do not continue if the clone, checkout, or commit check fails. If ~/executorch already exists, move or remove that checkout first.

After the commit has been verified, create the Python environment, install the Arm tools, and build the bare-metal runtime:

    

        
        
cd ~/executorch
python -m venv .venv
source .venv/bin/activate
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=OFF -DEXECUTORCH_BUILD_OPENVINO=OFF" \
  ./install_executorch.sh --minimal --optional-dependency ethos_u
./examples/arm/setup.sh --i-agree-to-the-contained-eula
source examples/arm/arm-scratch/setup_path.sh
./backends/arm/scripts/build_executorch.sh

    

The checkout is pinned to the official ExecuTorch 1.5.0 release. The setup commands create ~/executorch/.venv, install the ExecuTorch Python package with its Ethos-U dependencies, and build the bare-metal libraries used by the runner.

The first FVP run you perform will use the generic runner provided at:

    

        
        
~/executorch/examples/arm/executor_runner

    

This runner is model-agnostic. It loads the embedded .pte artifact, reads tensor inputs from the host during FVP simulation, runs the model, and writes raw output tensors back to the host.

Later in the module, you will apply a small patch to the runner to adapt it into a simple image classification app that prints MobileNetV2 top-5 class IDs over UART.

With the ExecuTorch environment still active, enter the course repository and install the Module 4 add-on requirements before preparing MobileNetV2. The course scripts use TorchVision and Pillow in addition to the packages installed by the ExecuTorch source setup.

    

        
        
git clone https://github.com/ArmDeveloperEcosystem/arm-courses-code-executorch.git ~/executorch_on_arm
cd ~/executorch_on_arm
python -m pip install -r module-4-ethos-npu-accelerated-inference/requirements.txt

    
Previous page Complete and continue