Skip to content

Commit

Permalink
Build instructions for Windows (#3584)
Browse files Browse the repository at this point in the history
Fixes #3127.
  • Loading branch information
pbchekin authored Mar 4, 2025
1 parent 84e8780 commit b3f9c6e
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Intel® XPU Backend for Triton\* is a out of tree backend module for [Triton](ht

Note that Intel® XPU Backend for Triton\* is not compatible with Intel® Extension for PyTorch\* and Intel® oneAPI Base Toolkit\*.

See also: [experimental support for Windows](WINDOWS.md).

# Quick Installation

## Prerequisites
Expand Down
193 changes: 193 additions & 0 deletions .github/WINDOWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# Intel® XPU Backend for Triton\* on Windows

Intel® XPU Backend for Triton\* support for Windows is currently experimental and requires compiling PyTorch and Intel® XPU Backend for Triton\* from source.

## 1. Prerequisites

* Windows 11

* GPU card
* Intel® Arc™ A-Series Graphics for Desktops
* [Intel® Arc™ A750](https://www.intel.com/content/www/us/en/products/sku/227954/intel-arc-a750-graphics/specifications.html)
* [Intel® Arc™ A770](https://www.intel.com/content/www/us/en/products/sku/229151/intel-arc-a770-graphics-16gb/specifications.html)
* Intel® Arc™ B-Series Graphics for Desktops
* [Intel® Arc™ B570](https://www.intel.com/content/www/us/en/products/sku/241676/intel-arc-b570-graphics/specifications.html)
* [Intel® Arc™ B580](https://www.intel.com/content/www/us/en/products/sku/241598/intel-arc-b580-graphics/specifications.html)

* Latest [GPU driver](https://www.intel.com/content/www/us/en/download/785597/intel-arc-iris-xe-graphics-windows.html)

In the following sections, all commands need to be executed in [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.5).

## 2. Tools and dependencies

### Enable Windows long paths

Enable long paths for Windows file system.

```
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1
```

Reboot your computer to apply the change to the file system.

### Microsoft Visual Studio 2022

Install Microsoft Visual Studio 2022 and make sure the following [components](https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community?view=vs-2022&preserve-view=true) are installed:
* Microsoft.VisualStudio.Component.VC.Tools.x86.x64
* Microsoft.VisualStudio.Component.Windows11SDK.22621
* Microsoft.VisualStudio.Component.VC.CMake.Project

### Intel® Deep Learning Essentials

Install the latest [Intel® Deep Learning Essentials](https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit-download.html?packages=dl-essentials&dl-essentials-os=windows&dl-win=offline).
By default, it is installed to `C:\Program Files (x86)\Intel\oneAPI`.

### Level Zero SDK

Identify Level Zero version installed with the GPU Driver:

```shell
(Get-Item C:\Windows\system32\ze_loader.dll).VersionInfo.ProductVersion
```

Find the corresponding release in https://github.com/oneapi-src/level-zero/releases, download its archive and extract to `c:\level_zero` or other location.

### Chocolatey

```
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
```

Restart your PowerShell session to make sure `chocolatey` is properly initialized.

### Python

If you do not have a system Python installed at this step, you can install one with `chocolatey`.
For example:

```
choco install python --version=3.9.13
```

### Git

Install `git` with other POSIX tools, such as `bash`:

```
choco install -y git.install --params "'/GitAndUnixToolsOnPath /WindowsTerminal /NoAutoCrlf'"
```

Restart your PowerShell session to make sure `git` and other tools are properly initialized.

Enable symbolic links and long paths:

```
git config --global core.longpaths true
git config --global core.symlinks true
```

### Ninja

```
choco install -y ninja
```

### Pscx

The module [Pscx](https://github.com/Pscx/Pscx) is required for `Invoke-BatchFile`, a command to call bat/cmd script and set environment variables in the existing PowerShell session.

```
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module Pscx -Scope CurrentUser -Force -AllowClobber
```

## 3. Build environment

Clone repository:

```
git clone https://github.com/intel/intel-xpu-backend-for-triton.git
```

Create a new virtual environment:

```
cd intel-xpu-backend-for-triton
python -m venv .venv
```


## 4. PyTorch

Activate the virtual environment:

```
.venv\Scripts\activate.ps1
```

Initialize Intel® Deep Learning Essentials, for example:

```
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
```

Set `ZE_PATH` to the location of Level Zero SDK, for example:

```
$env:ZE_PATH = "C:\level_zero"
```

Build and install PyTorch:

```
$env:CMAKE_SHARED_LINKER_FLAGS = "/FORCE:MULTIPLE"
$env:CMAKE_MODULE_LINKER_FLAGS = "/FORCE:MULTIPLE"
$env:CMAKE_EXE_LINKER_FLAGS = "/FORCE:MULTIPLE"
bash -c "./scripts/install-pytorch.sh --source"
```

Check that PyTorch is installed:

```
python -c 'import torch;print(torch.__version__)'
```

## 5. Triton

Install build dependencies:

```
pip install -U wheel pybind11 cython cmake 'setuptools>=65.6.1'
```

Build and install Triton:

```
cd python
pip install -v --no-build-isolation '.[build,tests,tutorials]'
cd ..
```

Check that Triton is installed:

```
python -c 'import triton; print(triton.__version__)'
```

## 6. New PowerShell session

In a new PowerShell session, make sure the current directory is `intel-xpu-backend-for-triton` (a clone of the repository).
Initialize environment variables:

```
.venv\Scripts\activate.ps1
Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
$env:ZE_PATH = "C:\level_zero"
```

Check that PyTorch and Triton are available:

```
python -c 'import torch;print(torch.__version__)'
python -c 'import triton; print(triton.__version__)'
```

0 comments on commit b3f9c6e

Please sign in to comment.