INSTALL.md 3.57 KB
Newer Older
facebook-github-bot's avatar
facebook-github-bot committed
1
2
3
4
5
6
7
# Installation


## Requirements

### Core library

8
The core library is written in PyTorch. Several components have underlying implementation in CUDA for improved performance. A subset of these components have CPU implementations in C++/Pytorch. It is advised to use PyTorch3D with GPU support in order to use all the features.
facebook-github-bot's avatar
facebook-github-bot committed
9

10
- Linux or macOS or Windows
facebook-github-bot's avatar
facebook-github-bot committed
11
12
13
14
15
16
17
18
19
- Python ≥ 3.6
- PyTorch 1.4
- torchvision that matches the PyTorch installation. You can install them together at pytorch.org to make sure of this.
- gcc & g++ ≥ 4.9
- CUDA 9.2 or 10.0 or 10.1
- [fvcore](https://github.com/facebookresearch/fvcore)

These can be installed by running:
```
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
20
conda create -n pytorch3d python=3.8
facebook-github-bot's avatar
facebook-github-bot committed
21
22
conda activate pytorch3d
conda install -c pytorch pytorch torchvision cudatoolkit=10.0
Haoqi Fan's avatar
Haoqi Fan committed
23
conda install -c conda-forge -c fvcore fvcore
facebook-github-bot's avatar
facebook-github-bot committed
24
25
26
27
```

### Tests/Linting and Demos

28
For developing on top of PyTorch3D or contributing, you will need to run the linter and tests. If you want to run any of the notebook tutorials as `docs/tutorials` you will also need matplotlib.
facebook-github-bot's avatar
facebook-github-bot committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
- scikit-image
- black
- isort
- flake8
- matplotlib
- tdqm
- jupyter
- imageio

These can be installed by running:
```
# Demos
conda install jupyter
pip install scikit-image matplotlib imageio

# Tests/Linting
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
45
pip install black isort flake8 flake8-bugbear flake8-comprehensions
facebook-github-bot's avatar
facebook-github-bot committed
46
47
```

48
## Installing prebuilt binaries for PyTorch3D
facebook-github-bot's avatar
facebook-github-bot committed
49
50
After installing the above dependencies, run one of the following commands:

51
### 1. Install with CUDA support from Anaconda Cloud, on Linux only
facebook-github-bot's avatar
facebook-github-bot committed
52
53
54

```
# Anaconda Cloud
Yun Chen's avatar
Yun Chen committed
55
conda install pytorch3d -c pytorch3d
facebook-github-bot's avatar
facebook-github-bot committed
56
57
```

Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
58
59
60
61
62
Or, to install a nightly (non-official, alpha) build:
```
# Anaconda Cloud
conda install pytorch3d -c pytorch3d-nightly
```
63
64
65
66
67
68
69
70
### 2. Install without CUDA support from PyPI, on Linux and Mac
```
pip install pytorch3d
```

## Building / installing from source.
CUDA support will be included if CUDA is enabled or if the environment variable
`FORCE_CUDA` is set to `1`.
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
71

72
### 1. Install from GitHub
facebook-github-bot's avatar
facebook-github-bot committed
73
74
75
76
```
pip install 'git+https://github.com/facebookresearch/pytorch3d.git'
```

77
78
79
80
81
82
**Install from Github on macOS:**
```
MACOSX_DEPLOYMENT_TARGET=10.14 CC=clang CXX=clang++ pip install 'git+https://github.com/facebookresearch/pytorch3d.git'
```

### 2. Install from a local clone
facebook-github-bot's avatar
facebook-github-bot committed
83
84
85
86
```
git clone https://github.com/facebookresearch/pytorch3d.git
cd pytorch3d && pip install -e .
```
87
To rebuild after installing from a local clone run, `rm -rf build/ **/*.so` then `pip install -e .`. You often need to rebuild pytorch3d after reinstalling PyTorch.
facebook-github-bot's avatar
facebook-github-bot committed
88
89
90

**Install from local clone on macOS:**
```
91
MACOSX_DEPLOYMENT_TARGET=10.14 CC=clang CXX=clang++ pip install -e .
facebook-github-bot's avatar
facebook-github-bot committed
92
```
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

**Install from local clone on Windows:**

If you are using pre-compiled pytorch 1.4 and torchvision 0.5, you should make the following changes to the pytorch source code to successfully compile with Visual Studio 2019 (MSVC 19.16.27034) and CUDA 10.1.

Change python/Lib/site-packages/torch/include/csrc/jit/script/module.h

L466, 476, 493, 506, 536
```
-static constexpr *
+static const *
```
Change python/Lib/site-packages/torch/include/csrc/jit/argument_spec.h

L190
```
-static constexpr size_t DEPTH_LIMIT = 128;
+static const size_t DEPTH_LIMIT = 128;
```

Change python/Lib/site-packages/torch/include/pybind11/cast.h

L1449
```
-explicit operator type&() { return *(this->value); }
+explicit operator type& () { return *((type*)(this->value)); }
```

After patching, you can go to "x64 Native Tools Command Prompt for VS 2019" to compile and install
```
cd pytorch3d
python3 setup.py install
```
After installing, verify whether all unit tests have passed
```
cd tests
python3 -m unittest discover -p *.py
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
130
```