mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
fix requirements.txt installation failure issue on Windows (#134567)
Fixes #134564 Root cause: The `lintrunner` wheel released on [pypi.org](https://pypi.org/project/lintrunner/#files) only supports Windows 32bit and Linux 64bit. Since compilation of pytorch requires a 64bit env, on windows, the `lintrunner` has to be compiled from source distribution. `Rust` is its dependency for compilation, as indicated in the error message. Meanwhile, Visual Studio environment is needed for linking libraries..  Issue when performing `pip install lintrunner` without a Visual Studio environment activated is shown below. ```bash >python -m pip install lintrunner Collecting lintrunner Downloading lintrunner-0.12.5.tar.gz (62 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: lintrunner Building wheel for lintrunner (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for lintrunner (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [137 lines of output] Running `maturin pep517 build-wheel -i C:\Users\\miniforge3\envs\py310\python.exe --compatibility off` 📡 Using build options bindings from pyproject.toml Compiling proc-macro2 v1.0.79 Compiling unicode-ident v1.0.12 Compiling version_check v0.9.4 Compiling windows_x86_64_msvc v0.52.4 Compiling winapi v0.3.9 Compiling serde v1.0.197 Compiling autocfg v1.2.0 Compiling syn v1.0.109 Compiling lazy_static v1.4.0 Compiling libc v0.2.153 Compiling equivalent v1.0.1 Compiling hashbrown v0.14.3 Compiling memchr v2.7.2 Compiling yansi v1.0.1 Compiling unicode-width v0.1.11 Compiling regex-syntax v0.8.3 Compiling encode_unicode v0.3.6 Compiling cfg-if v1.0.0 Compiling winnow v0.6.5 Compiling cc v1.0.92 error: could not compile `windows_x86_64_msvc` (build script) due to 2 previous errors warning: build failed, waiting for other jobs to finish... error: could not compile `serde` (build script) due to 2 previous errors error: could not compile `proc-macro2` (build script) due to 2 previous errors error: could not compile `syn` (build script) due to 2 previous errors error: could not compile `libc` (build script) due to 2 previous errors error: could not compile `winapi` (build script) due to 2 previous errors 💥 maturin failed Caused by: Failed to build a native library through cargo Caused by: Cargo build finished with "exit code: 101": `cargo rustc --manifest-path Cargo.toml --message-format json --release --bins --` 📦 Including license file "LICENSE" 🔗 Found bin bindings error: linker `link.exe` not found | = note: program not found note: the msvc targets depend on the msvc linker but `link.exe` was not found note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option. note: VS Code is a different product, and is not sufficient. error: aborting due to 1 previous error error: linker `link.exe` not found | = note: program not found note: the msvc targets depend on the msvc linker but `link.exe` was not found note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option. note: VS Code is a different product, and is not sufficient. error: aborting due to 1 previous error error: linker `link.exe` not found | = note: program not found note: the msvc targets depend on the msvc linker but `link.exe` was not found note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option. note: VS Code is a different product, and is not sufficient. error: aborting due to 1 previous error error: linker `link.exe` not found | = note: program not found note: the msvc targets depend on the msvc linker but `link.exe` was not found note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option. note: VS Code is a different product, and is not sufficient. error: aborting due to 1 previous error error: linker `link.exe` not found | = note: program not found note: the msvc targets depend on the msvc linker but `link.exe` was not found note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option. note: VS Code is a different product, and is not sufficient. error: aborting due to 1 previous error error: linker `link.exe` not found | = note: program not found note: the msvc targets depend on the msvc linker but `link.exe` was not found note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option. note: VS Code is a different product, and is not sufficient. error: aborting due to 1 previous error Error: command ['maturin', 'pep517', 'build-wheel', '-i', 'C:\\Users\\\\miniforge3\\envs\\py310\\python.exe', '--compatibility', 'off'] returned non-zero exit status 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for lintrunner Failed to build lintrunner ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (lintrunner) ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/134567 Approved by: https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
b6d6aa49b8
commit
835e7bb077
59
README.md
59
README.md
@ -27,8 +27,8 @@ Our trunk health (Continuous Integration signals) can be found at [hud.pytorch.o
|
||||
- [NVIDIA CUDA Support](#nvidia-cuda-support)
|
||||
- [AMD ROCm Support](#amd-rocm-support)
|
||||
- [Intel GPU Support](#intel-gpu-support)
|
||||
- [Install Dependencies](#install-dependencies)
|
||||
- [Get the PyTorch Source](#get-the-pytorch-source)
|
||||
- [Install Dependencies](#install-dependencies)
|
||||
- [Install PyTorch](#install-pytorch)
|
||||
- [Adjust Build Options (Optional)](#adjust-build-options-optional)
|
||||
- [Docker Image](#docker-image)
|
||||
@ -161,9 +161,34 @@ They require JetPack 4.2 and above, and [@dusty-nv](https://github.com/dusty-nv)
|
||||
#### Prerequisites
|
||||
If you are installing from source, you will need:
|
||||
- Python 3.8 or later (for Linux, Python 3.8.1+ is needed)
|
||||
- A compiler that fully supports C++17, such as clang or gcc (gcc 9.4.0 or newer is required)
|
||||
- A compiler that fully supports C++17, such as clang or gcc (gcc 9.4.0 or newer is required, on Linux)
|
||||
- Visual Studio or Visual Studio Build Tool on Windows
|
||||
|
||||
We highly recommend installing an [Anaconda](https://www.anaconda.com/download) environment. You will get a high-quality BLAS library (MKL) and you get controlled dependency versions regardless of your Linux distro.
|
||||
\* PyTorch CI uses Visual C++ BuildTools, which come with Visual Studio Enterprise,
|
||||
Professional, or Community Editions. You can also install the build tools from
|
||||
https://visualstudio.microsoft.com/visual-cpp-build-tools/. The build tools *do not*
|
||||
come with Visual Studio Code by default.
|
||||
|
||||
\* We highly recommend installing an [Anaconda](https://www.anaconda.com/download) environment. You will get a high-quality BLAS library (MKL) and you get controlled dependency versions regardless of your Linux distro.
|
||||
|
||||
An example of environment setup is shown below:
|
||||
|
||||
* Linux:
|
||||
|
||||
```bash
|
||||
$ source <CONDA_INSTALL_DIR>/bin/activate
|
||||
$ conda create -y -n <CONDA_NAME>
|
||||
$ conda activate <CONDA_NAME>
|
||||
```
|
||||
|
||||
* Windows:
|
||||
|
||||
```bash
|
||||
$ source <CONDA_INSTALL_DIR>\Scripts\activate.bat
|
||||
$ conda create -y -n <CONDA_NAME>
|
||||
$ conda activate <CONDA_NAME>
|
||||
$ call "C:\Program Files\Microsoft Visual Studio\<VERSION>\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
|
||||
```
|
||||
|
||||
##### NVIDIA CUDA Support
|
||||
If you want to compile with CUDA support, [select a supported version of CUDA from our support matrix](https://pytorch.org/get-started/locally/), then install the following:
|
||||
@ -194,12 +219,23 @@ If you want to compile with Intel GPU support, follow these
|
||||
If you want to disable Intel GPU support, export the environment variable `USE_XPU=0`.
|
||||
Other potentially useful environment variables may be found in `setup.py`.
|
||||
|
||||
#### Get the PyTorch Source
|
||||
```bash
|
||||
git clone --recursive https://github.com/pytorch/pytorch
|
||||
cd pytorch
|
||||
# if you are updating an existing checkout
|
||||
git submodule sync
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
#### Install Dependencies
|
||||
|
||||
**Common**
|
||||
|
||||
```bash
|
||||
conda install cmake ninja
|
||||
# Run this command on native Windows
|
||||
conda install rust
|
||||
# Run this command from the PyTorch directory after cloning the source code using the “Get the PyTorch Source“ section below
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
@ -235,15 +271,6 @@ pip install mkl-static mkl-include
|
||||
conda install -c conda-forge libuv=1.39
|
||||
```
|
||||
|
||||
#### Get the PyTorch Source
|
||||
```bash
|
||||
git clone --recursive https://github.com/pytorch/pytorch
|
||||
cd pytorch
|
||||
# if you are updating an existing checkout
|
||||
git submodule sync
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
#### Install PyTorch
|
||||
**On Linux**
|
||||
|
||||
@ -284,13 +311,6 @@ python3 setup.py develop
|
||||
|
||||
**On Windows**
|
||||
|
||||
Choose Correct Visual Studio Version.
|
||||
|
||||
PyTorch CI uses Visual C++ BuildTools, which come with Visual Studio Enterprise,
|
||||
Professional, or Community Editions. You can also install the build tools from
|
||||
https://visualstudio.microsoft.com/visual-cpp-build-tools/. The build tools *do not*
|
||||
come with Visual Studio Code by default.
|
||||
|
||||
If you want to build legacy python code, please refer to [Building on legacy code and CUDA](https://github.com/pytorch/pytorch/blob/main/CONTRIBUTING.md#building-on-legacy-code-and-cuda)
|
||||
|
||||
**CPU-only builds**
|
||||
@ -298,7 +318,6 @@ If you want to build legacy python code, please refer to [Building on legacy cod
|
||||
In this mode PyTorch computations will run on your CPU, not your GPU
|
||||
|
||||
```cmd
|
||||
conda activate
|
||||
python setup.py develop
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user