# Build and install ExecuTorch

## In this learning path

- [Introduction](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/observing-ethos-u-on-nxp/)
- [Understand ExecuTorch deployment on NXP with Ethos-U](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/observing-ethos-u-on-nxp/1-overview/)
- [Boot the NXP FRDM i.MX 93 board](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/observing-ethos-u-on-nxp/2-boot-nxp/)
- [Set up the ExecuTorch build environment](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/observing-ethos-u-on-nxp/4-environment-setup/)
- [Build and install ExecuTorch](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/observing-ethos-u-on-nxp/6-build-executorch/)
- [Build ExecuTorch models for Ethos-U65](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/observing-ethos-u-on-nxp/7-build-executorch-pte/)
- [Build Cortex-M33 firmware for ExecuTorch](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/observing-ethos-u-on-nxp/9-build-executorch-runner-for-cm33/)
- [Deploy and test on FRDM-IMX93](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/observing-ethos-u-on-nxp/10-deploy-executorchrunner-nxp-board/)
- [Next Steps](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/observing-ethos-u-on-nxp/_next-steps/)

## Overview
With the ExecuTorch source checked out and your virtual environment active, you can now build ExecuTorch and set up the Arm toolchain for Ethos-U cross-compilation.

For a full tutorial on building ExecuTorch, see the Learning Path [Introduction to TinyML on Arm using PyTorch and ExecuTorch](https://learn.arm.com/learning-paths/embedded-and-microcontrollers/introduction-to-tinyml-on-arm/).

## Install ExecuTorch
Upgrade pip and install build tools:
```
pip install --upgrade pip setuptools wheel
```

Build and install the `executorch` pip package:
```
./install_executorch.sh
```

After the installation finishes, verify the package is available:
```
pip list | grep executorch
```

## Set up the Arm toolchain
Initialize the Arm-specific environment and accept the EULA:
```
./examples/arm/setup.sh --i-agree-to-the-contained-eula
```

Source the environment variables:
```
source ./examples/arm/ethos-u-scratch/setup_path.sh
```

### Troubleshooting
If `install_executorch.sh` fails, install the dependencies manually:
```
pip install torch torchvision
pip install --no-build-isolation .
pip install --no-build-isolation third-party/ao
```

If `buck2` hangs during the build:
```
ps aux | grep buck
pkill -f buck
```

To clean the build environment and start fresh:
```
./install_executorch.sh --clean
git submodule sync
git submodule update --init --recursive
./install_executorch.sh
```

## What you’ve learned and what’s next
In this section you’ve:
- Installed the ExecuTorch package and verified its availability
- Set up the Arm toolchain with Ethos-U support
- Configured the environment for cross-compiling to Ethos-U65

With ExecuTorch installed and the Arm toolchain configured, you can now compile `.pte` model files targeting the Ethos-U65 NPU.
