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