mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Add instruction on how to handle the potential linker error on Linux (#47593)
Summary: The original issue is https://github.com/pytorch/pytorch/issues/16683, which contains a https://github.com/pytorch/pytorch/issues/16683#issuecomment-459982988 that suggests manually un-shadowing the `ld`. A better approach can be found at https://github.com/ContinuumIO/anaconda-issues/issues/11152#issuecomment-573120962, which suggests that using a newer version can effectively fix this. It took me quite some time to realize that this is in fact an issue caused by Anaconda. I think we should add it in README. Pull Request resolved: https://github.com/pytorch/pytorch/pull/47593 Reviewed By: ailzhang Differential Revision: D24866092 Pulled By: heitorschueroff fbshipit-source-id: c1f51864d23fd6f4f63a117496d8619053e35196
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7864ae9f98
commit
fcd44ce698
12
README.md
12
README.md
@ -149,7 +149,7 @@ They require JetPack 4.2 and above, and [@dusty-nv](https://github.com/dusty-nv)
|
||||
|
||||
### From Source
|
||||
|
||||
If you are installing from source, you will need Python 3.6 or later and a C++14 compiler. Also, we highly recommend installing an [Anaconda](https://www.anaconda.com/distribution/#download-section) environment.
|
||||
If you are installing from source, you will need Python 3.6.2 or later and a C++14 compiler. Also, we highly recommend installing an [Anaconda](https://www.anaconda.com/distribution/#download-section) environment.
|
||||
You will get a high-quality BLAS library (MKL) and you get controlled dependency versions regardless of your Linux distro.
|
||||
|
||||
Once you have [Anaconda](https://www.anaconda.com/distribution/#download-section) installed, here are the instructions.
|
||||
@ -207,6 +207,16 @@ export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
|
||||
python setup.py install
|
||||
```
|
||||
|
||||
Note that if you are using [Anaconda](https://www.anaconda.com/distribution/#download-section), you may experience an error caused by the linker:
|
||||
|
||||
```plaintext
|
||||
build/temp.linux-x86_64-3.7/torch/csrc/stub.o: file not recognized: file format not recognized
|
||||
collect2: error: ld returned 1 exit status
|
||||
error: command 'g++' failed with exit status 1
|
||||
```
|
||||
|
||||
This is caused by `ld` from Conda environment shadowing the system `ld`. You should use a newer version of Python that fixes this issue. The recommended Python version is 3.6.10+, 3.7.6+ and 3.8.1+.
|
||||
|
||||
On macOS
|
||||
```bash
|
||||
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
|
||||
|
Reference in New Issue
Block a user