Windows Build Environment Settings BKC #1205
Stonepia
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This document is for environment settings for building PyTorch. If you are just using
pip install
for PyTorch, then all of the steps in this document are not needed. All you need is just pip install and run.1. System Settings:
1.1. Mandatory Step
1.1.1. Long Path Enablement
Since PyTorch will generate kernels with long file names, Long Path support must be enabled to avoid build errors.
Please refer to Maximum Path Length Limitation for details.
Open the Terminal (Admin) by right-clicking the Windows button, and execute the following:
1.2. Suggested Step
1.2.1. Developer Mode
Windows has introduced a Developer Mode. It allows the user to create symlinks with regular users. This could help to avoid potential build error. This is not a mandatory step.
2. Env Setting
You generally need
Visual Studio
,oneAPI
andconda
in your system. Since there are a lot of documents already, this section will not cover them. Be sure to install Visual Studio before install oneAPI!Just some commands for setting the env.
After installation, you need to activate the env in your terminal. There are two kinds of terminals in Windows: PowerShell and Command Prompt (cmd). I recommend using PowerShell for a modern development experience. Moreover, you could also try the latest PowerShell from PowerShell.
2.1. Option 1: Official Recommended Way
The official recommended way of running it would be:
2.1.1. Activate the env
Normally these two steps should work. If there are some environment not activated. Please refer to Notes: Activate Env Manually in CMD section.
2.1.2. Setup build environment
You also need to set the additional env:
There is a build error in PyTorch#134989.
By default, the AOT target is in BuildFlags.cmake. Since this is for dev purpose, you don't need to build all of them.
One could set according to the following.
One could find all the targets with the following:
2.1.3. Build PyTorch
Please following the official doc for build. One thing worth noting is that, the long path might still be a problem.
Thus please put the pytorch folder in a shallow folder path (
D:/pytorch
for example). Otherwise, it might be wrong.2.1.4. Notes: Activate Env Manually in CMD
In case one needs to activate the env manually:
Conda Env Activation
If your conda is not initialized, please try to initiate the conda first. You could use the following:
Then close and reopen the Command Prompt (cmd).
Visual Studio Env Activation
In case one needs to activate the environment manually, one could activate it by:
oneAPI Activation
2.2. Option 2: Use Powershell / pwsh
PowerShell is more modern to use. Thus if there is no bug, you could try with PowerShell. It is also recommended to install the latest
pwsh
from PowerShell.However, with PowerShell, one should activate all the environments manually.
2.2.1. Activate the Env
One should first setup the policy fo execute scripts.
Open the
terminal(Admin)
by right click the start menu:Then open a normal PowerShell terminal and execute the following:
Then close and reopen the PowerShell terminal.
This is the option step. Since the Step 3 will automatically activate the Visual Studio env. One could also directly open the "Visual Studio Developer PowerShell" shortcut from the start value.
To activate oneAPI, execute the following:
2.2.2. Setup Build environment
There is a build error in PyTorch#134989.
By default, the AOT target is in BuildFlags.cmake. Since this is for dev purpose, you don't need to build all of them.
One could set according to the following.
One could find all the targets with the following:
2.2.3. Build PyTorch
Please follow the official doc for build.
2.2.4. Notes: Optional step to automatically source the env
One could create a profile of PowerShell and add the oneAPI source file to it. Note that this would greatly reduce the start time of the PowerShell.
In addition, It is NOT recommended to edit the profile of the default PowerShell, please install the pwsh and edit its profile.
notepad $Profile
Then add the following:
Beta Was this translation helpful? Give feedback.
All reactions