mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Document faster builds for C++ changes (#102316)
Update `CONTRIBUTING.md` with tip on how to avoid rebuilding/copying libs every time one makes a small change to the native code. <!-- copilot:poem --> ### <samp>🤖 Generated by Copilot at f5e8394</samp> > _`setup.py` docs_ > _Link to source and build dirs_ > _Winter of testing_ Pull Request resolved: https://github.com/pytorch/pytorch/pull/102316 Approved by: https://github.com/kit1980, https://github.com/huydhn
This commit is contained in:
committed by
PyTorch MergeBot
parent
c05a317371
commit
efd774a295
@ -83,12 +83,22 @@ Follow the instructions for [installing PyTorch from source](https://github.com/
|
|||||||
|
|
||||||
* If you want to have no-op incremental rebuilds (which are fast), see [Make no-op build fast](#make-no-op-build-fast) below.
|
* If you want to have no-op incremental rebuilds (which are fast), see [Make no-op build fast](#make-no-op-build-fast) below.
|
||||||
|
|
||||||
* When installing with `python setup.py develop` (in contrast to `python setup.py install`) you will symlink
|
* When installing with `python setup.py develop` (in contrast to `python setup.py install`) Python runtime will use
|
||||||
the Python files from the current local source-tree into the Python install.
|
the current local source-tree when importing `torch` package. (This is done by creating [`.egg-link`](https://wiki.python.org/moin/PythonPackagingTerminology#egg-link) file in `site-packages` folder)
|
||||||
This way you do not need to repeatedly install after modifying Python files (`.py`).
|
This way you do not need to repeatedly install after modifying Python files (`.py`).
|
||||||
However, you would need to reinstall if you modify Python interface (`.pyi`, `.pyi.in`) or
|
However, you would need to reinstall if you modify Python interface (`.pyi`, `.pyi.in`) or
|
||||||
non-Python files (`.cpp`, `.cc`, `.cu`, `.h`, ...).
|
non-Python files (`.cpp`, `.cc`, `.cu`, `.h`, ...).
|
||||||
|
|
||||||
|
|
||||||
|
One way to avoid running `python setup.py develop` every time one makes a change to C++/CUDA/ObjectiveC files on Linux/Mac,
|
||||||
|
is to create a symbolic link from `build` folder to `torch/lib`, for example, by issuing following:
|
||||||
|
```bash
|
||||||
|
pushd torch/lib; sh -c "ln -sf ../../build/lib/libtorch_cpu.* ."; popd
|
||||||
|
```
|
||||||
|
Afterwards rebuilding a library (for example to rebuild `libtorch_cpu.so` issue `ninja torch_cpu` from `build` folder),
|
||||||
|
would be sufficient to make change visible in `torch` package.
|
||||||
|
|
||||||
|
|
||||||
To reinstall, first uninstall all existing PyTorch installs. You may need to run `pip
|
To reinstall, first uninstall all existing PyTorch installs. You may need to run `pip
|
||||||
uninstall torch` multiple times. You'll know `torch` is fully
|
uninstall torch` multiple times. You'll know `torch` is fully
|
||||||
uninstalled when you see `WARNING: Skipping torch as it is not
|
uninstalled when you see `WARNING: Skipping torch as it is not
|
||||||
|
Reference in New Issue
Block a user