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

### Requirements

Kai Chen's avatar
Kai Chen committed
5
- Linux (Windows is not officially supported)
Kai Chen's avatar
Kai Chen committed
6
- Python 3.5+
Kai Chen's avatar
Kai Chen committed
7
8
9
- PyTorch 1.1 or higher
- CUDA 9.0 or higher
- NCCL 2
Kai Chen's avatar
Kai Chen committed
10
- GCC 4.9 or higher
taokong's avatar
taokong committed
11
- [mmcv 0.2.16](https://github.com/open-mmlab/mmcv/tree/v0.2.16)
Kai Chen's avatar
Kai Chen committed
12

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

- OS: Ubuntu 16.04/18.04 and CentOS 7.2
Kai Chen's avatar
Kai Chen committed
16
- CUDA: 9.0/9.2/10.0/10.1
Kai Chen's avatar
Kai Chen committed
17
- 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

WXinlong's avatar
WXinlong committed
20
### Install SOLO
Kai Chen's avatar
Kai Chen committed
21

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

```shell
WXinlong's avatar
WXinlong committed
25
26
conda create -n solo python=3.7 -y
conda activate solo
Kai Chen's avatar
Kai Chen committed
27
```
Kai Chen's avatar
Kai Chen committed
28

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

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

WXinlong's avatar
WXinlong committed
35
c. Clone the SOLO repository.
Kai Chen's avatar
Kai Chen committed
36
37

```shell
Tao Kong's avatar
Tao Kong committed
38
git clone https://github.com/WXinlong/SOLO.git
WXinlong's avatar
WXinlong committed
39
cd SOLO
Kai Chen's avatar
Kai Chen committed
40
41
```

WXinlong's avatar
WXinlong committed
42
d. Install build requirements and then install SOLO.
43
(We install pycocotools via the github repo instead of pypi because the pypi version is old and not compatible with the latest numpy.)
Kai Chen's avatar
Kai Chen committed
44
45

```shell
46
pip install -r requirements/build.txt
47
pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI"
48
pip install -v -e .  # or "python setup.py develop"
Kai Chen's avatar
Kai Chen committed
49
50
```

Kai Chen's avatar
Kai Chen committed
51
52
Note:

Kai Chen's avatar
Kai Chen committed
53
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.
Kai Chen's avatar
Kai Chen committed
54
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
55

WXinlong's avatar
WXinlong committed
56
2. Following the above instructions, SOLO 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
57

Kai Chen's avatar
Kai Chen committed
58
59
60
3. If you would like to use `opencv-python-headless` instead of `opencv-python`,
you can install it before installing MMCV.

61
62
4. Some dependencies are optional. Simply running `pip install -v -e .` will only install the minimum runtime requirements. To use optional dependencies like `albumentations` and `imagecorruptions` either install them manually with `pip install -r requirements/optional.txt` or specify desired extras when calling `pip` (e.g. `pip install -v -e .[optional]`). Valid keys for the extras field are: `all`, `tests`, `build`, and `optional`.

Kai Chen's avatar
Kai Chen committed
63
64
### Another option: Docker Image

WXinlong's avatar
WXinlong committed
65
We provide a [Dockerfile](https://github.com/WXinlong/SOLO/blob/master/docker/Dockerfile) to build an image.
Kai Chen's avatar
Kai Chen committed
66
67
68

```shell
# build an image with PyTorch 1.1, CUDA 10.0 and CUDNN 7.5
WXinlong's avatar
WXinlong committed
69
docker build -t SOLO docker/
Kai Chen's avatar
Kai Chen committed
70
71
72
```

### Prepare datasets
Kai Chen's avatar
Kai Chen committed
73

WXinlong's avatar
WXinlong committed
74
It is recommended to symlink the dataset root to `$SOLO/data`.
Kai Chen's avatar
Kai Chen committed
75
If your folder structure is different, you may need to change the corresponding paths in config files.
Kai Chen's avatar
Kai Chen committed
76
77

```
WXinlong's avatar
WXinlong committed
78
SOLO
Kai Chen's avatar
Kai Chen committed
79
80
81
82
83
84
85
86
87
├── mmdet
├── tools
├── configs
├── data
│   ├── coco
│   │   ├── annotations
│   │   ├── train2017
│   │   ├── val2017
│   │   ├── test2017
88
89
90
91
│   ├── cityscapes
│   │   ├── annotations
│   │   ├── train
│   │   ├── val
Kai Chen's avatar
Kai Chen committed
92
93
94
95
│   ├── VOCdevkit
│   │   ├── VOC2007
│   │   ├── VOC2012

96
97
```
The cityscapes annotations have to be converted into the coco format using the [cityscapesScripts](https://github.com/mcordts/cityscapesScripts) toolbox.
Kai Chen's avatar
Kai Chen committed
98
We plan to provide an easy to use conversion script. For the moment we recommend following the instructions provided in the
99
100
101
102
[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
103
104
```

Kai Chen's avatar
Kai Chen committed
105
### A from-scratch setup script
Kai Chen's avatar
Kai Chen committed
106

WXinlong's avatar
WXinlong committed
107
Here is a full script for setting up SOLO with conda and link the dataset path (supposing that your COCO dataset path is $COCO_ROOT).
pangjm's avatar
pangjm committed
108

Kai Chen's avatar
Kai Chen committed
109
```shell
WXinlong's avatar
WXinlong committed
110
111
conda create -n solo python=3.7 -y
conda activate solo
Kai Chen's avatar
Kai Chen committed
112
113
114

conda install -c pytorch pytorch torchvision -y
conda install cython -y
WXinlong's avatar
WXinlong committed
115
116
git clone https://github.com/WXinlong/SOLO.git
cd SOLO
117
118
pip install -r requirements/build.txt
pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI"
Kai Chen's avatar
Kai Chen committed
119
120
121
122
123
124
125
pip install -v -e .

mkdir data
ln -s $COCO_ROOT data
```

### Using multiple MMDetection versions
Kai Chen's avatar
Kai Chen committed
126
127

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
128

Kai Chen's avatar
Kai Chen committed
129
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
130
```python
pangjm's avatar
pangjm committed
131
132
133
import os.path as osp
import sys
sys.path.insert(0, osp.join(osp.dirname(osp.abspath(__file__)), '../'))
pangjm's avatar
pangjm committed
134
```
Kai Chen's avatar
Kai Chen committed
135
136

Or run the following command in the terminal of corresponding folder to temporally use the current one.
pangjm's avatar
pangjm committed
137
138
139
```shell
export PYTHONPATH=`pwd`:$PYTHONPATH
```