Skip to content

Commit 17fe76d

Browse files
authored
Show every install variant on the getting started page (pytorch#23012)
### What is wrong today The Installation section gives one command, `pip install executorch`, and that command does not produce a working setup. PyTorch is not installed with it. The package does not declare torch as a dependency, because the right build depends on the hardware. In a clean environment the export example a few paragraphs further down the same page stops with `No module named 'torch'`. The CUDA packages are not mentioned anywhere on the page, although releases and nightly builds both carry `cu130`, `cu132` and `cu134`. To find any of them today you have to already know how the package index is laid out. ### What this changes The single command becomes one command template plus a small table of variants, in the spirit of the PyTorch get started page. You find the row for the machine you export on and put its name in the index URL. Nightly builds are the same names with `nightly/` in front. The section now also says why torch is on the command line, why a second index is needed, that the CUDA packages are Linux only, and what to do when your CUDA version is not one of the listed ones. A test is added next to the existing release matrix checks: the CUDA versions named in that section must be exactly the ones the release matrix publishes. A version added to or dropped from the build then cannot leave the page behind. ### What was tested Every documented variant was installed with `pip install --dry-run` in a clean environment, and the resolved executorch and torch versions come from the intended index: `cpu`, `cu130`, `cu132`, `nightly/cpu`, `nightly/cu130`, `nightly/cu132` and `nightly/cu134`. CUDA 13.4 has no release wheel yet, which the page says. The old instruction was confirmed broken: `pip install executorch` in a clean environment installs no torch, and `import executorch.exir` then fails. `pytest .ci/scripts/tests/test_filter_cuda_matrix.py` passes. It fails when a row is removed from the table, when a version that is not published is added to it, and when the section heading is renamed.
1 parent 61f9d45 commit 17fe76d

2 files changed

Lines changed: 50 additions & 12 deletions

File tree

‎.ci/scripts/tests/test_filter_cuda_matrix.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import io
1616
import json
1717
import os
18+
import re
1819
import subprocess
1920
import unittest
2021
from pathlib import Path
@@ -285,6 +286,23 @@ class TestPublishedSets(unittest.TestCase):
285286
def test_published_cuda_versions(self):
286287
self.assertEqual(FILTER.SUPPORTED_CUDA_VERSIONS, ["cu130", "cu132", "cu134"])
287288

289+
def test_published_cuda_versions_are_documented(self):
290+
# The install table on the getting started page is the only place a user is told
291+
# these wheels exist. A train published without a row there is published to nobody,
292+
# and a row left behind after a train stops being built sends people to an index
293+
# with no wheel in it.
294+
page = ROOT / "docs" / "source" / "getting-started.md"
295+
text = page.read_text(encoding="utf-8")
296+
heading = "\n## Installation\n"
297+
self.assertIn(heading, text, f"no Installation section in {page.name}")
298+
section = text.split(heading, 1)[1].split("\n## ", 1)[0]
299+
documented = set(re.findall(r"cu\d+", section))
300+
self.assertEqual(
301+
documented,
302+
set(FILTER.SUPPORTED_CUDA_VERSIONS),
303+
f"the install table in {page.name} lists {sorted(documented)}",
304+
)
305+
288306
def test_published_cuda_versions_are_supported_by_the_installer(self):
289307
supported = {
290308
f"cu{major}{minor}"

‎docs/source/getting-started.md‎

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,44 @@ The following are required to install the ExecuTorch host libraries, needed to e
1515
- On Windows, Visual Studio 2022 or later.
1616

1717
## Installation
18-
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.
18+
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. Consider installing it within a virtual environment, such as one provided by [conda](https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html#creating-environments) or [venv](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments).
1919

20-
This package includes the dependencies needed to export a PyTorch model, as well as Python runtime bindings for model testing and evaluation. Consider installing ExecuTorch within a virtual environment, such as one provided by [conda](https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html#creating-environments) or [venv](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments).
20+
Install PyTorch in the same command. The ExecuTorch package does not declare it
21+
as a dependency, because the build you need depends on your hardware, so pip
22+
cannot choose one for you. Installing ExecuTorch on its own gives an environment
23+
where exporting a model stops with `No module named 'torch'`.
2124

22-
```
23-
pip install executorch
24-
```
25-
26-
To get the latest features before they reach a stable release, install a nightly
27-
build instead. Nightly wheels are built from the `main` branch every day, so a
28-
change that has landed but is not yet in a stable release is available there first.
25+
Both packages come from the same package index. Find your machine in the table
26+
below and put the name from it in place of `<variant>`:
2927

3028
```
31-
pip install --upgrade --pre executorch torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu
29+
pip install executorch torch \
30+
--index-url https://download.pytorch.org/whl/<variant> \
31+
--extra-index-url https://pypi.org/simple
3232
```
3333

34-
`torch` is explicit because nightly ExecuTorch wheels do not declare it as a
35-
dependency.
34+
| Machine you export on | Variant |
35+
| --- | --- |
36+
| CPU only | `cpu` |
37+
| NVIDIA GPU, CUDA 13.0 | `cu130` |
38+
| NVIDIA GPU, CUDA 13.2 | `cu132` |
39+
| NVIDIA GPU, CUDA 13.4 | `cu134` |
40+
41+
The CUDA packages are built for Linux, on x86_64 and ARM64. Use the `cpu`
42+
variant on macOS and on Windows. If your CUDA version is not in the table,
43+
choose the closest lower one with the same major version, because CUDA works
44+
across minor versions but not across major ones. There is no package for CUDA
45+
12, so on CUDA 12 use the `cpu` variant or build from source.
46+
47+
To get a change that has landed on the `main` branch but is not in a release
48+
yet, use a nightly build. These are rebuilt every day. Put `nightly/` in front
49+
of the variant name, for example `nightly/cu130`, and add `--pre` to the
50+
command, otherwise pip skips development versions. Nightly builds cover the same
51+
variants. CUDA 13.4 is the newest, and until the next release it is in nightly
52+
builds only.
53+
54+
The second index is needed because a bare `--index-url` replaces PyPI instead of
55+
adding to it, and some dependencies are published only on PyPI.
3656

3757
To build the framework from source, see [Building From Source](using-executorch-building-from-source.md). Backend delegates may require additional dependencies. See the appropriate backend documentation for more information.
3858

0 commit comments

Comments
 (0)