Skip to content

Commit 6a7c564

Browse files
ezyangsoumith
authored andcommitted
How to manage multiple build trees of PyTorch. (pytorch#1654)
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
1 parent 46ee1e4 commit 6a7c564

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

CONTRIBUTING.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ https://github.com/pytorch/pytorch#from-source
4444

4545
The change you have to make is to replace
4646

47-
`python setup.py install`
47+
```
48+
python setup.py install
49+
```
4850

4951
with
5052

@@ -61,11 +63,11 @@ Hence, if you modify a python file, you do not need to reinstall pytorch again a
6163

6264
For example:
6365
- Install local pytorch in `build develop` mode
64-
- modify your python file torch/__init__.py (for example)
66+
- modify your python file `torch/__init__.py` (for example)
6567
- test functionality
66-
- modify your python file torch/__init__.py
68+
- modify your python file `torch/__init__.py`
6769
- test functionality
68-
- modify your python file torch/__init__.py
70+
- modify your python file `torch/__init__.py`
6971
- test functionality
7072

7173
You do not need to repeatedly install after modifying python files.
@@ -80,6 +82,25 @@ We recommend removing the `build` directory before rebuilding because
8082
setup.py's recompilation checking is not great, and it will often fail
8183
to rebuild C code after you modify code in a `generic` directory.
8284

85+
#### Managing multiple build trees
86+
87+
One downside to using `python setup.py develop` is that your development
88+
version of pytorch will be installed globally on your account (e.g., if
89+
you run `import torch` anywhere else, the development version will be
90+
used.
91+
92+
If you want to manage multiple builds of PyTorch, you can make use of
93+
[conda environments](https://conda.io/docs/using/envs.html) to maintain
94+
separate Python package environments, each of which can be tied to a
95+
specific build of PyTorch. To set one up:
96+
97+
```
98+
conda create -n pytorch-myfeature
99+
source activate pytorch-myfeature
100+
# if you run python now, torch will NOT be installed
101+
python setup.py build develop
102+
```
103+
83104
#### C++ Development tips
84105

85106
When you are developing on the C++ side of things, the environment variables `DEBUG` and `NO_CUDA` are helpful.

0 commit comments

Comments
 (0)