INSTALL.md 3.65 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
- Linux (Windows is not officially supported)
- Python 3.5+ (Python 2 is not supported)
- PyTorch 1.1 or higher
- CUDA 9.0 or higher
- NCCL 2
10
- GCC(G++) 4.9 or higher
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
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
18
- GCC(G++): 4.9/5.3/5.4/7.3
Kai Chen's avatar
Kai Chen committed
19

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

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

```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
```
Kai Chen's avatar
Kai Chen committed
28

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

```shell
conda install pytorch torchvision -c pytorch
```
Kai Chen's avatar
Kai Chen committed
34
35

c. Clone the mmdetection repository.
Kai Chen's avatar
Kai Chen committed
36
37
38

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

42
d. Install mmdetection (other dependencies will be installed automatically).
Kai Chen's avatar
Kai Chen committed
43
44

```shell
Kai Chen's avatar
Kai Chen committed
45
python setup.py develop
46
# or "pip install -v -e ."
Kai Chen's avatar
Kai Chen committed
47
48
```

Kai Chen's avatar
Kai Chen committed
49
50
Note:

Kai Chen's avatar
Kai Chen committed
51
52
1. The git commit id will be written to the version number with step d, e.g. 0.6.0+2e7045c. The version will also be saved in trained models.
It is recommended that you run step d each time you pull some updates from github. If C/CUDA codes are modified, then this step is compulsory.
Kai Chen's avatar
Kai Chen committed
53

Kai Chen's avatar
Kai Chen committed
54
2. Following the above instructions, mmdetection is installed on `dev` mode, any local modifications made to the code will take effect without the need to reinstall it (unless you submit some commits and want to update the version number).
Kai Chen's avatar
Kai Chen committed
55

Kai Chen's avatar
Kai Chen committed
56
57
### Another option: Docker Image

58
We provide a [Dockerfile](../docker/Dockerfile) to build an image.
Kai Chen's avatar
Kai Chen committed
59
60
61
62
63
64
65

```shell
# build an image with PyTorch 1.1, CUDA 10.0 and CUDNN 7.5
docker build -t mmdetection docker/
```

### Prepare datasets
Kai Chen's avatar
Kai Chen committed
66
67

It is recommended to symlink the dataset root to `$MMDETECTION/data`.
Kai Chen's avatar
Kai Chen committed
68
If your folder structure is different, you may need to change the corresponding paths in config files.
Kai Chen's avatar
Kai Chen committed
69
70
71
72
73
74
75
76
77
78
79
80

```
mmdetection
├── mmdet
├── tools
├── configs
├── data
│   ├── coco
│   │   ├── annotations
│   │   ├── train2017
│   │   ├── val2017
│   │   ├── test2017
81
82
83
84
│   ├── cityscapes
│   │   ├── annotations
│   │   ├── train
│   │   ├── val
Kai Chen's avatar
Kai Chen committed
85
86
87
88
│   ├── VOCdevkit
│   │   ├── VOC2007
│   │   ├── VOC2012

89
90
91
92
93
94
95
```
The cityscapes annotations have to be converted into the coco format using the [cityscapesScripts](https://github.com/mcordts/cityscapesScripts) toolbox.
We plan to provide an easy to use conversion script. For the moment we recommend following the instructions provided in the 
[maskrcnn-benchmark](https://github.com/facebookresearch/maskrcnn-benchmark/tree/master/maskrcnn_benchmark/data) toolbox. When using this script all images have to be moved into the same folder. On linux systems this can e.g. be done for the train images with:
```shell
cd data/cityscapes/
mv train/*/* train/
Kai Chen's avatar
Kai Chen committed
96
97
98
```

### Scripts
Kai Chen's avatar
Kai Chen committed
99

Kai Chen's avatar
Kai Chen committed
100
[Here](https://gist.github.com/hellock/bf23cd7348c727d69d48682cb6909047) is
Kai Chen's avatar
Kai Chen committed
101
a script for setting up mmdetection with conda.
pangjm's avatar
pangjm committed
102

Kai Chen's avatar
Kai Chen committed
103
104
105
### Multiple versions

If there are more than one mmdetection on your machine, and you want to use them alternatively, the recommended way is to create multiple conda environments and use different environments for different versions.
pangjm's avatar
pangjm committed
106

Kai Chen's avatar
Kai Chen committed
107
Another way is to insert the following code to the main scripts (`train.py`, `test.py` or any other scripts you run)
pangjm's avatar
pangjm committed
108
```python
pangjm's avatar
pangjm committed
109
110
111
import os.path as osp
import sys
sys.path.insert(0, osp.join(osp.dirname(osp.abspath(__file__)), '../'))
pangjm's avatar
pangjm committed
112
```
pangjm's avatar
pangjm committed
113
or run the following command in the terminal of corresponding folder.
pangjm's avatar
pangjm committed
114
115
116
```shell
export PYTHONPATH=`pwd`:$PYTHONPATH
```