mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
update windows build guide (#47840)
Summary: Fixes https://github.com/pytorch/pytorch/issues/47483 Pull Request resolved: https://github.com/pytorch/pytorch/pull/47840 Reviewed By: malfet Differential Revision: D24951466 Pulled By: walterddr fbshipit-source-id: 7530ec5a3aff7095978c330d9b78e58b10349373
This commit is contained in:
parent
147a48fb27
commit
f9552e6da4
48
README.md
48
README.md
|
|
@ -158,6 +158,7 @@ If you want to compile with CUDA support, install
|
|||
- [NVIDIA CUDA](https://developer.nvidia.com/cuda-downloads) 9.2 or above
|
||||
- [NVIDIA cuDNN](https://developer.nvidia.com/cudnn) v7 or above
|
||||
- [Compiler](https://gist.github.com/ax3l/9489132) compatible with CUDA
|
||||
Note: You could refer to the [cuDNN Support Matrix](https://docs.nvidia.com/deeplearning/cudnn/pdf/cuDNN-Support-Matrix.pdf) for cuDNN versions with the various supported CUDA, CUDA driver and NVIDIA hardwares
|
||||
|
||||
If you want to disable CUDA support, export environment variable `USE_CUDA=0`.
|
||||
Other potentially useful environment variables may be found in `setup.py`.
|
||||
|
|
@ -233,44 +234,51 @@ Each CUDA version only supports one particular XCode version. The following comb
|
|||
|
||||
On Windows
|
||||
|
||||
At least Visual Studio 2017 version 15.6 with the toolset 14.13 and [NVTX](https://docs.nvidia.com/gameworks/content/gameworkslibrary/nvtx/nvidia_tools_extension_library_nvtx.htm) are needed.
|
||||
Build with CPU
|
||||
|
||||
If the version of Visual Studio 2017 is higher than 15.6, installing of "VC++ 2017 version 15.6 v14.13 toolset" is strongly recommended.
|
||||
<br/> If the version of Visual Studio 2017 is lesser than 15.6, please update Visual Studio 2017 to the latest version along with installing "VC++ 2017 version 15.6 v14.13 toolset".
|
||||
<br/> There is no guarantee of the correct building with VC++ 2017 toolsets, others than version 15.6 v14.13.
|
||||
<br/> "VC++ 2017 version 15.6 v14.13 toolset" might be installed onto already installed Visual Studio 2017 by running its installation once again and checking the corresponding checkbox under "Individual components"/"Compilers, build tools, and runtimes".
|
||||
It's fairly easy to build with CPU. Visual Studio 2019 version 16.7.6 (MSVC toolchain version 14.27) or higher is recommended.
|
||||
|
||||
Build with CUDA
|
||||
[NVTX](https://docs.nvidia.com/gameworks/content/gameworkslibrary/nvtx/nvidia_tools_extension_library_nvtx.htm) is needed to build Pytorch with CUDA.
|
||||
NVTX is a part of CUDA distributive, where it is called "Nsight Compute". To install it onto already installed CUDA run CUDA installation once again and check the corresponding checkbox.
|
||||
Be sure that CUDA with Nsight Compute is installed after Visual Studio 2017.
|
||||
Make sure that CUDA with Nsight Compute is installed after Visual Studio.
|
||||
|
||||
Currently, VS 2017, VS 2019, and Ninja are supported as the generator of CMake. If `ninja.exe` is detected in `PATH`, then Ninja will be used as the default generator, otherwise, it will use VS 2017.
|
||||
<br/> If Ninja is selected as the generator, the latest MSVC which is newer than VS 2015 (14.0) will get selected as the underlying toolchain. If you use CMake <= 3.14.2 and has VS 2019 installed, then even if you specify VS 2017 as the generator, VS 2019 will get selected as the generator.
|
||||
Currently, VS 2017 / 2019, and Ninja are supported as the generator of CMake. If `ninja.exe` is detected in `PATH`, then Ninja will be used as the default generator, otherwise, it will use VS 2017 / 2019.
|
||||
<br/> If Ninja is selected as the generator, the latest MSVC will get selected as the underlying toolchain.
|
||||
|
||||
CUDA and MSVC have strong version dependencies, so even if you use VS 2017 / 2019, you will get build errors like `nvcc fatal : Host compiler targets unsupported OS`. For this kind of problem, please install the corresponding VS toolchain in the table below, and then you can either specify the toolset during activation (recommended) or set `CUDAHOSTCXX` to override the Cuda host compiler (not recommended if there are big version differences).
|
||||
CUDA, MSVC, and PyTorch versions are interdependent; please install matching versions from this table:
|
||||
| CUDA version | Newest supported VS version | PyTorch version |
|
||||
| ------------ | ------------------------------------------------------- | --------------- |
|
||||
| 9.2 | Visual Studio 2017 Update 5 (15.5) (`_MSC_VER` <= 1912) | 0.4.1 ~ 1.5.1 |
|
||||
| 10.1 | Visual Studio 2019 (16.X) (`_MSC_VER` < 1930) | 1.3.0 ~ 1.7.0 |
|
||||
| 10.2 | Visual Studio 2019 (16.X) (`_MSC_VER` < 1930) | 1.5.0 ~ 1.7.0 |
|
||||
| 11.0 | Visual Studio 2019 (16.X) (`_MSC_VER` < 1930) | 1.7.0 |
|
||||
|
||||
Note: There's a [compilation issue](https://github.com/oneapi-src/oneDNN/issues/812) in serveral Visual Studio 2019 versions since 16.7.1, so please make sure your Visual Studio 2019 version is not in 16.7.1 ~ 16.7.5
|
||||
|
||||
Additional libraries such as
|
||||
[Magma](https://developer.nvidia.com/magma), [oneDNN, a.k.a MKLDNN or DNNL](https://github.com/oneapi-src/oneDNN), and [Sccache](https://github.com/mozilla/sccache) are often needed. Please refer to the [installation-helper](https://github.com/pytorch/pytorch/tree/master/.jenkins/pytorch/win-test-helpers/installation-helpers) to install them.
|
||||
|
||||
You can refer to the [build_pytorch.bat](https://github.com/pytorch/pytorch/blob/master/.jenkins/pytorch/win-test-helpers/build_pytorch.bat) script for some other environment variables configurations
|
||||
|
||||
| CUDA version | Newest supported VS version |
|
||||
| ------------ | ------------------------------------------------------- |
|
||||
| 9.2 | Visual Studio 2017 Update 5 (15.5) (`_MSC_VER` <= 1912) |
|
||||
| 10.0 | Visual Studio 2017 (15.X) (`_MSC_VER` < 1920) |
|
||||
| 10.1 | Visual Studio 2019 (16.X) (`_MSC_VER` < 1930) |
|
||||
|
||||
```cmd
|
||||
cmd
|
||||
|
||||
:: [Optional] If you want to build with VS 2019 generator, please change the value in the next line to `Visual Studio 16 2019`.
|
||||
:: [Optional] If you want to build with the VS 2017 generator for old CUDA and PyTorch, please change the value in the next line to `Visual Studio 15 2017`.
|
||||
:: Note: This value is useless if Ninja is detected. However, you can force that by using `set USE_NINJA=OFF`.
|
||||
set CMAKE_GENERATOR=Visual Studio 15 2017
|
||||
set CMAKE_GENERATOR=Visual Studio 16 2019
|
||||
|
||||
:: Read the content in the previous section carefully before you proceed.
|
||||
:: [Optional] If you want to override the underlying toolset used by Ninja and Visual Studio with CUDA, please run the following script block.
|
||||
:: "Visual Studio 2017 Developer Command Prompt" will be run automatically.
|
||||
:: "Visual Studio 2019 Developer Command Prompt" will be run automatically.
|
||||
:: Make sure you have CMake >= 3.12 before you do this when you use the Visual Studio generator.
|
||||
set CMAKE_GENERATOR_TOOLSET_VERSION=14.11
|
||||
set CMAKE_GENERATOR_TOOLSET_VERSION=14.27
|
||||
set DISTUTILS_USE_SDK=1
|
||||
for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version [15^,16^) -products * -latest -property installationPath`) do call "%i\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=%CMAKE_GENERATOR_TOOLSET_VERSION%
|
||||
|
||||
:: [Optional] If you want to override the Cuda host compiler
|
||||
set CUDAHOSTCXX=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\cl.exe
|
||||
:: [Optional] If you want to override the CUDA host compiler
|
||||
set CUDAHOSTCXX=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\cl.exe
|
||||
|
||||
python setup.py install
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user