|
| 1 | +# Intel® XPU Backend for Triton\* on Windows |
| 2 | + |
| 3 | +Intel® XPU Backend for Triton\* support for Windows is currently experimental and requires compiling PyTorch and Intel® XPU Backend for Triton\* from source. |
| 4 | + |
| 5 | +## 1. Prerequisites |
| 6 | + |
| 7 | +* Windows 11 |
| 8 | + |
| 9 | +* GPU card |
| 10 | + * Intel® Arc™ A-Series Graphics for Desktops |
| 11 | + * [Intel® Arc™ A750](https://www.intel.com/content/www/us/en/products/sku/227954/intel-arc-a750-graphics/specifications.html) |
| 12 | + * [Intel® Arc™ A770](https://www.intel.com/content/www/us/en/products/sku/229151/intel-arc-a770-graphics-16gb/specifications.html) |
| 13 | + * Intel® Arc™ B-Series Graphics for Desktops |
| 14 | + * [Intel® Arc™ B570](https://www.intel.com/content/www/us/en/products/sku/241676/intel-arc-b570-graphics/specifications.html) |
| 15 | + * [Intel® Arc™ B580](https://www.intel.com/content/www/us/en/products/sku/241598/intel-arc-b580-graphics/specifications.html) |
| 16 | + |
| 17 | +* Latest [GPU driver](https://www.intel.com/content/www/us/en/download/785597/intel-arc-iris-xe-graphics-windows.html) |
| 18 | + |
| 19 | +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). |
| 20 | + |
| 21 | +## 2. Tools and dependencies |
| 22 | + |
| 23 | +### Enable Windows long paths |
| 24 | + |
| 25 | +Enable long paths for Windows file system. |
| 26 | + |
| 27 | +``` |
| 28 | +Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 |
| 29 | +``` |
| 30 | + |
| 31 | +Reboot your computer to apply the change to the file system. |
| 32 | + |
| 33 | +### Microsoft Visual Studio 2022 |
| 34 | + |
| 35 | +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: |
| 36 | + * Microsoft.VisualStudio.Component.VC.Tools.x86.x64 |
| 37 | + * Microsoft.VisualStudio.Component.Windows11SDK.22621 |
| 38 | + * Microsoft.VisualStudio.Component.VC.CMake.Project |
| 39 | + |
| 40 | +### Intel® Deep Learning Essentials |
| 41 | + |
| 42 | +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). |
| 43 | +By default, it is installed to `C:\Program Files (x86)\Intel\oneAPI`. |
| 44 | + |
| 45 | +### Level Zero SDK |
| 46 | + |
| 47 | +Identify Level Zero version installed with the GPU Driver: |
| 48 | + |
| 49 | +```shell |
| 50 | +(Get-Item C:\Windows\system32\ze_loader.dll).VersionInfo.ProductVersion |
| 51 | +``` |
| 52 | + |
| 53 | +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. |
| 54 | + |
| 55 | +### Chocolatey |
| 56 | + |
| 57 | +``` |
| 58 | +Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) |
| 59 | +``` |
| 60 | + |
| 61 | +Restart your PowerShell session to make sure `chocolatey` is properly initialized. |
| 62 | + |
| 63 | +### Python |
| 64 | + |
| 65 | +If you do not have a system Python installed at this step, you can install one with `chocolatey`. |
| 66 | +For example: |
| 67 | + |
| 68 | +``` |
| 69 | +choco install python --version=3.9.13 |
| 70 | +``` |
| 71 | + |
| 72 | +### Git |
| 73 | + |
| 74 | +Install `git` with other POSIX tools, such as `bash`: |
| 75 | + |
| 76 | +``` |
| 77 | +choco install -y git.install --params "'/GitAndUnixToolsOnPath /WindowsTerminal /NoAutoCrlf'" |
| 78 | +``` |
| 79 | + |
| 80 | +Restart your PowerShell session to make sure `git` and other tools are properly initialized. |
| 81 | + |
| 82 | +Enable symbolic links and long paths: |
| 83 | + |
| 84 | +``` |
| 85 | +git config --global core.longpaths true |
| 86 | +git config --global core.symlinks true |
| 87 | +``` |
| 88 | + |
| 89 | +### Ninja |
| 90 | + |
| 91 | +``` |
| 92 | +choco install -y ninja |
| 93 | +``` |
| 94 | + |
| 95 | +### Pscx |
| 96 | + |
| 97 | +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. |
| 98 | + |
| 99 | +``` |
| 100 | +Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force |
| 101 | +Install-Module Pscx -Scope CurrentUser -Force -AllowClobber |
| 102 | +``` |
| 103 | + |
| 104 | +## 3. Build environment |
| 105 | + |
| 106 | +Clone repository: |
| 107 | + |
| 108 | +``` |
| 109 | +git clone https://github.com/intel/intel-xpu-backend-for-triton.git |
| 110 | +``` |
| 111 | + |
| 112 | +Create a new virtual environment: |
| 113 | + |
| 114 | +``` |
| 115 | +cd intel-xpu-backend-for-triton |
| 116 | +python -m venv .venv |
| 117 | +``` |
| 118 | + |
| 119 | + |
| 120 | +## 4. PyTorch |
| 121 | + |
| 122 | +Activate the virtual environment: |
| 123 | + |
| 124 | +``` |
| 125 | +.venv\Scripts\activate.ps1 |
| 126 | +``` |
| 127 | + |
| 128 | +Initialize Intel® Deep Learning Essentials, for example: |
| 129 | + |
| 130 | +``` |
| 131 | +Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" |
| 132 | +``` |
| 133 | + |
| 134 | +Set `ZE_PATH` to the location of Level Zero SDK, for example: |
| 135 | + |
| 136 | +``` |
| 137 | +$env:ZE_PATH = "C:\level_zero" |
| 138 | +``` |
| 139 | + |
| 140 | +Build and install PyTorch: |
| 141 | + |
| 142 | +``` |
| 143 | +$env:CMAKE_SHARED_LINKER_FLAGS = "/FORCE:MULTIPLE" |
| 144 | +$env:CMAKE_MODULE_LINKER_FLAGS = "/FORCE:MULTIPLE" |
| 145 | +$env:CMAKE_EXE_LINKER_FLAGS = "/FORCE:MULTIPLE" |
| 146 | +bash -c "./scripts/install-pytorch.sh --source" |
| 147 | +``` |
| 148 | + |
| 149 | +Check that PyTorch is installed: |
| 150 | + |
| 151 | +``` |
| 152 | +python -c 'import torch;print(torch.__version__)' |
| 153 | +``` |
| 154 | + |
| 155 | +## 5. Triton |
| 156 | + |
| 157 | +Install build dependencies: |
| 158 | + |
| 159 | +``` |
| 160 | +pip install -U wheel pybind11 cython cmake 'setuptools>=65.6.1' |
| 161 | +``` |
| 162 | + |
| 163 | +Build and install Triton: |
| 164 | + |
| 165 | +``` |
| 166 | +cd python |
| 167 | +pip install -v --no-build-isolation '.[build,tests,tutorials]' |
| 168 | +cd .. |
| 169 | +``` |
| 170 | + |
| 171 | +Check that Triton is installed: |
| 172 | + |
| 173 | +``` |
| 174 | +python -c 'import triton; print(triton.__version__)' |
| 175 | +``` |
| 176 | + |
| 177 | +## 6. New PowerShell session |
| 178 | + |
| 179 | +In a new PowerShell session, make sure the current directory is `intel-xpu-backend-for-triton` (a clone of the repository). |
| 180 | +Initialize environment variables: |
| 181 | + |
| 182 | +``` |
| 183 | +.venv\Scripts\activate.ps1 |
| 184 | +Invoke-BatchFile "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" |
| 185 | +$env:ZE_PATH = "C:\level_zero" |
| 186 | +``` |
| 187 | + |
| 188 | +Check that PyTorch and Triton are available: |
| 189 | + |
| 190 | +``` |
| 191 | +python -c 'import torch;print(torch.__version__)' |
| 192 | +python -c 'import triton; print(triton.__version__)' |
| 193 | +``` |
0 commit comments