Skip to content

Commit 9345972

Browse files
authored
Update install script and building from source docs (#10652)
### Summary - Updated `install_requirements.sh` to improve compatibility with source-built PyTorch and Intel macOS systems. - Added checks to prevent install commands from altering existing PyTorch builds by adding the `--no-deps` flag. - Removed `torchaudio` and `torchvision` dependencies for Intel macOS systems to avoid compatibility issues. Fixes #9772 ### Test plan Tested executorch installations with source-built PyTorch on: - Intel-macOS with PyTorch 2.7.0, Python 3.12.9 - ARM64 macOS with PyTorch 2.8.0a0, Python 3.12.9 Validated by exporting and running the MobileNet V2 image classification model, following the examples on the [Getting Started with ExecuTorch](https://pytorch.org/executorch/stable/getting-started.html) page. cc @larryliu0820 @jathu
1 parent 496cb05 commit 9345972

File tree

6 files changed

+42
-7
lines changed

6 files changed

+42
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ It supports a wide range of models including LLMs (Large Language Models), CV (C
1919
Platform Support:
2020
- Operating Systems:
2121
- iOS
22-
- Mac
22+
- MacOS (ARM64)
2323
- Android
2424
- Linux
2525
- Microcontrollers

docs/source/backends-xnnpack.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The XNNPACK delegate is the ExecuTorch solution for CPU execution on mobile CPUs
1414
- ARM64 on Android, iOS, macOS, Linux, and Windows.
1515
- ARMv7 (with NEON) on Android.
1616
- ARMv6 (with VFPv2) on Linux.
17-
- x86 and x86-64 (up to AVX512) on Windows, Linux, macOS, Android, and iOS simulator.
17+
- x86 and x86-64 (up to AVX512) on Windows, Linux, Android.
1818

1919
## Development Requirements
2020

docs/source/getting-started.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ The following are required to install the ExecuTorch host libraries, needed to e
1010

1111
- Python 3.10 - 3.12
1212
- g++ version 7 or higher, clang++ version 5 or higher, or another C++17-compatible toolchain.
13-
- Linux or MacOS operating system (Arm or x86).
14-
- Windows is supported via WSL.
13+
- Linux (x86_64 or ARM64) or macOS (ARM64).
14+
- Intel-based macOS systems require building PyTorch from source (see [Building From Source](using-executorch-building-from-source.md) for instructions).
15+
- Windows is supported via WSL.
1516

1617
## Installation
1718
To use ExecuTorch, you will need to install both the Python package and the appropriate platform-specific runtime libraries. Pip is the recommended way to install the ExecuTorch python package.

docs/source/using-executorch-building-from-source.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Linux (x86_64)
1616
- Ubuntu 20.04.6 LTS+
1717
- RHEL 8+
1818

19-
macOS (x86_64/M1/M2)
19+
macOS (x86_64/ARM64)
2020
- Big Sur (11.0)+
2121

2222
Windows (x86_64)
@@ -56,13 +56,27 @@ Or alternatively, [install conda on your machine](https://conda.io/projects/cond
5656
conda create -yn executorch python=3.10.0 && conda activate executorch
5757
```
5858

59-
## Install ExecuTorch pip package from Source
59+
## Install ExecuTorch pip package from source
6060
```bash
6161
# Install ExecuTorch pip package and its dependencies, as well as
6262
# development tools like CMake.
6363
# If developing on a Mac, make sure to install the Xcode Command Line Tools first.
64+
# Intel-based macOS systems require building PyTorch from source (see below)
6465
./install_executorch.sh
6566
```
67+
68+
See the [PyTorch instructions](https://github.com/pytorch/pytorch#installation) on how to build PyTorch from source.
69+
70+
Use the [`--use-pt-pinned-commit` flag](../../install_executorch.py) to install ExecuTorch with an existing PyTorch build:
71+
72+
```bash
73+
./install_executorch.sh --use-pt-pinned-commit
74+
```
75+
76+
For Intel-based macOS systems, use the [`--use-pt-pinned-commit --minimal` flags](../../install_executorch.py):
77+
```bash
78+
./install_executorch.sh --use-pt-pinned-commit --minimal
79+
```
6680

6781
Not all backends are built into the pip wheel by default. You can link these missing/experimental backends by turning on the corresponding cmake flag. For example, to include the MPS backend:
6882

docs/source/using-executorch-ios.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ExecuTorch supports both iOS and macOS via Objective-C, Swift, and C++. ExecuTor
44

55
## Integration
66

7-
The ExecuTorch Runtime for iOS and macOS is distributed as a collection of prebuilt [.xcframework](https://developer.apple.com/documentation/xcode/creating-a-multi-platform-binary-framework-bundle) binary targets. These targets are compatible with both iOS and macOS devices and simulators and are available in both release and debug modes:
7+
The ExecuTorch Runtime for iOS and macOS (ARM64) is distributed as a collection of prebuilt [.xcframework](https://developer.apple.com/documentation/xcode/creating-a-multi-platform-binary-framework-bundle) binary targets. These targets are compatible with both iOS and macOS devices and simulators and are available in both release and debug modes:
88

99
* `executorch` - Main Runtime components
1010
* `backend_coreml` - Core ML backend

install_requirements.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ def python_is_compatible():
7575

7676

7777
def install_requirements(use_pytorch_nightly):
78+
# Skip pip install on Intel macOS if using nightly.
79+
if use_pytorch_nightly and is_intel_mac_os():
80+
print(
81+
"ERROR: Prebuilt PyTorch wheels are no longer available for Intel-based macOS.\n"
82+
"Please build from source by following https://docs.pytorch.org/executorch/main/using-executorch-building-from-source.html",
83+
file=sys.stderr,
84+
)
85+
sys.exit(1)
86+
7887
# pip packages needed by exir.
7988
TORCH_PACKAGE = [
8089
# Setting use_pytorch_nightly to false to test the pinned PyTorch commit. Note
@@ -163,6 +172,17 @@ def install_optional_example_requirements(use_pytorch_nightly):
163172
)
164173

165174

175+
# Prebuilt binaries for Intel-based macOS are no longer available on PyPI; users must compile from source.
176+
# PyTorch stopped building macOS x86_64 binaries since version 2.3.0 (January 2024).
177+
def is_intel_mac_os():
178+
# Returns True if running on Intel macOS.
179+
return platform.system().lower() == "darwin" and platform.machine().lower() in (
180+
"x86",
181+
"x86_64",
182+
"i386",
183+
)
184+
185+
166186
def main(args):
167187
parser = argparse.ArgumentParser()
168188
parser.add_argument(

0 commit comments

Comments
 (0)