INSTALL.md 2.54 KB
Newer Older
Kai Chen's avatar
Kai Chen committed
1
2
3
4
## Installation

### Requirements

Kai Chen's avatar
Kai Chen committed
5
6
7
8
9
10
- Linux
- Python 3.5+ ([Say goodbye to Python2](https://python3statement.org/))
- PyTorch 1.0+ or PyTorch-nightly
- CUDA 9.0+
- NCCL 2+
- GCC 4.9+
Kai Chen's avatar
Kai Chen committed
11
- [mmcv](https://github.com/open-mmlab/mmcv)
Kai Chen's avatar
Kai Chen committed
12

Kai Chen's avatar
Kai Chen committed
13
14
15
16
17
18
19
We have tested the following versions of OS and softwares:

- OS: Ubuntu 16.04/18.04 and CentOS 7.2
- CUDA: 9.0/9.2/10.0
- NCCL: 2.1.15/2.2.13/2.3.7/2.4.2
- GCC: 4.9/5.3/5.4/7.3

Kai Chen's avatar
Kai Chen committed
20
21
### Install mmdetection

Kai Chen's avatar
Kai Chen committed
22
23
24
25
a. Create a conda virtual environment and activate it. Then install Cython.

```shell
conda create -n open-mmlab python=3.7 -y
O's avatar
O committed
26
conda activate open-mmlab
Kai Chen's avatar
Kai Chen committed
27
28
29

conda install cython
```
Kai Chen's avatar
Kai Chen committed
30

Kai Chen's avatar
Kai Chen committed
31
32
33
b. Install PyTorch stable or nightly and torchvision following the [official instructions](https://pytorch.org/).

c. Clone the mmdetection repository.
Kai Chen's avatar
Kai Chen committed
34
35
36

```shell
git clone https://github.com/open-mmlab/mmdetection.git
Kai Chen's avatar
Kai Chen committed
37
cd mmdetection
Kai Chen's avatar
Kai Chen committed
38
39
```

Kai Chen's avatar
Kai Chen committed
40
d. Compile cuda extensions.
Kai Chen's avatar
Kai Chen committed
41
42

```shell
Kai Chen's avatar
Kai Chen committed
43
./compile.sh
Kai Chen's avatar
Kai Chen committed
44
45
```

Kai Chen's avatar
Kai Chen committed
46
e. Install mmdetection (other dependencies will be installed automatically).
Kai Chen's avatar
Kai Chen committed
47
48

```shell
Kai Chen's avatar
Kai Chen committed
49
50
python setup.py develop
# or "pip install -e ."
Kai Chen's avatar
Kai Chen committed
51
52
```

Kai Chen's avatar
Kai Chen committed
53
54
55
56
57
58
Note:

1. It is recommended that you run the step e each time you pull some updates from github. If there are some updates of the C/CUDA codes, you also need to run step d.
The git commit id will be written to the version number with step e, e.g. 0.6.0+2e7045c. The version will also be saved in trained models.

2. Following the above instructions, mmdetection is installed on `dev` mode, any modifications to the code will take effect without installing it again.
Kai Chen's avatar
Kai Chen committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

### Prepare COCO dataset.

It is recommended to symlink the dataset root to `$MMDETECTION/data`.

```
mmdetection
├── mmdet
├── tools
├── configs
├── data
│   ├── coco
│   │   ├── annotations
│   │   ├── train2017
│   │   ├── val2017
│   │   ├── test2017
│   ├── VOCdevkit
│   │   ├── VOC2007
│   │   ├── VOC2012

```

### Scripts
Kai Chen's avatar
Kai Chen committed
82
[Here](https://gist.github.com/hellock/bf23cd7348c727d69d48682cb6909047) is
Kai Chen's avatar
Kai Chen committed
83
a script for setting up mmdetection with conda.
pangjm's avatar
pangjm committed
84
85

### Notice
pangjm's avatar
pangjm committed
86
87
88
89
You can run `python(3) setup.py develop` or `pip install -e .` to install mmdetection if you want to make modifications to it frequently.

If there are more than one mmdetection on your machine, and you want to use them alternatively.
Please insert the following code to the main file
pangjm's avatar
pangjm committed
90
```python
pangjm's avatar
pangjm committed
91
92
93
import os.path as osp
import sys
sys.path.insert(0, osp.join(osp.dirname(osp.abspath(__file__)), '../'))
pangjm's avatar
pangjm committed
94
```
pangjm's avatar
pangjm committed
95
or run the following command in the terminal of corresponding folder.
pangjm's avatar
pangjm committed
96
97
98
```shell
export PYTHONPATH=`pwd`:$PYTHONPATH
```