Skip to content

Commit 00c6211

Browse files
committed
add tutorial for inductor on windows cpu
1 parent be7f1b3 commit 00c6211

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
How to use TorchInductor on Windows CPU
2+
=======================================
3+
4+
**Author**: `Xu, Han <https://github.com/xuhancn>`_, `Zhaoqiong Zheng <https://github.com/ZhaoqiongZ>`_
5+
6+
7+
Introduction
8+
------------
9+
10+
TorchInductor is the new compiler backend that compiles the FX Graphs generated by TorchDynamo into optimized C++/Triton kernels.
11+
12+
This tutorial introduces the steps for utilizing TorchInductor on Windows CPU.
13+
14+
15+
16+
Software Installation
17+
---------------------
18+
19+
Now, we will walk you through a step-by-step tutorial for how to use torchinductor on Windows CPU.
20+
21+
Install a Compiler
22+
^^^^^^^^^^^^^^^^^^
23+
24+
TorchInductor Optimization need a compiler, let's take MSVC as an example.
25+
26+
Download and install `MSVC <https://visualstudio.microsoft.com/downloads/>`_.
27+
28+
During Installation, chosse `Desktop Development with C++` in the `Desktop & Mobile` Section and then install.
29+
30+
.. note::
31+
32+
You can also choose other compiler like Clang & Intel Compiler.
33+
34+
35+
Install Miniforge
36+
^^^^^^^^^^^^^^^^^
37+
38+
Download and install `Miniforge <https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Windows-x86_64.exe>`_.
39+
40+
Set Up Environment
41+
^^^^^^^^^^^^^^^^^^
42+
43+
1. Open a command line environment via cmd.exe.
44+
2. Activate `MSVC` via below command:
45+
::
46+
47+
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat"
48+
3. Activate `conda` via below command:
49+
::
50+
51+
"C:/ProgramData/miniforge3/Scripts/activate.bat"
52+
4. Create and activate customer conda environment:
53+
::
54+
55+
conda create -n inductor_cpu_windows python=3.10 -y
56+
conda activate inductor_cpu_windows
57+
58+
5. `Install PyTorch 2.5 <https://pytorch.org/get-started/locally/>`_ or later.
59+
6. Try `torchinductor` on Windows CPU:
60+
::
61+
62+
import torch
63+
def foo(x, y):
64+
a = torch.sin(x)
65+
b = torch.cos(x)
66+
return a + b
67+
opt_foo1 = torch.compile(foo)
68+
print(opt_foo1(torch.randn(10, 10), torch.randn(10, 10)))
69+
70+
Conclusion
71+
----------
72+
73+
With this tutorial, we introduce how to use Inductor with X86 CPU in PyTorch 2.5 on Windows.

0 commit comments

Comments
 (0)