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
Added docs for setting up executorch on windows (#11273)
### Summary
First documentation for setting up ExecuTorch for Windows and exporting
MobileNet V2 model and executing.
This version works only on Windows Powershell on admin mode.
---------
Co-authored-by: Nikhil Viswanath Sivakumar <nikhilviswanath@meta.com>
Copy file name to clipboardExpand all lines: docs/source/using-executorch-building-from-source.md
+149Lines changed: 149 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -204,7 +204,156 @@ I 00:00:00.000764 executorch:executor_runner.cpp:180] Model executed successfull
204
204
I 00:00:00.000770 executorch:executor_runner.cpp:184] 1 outputs:
205
205
Output 0: tensor(sizes=[1], [2.])
206
206
```
207
+
## Build ExecuTorch for Windows
207
208
209
+
This document outlines the current known working build instructions for building and validating ExecuTorch on a Windows machine.
210
+
211
+
This demo uses the
212
+
[MobileNet v2](https://pytorch.org/vision/main/models/mobilenetv2.html) model to classify images using the [XNNPACK](https://github.com/google/XNNPACK) backend.
213
+
214
+
Note that all commands should be executed on Windows powershell in administrator mode.
215
+
216
+
### Pre-requisites
217
+
218
+
#### 1. Install Miniconda for Windows
219
+
Install miniconda for Windows from the [official website](https://docs.conda.io/en/latest/miniconda.html).
220
+
221
+
#### 2. Install Git for Windows
222
+
Install Git for Windows from the [official website](https://git-scm.com/download/win).
223
+
224
+
#### 3. Install ClangCL for Windows
225
+
Install ClangCL for Windows from the [official website](https://learn.microsoft.com/en-us/cpp/build/clang-support-msbuild?view=msvc-170).
226
+
227
+
228
+
### Create the Conda Environment
229
+
To check if conda is detected by the powershell prompt, try `conda list` or `conda --version`
230
+
231
+
If conda is not detected, you could run the powershell script for conda named `conda-hook.ps1`.
232
+
To verify that Conda is available in the in the powershell environment, run try `conda list` or `conda --version`.
233
+
If Conda is not available, run conda-hook.ps1 as follows:
234
+
```bash
235
+
$miniconda_dir\\shell\\condabin\\conda-hook.ps1
236
+
```
237
+
where `$miniconda_dir` is the directory where you installed miniconda
238
+
This is `“C:\Users\<username>\AppData\Local”` by default.
239
+
240
+
#### Create and activate the conda environment:
241
+
```bash
242
+
conda create -yn et python=3.12
243
+
conda activate et
244
+
```
245
+
246
+
### Check Symlinks
247
+
Set the following environment variable to enable symlinks:
248
+
```bash
249
+
git config --global core.symlinks true
250
+
```
251
+
252
+
### Set up ExecuTorch
253
+
Clone ExecuTorch from the [official GitHub repository](https://github.com/pytorch/executorch).
Currently, there are a lot of components that are not buildable on Windows. The below instructions install a very minimal ExecuTorch which can be used as a sanity check.
262
+
263
+
#### Move into the `executorch` directory
264
+
```bash
265
+
cd executorch
266
+
```
267
+
268
+
#### (Optional) Run a --clean script prior to running the .bat file.
269
+
```bash
270
+
./install_executorch.bat --clean
271
+
```
272
+
273
+
#### Run the setup script.
274
+
You could run the .bat file or the python script.
275
+
```bash
276
+
./install_executorch.bat
277
+
# OR
278
+
# python install_executorch.py
279
+
```
280
+
281
+
### Export MobileNet V2
282
+
283
+
Create the following script named export_mv2.py
284
+
285
+
```bash
286
+
from torchvision.models import mobilenet_v2
287
+
from torchvision.models.mobilenetv2 import MobileNet_V2_Weights
288
+
289
+
mv2 = mobilenet_v2(weights=MobileNet_V2_Weights.DEFAULT) # This is torch.nn.Module
290
+
291
+
import torch
292
+
from executorch.exir import to_edge
293
+
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
294
+
295
+
model = mv2.eval() # turn into evaluation mode
296
+
297
+
example_inputs = (torch.randn((1, 3, 224, 224)),) # Necessary for exporting the model
0 commit comments