windows install mmdetection

The official website of mmdetection: https://github.com/open-mmlab/mmdetection/blob/master/docs/get_started.md The
official website gave the installation steps of linux, I tried to use ubuntu16.04 to follow this tutorial and the installation was very smooth, because The general steps are not much different from windows, so I still write the installation steps on linux by the way, which is somewhat of a check:

conda create -n open-mmlab python=3.7 -y
conda activate open-mmlab

conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.2 -c pytorch -y

# install the latest mmcv,这里可能会找不到,那就到这条命令后面哪个网址去找到下载下来再安装
pip install mmcv-full==latest+torch1.6.0+cu102 -f https://download.openmmlab.com/mmcv/dist/index.html

# install mmdetection
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e .

The official website also said that the current installation of windows is experimental and not fully supported, so it is a bit troublesome compared to linux (it seems that it is not very troublesome, but I have been doing it for a long time).

The overall steps of windows installation:

conda create -n mmd2 python=3.7
conda activate mmd2
#pytorch=1.6 torchvision==0.7.0可以先下载再安装,cudatoolkit=10.2还是就这种安装方式
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.2

pip install mmcv-full==1.1.5+torch1.6.0+cu102 -f https://download.openmmlab.com/mmcv/dist/index.html

# install mmdetection
git clone https://github.com/open-mmlab/mmdetection.git
#进入到mmdetection2.6版本
cd mmdetection
pip install -r requirements.txt
python setup.py develop

Pay attention to two points above:

pytorch part

One thing is that the installation of pytorch may be interrupted due to network problems. The method I used here is to download the offline installation package first, and then install it.

For the download method
, please refer to my original blog: https://blog.csdn.net/yanghao201607030101/article/details/109904368, that is, download all the required installation packages and install them in this way.

pip install --target=C:\ProgramData\Anaconda3\Lib\site-packages pyXXX.whl

For example, if you want to install pytorch 1.6.0, go to the website mentioned above to download pytorch1.6.0, torchvision0.7.0 cdatoolkit=10.2 These three are down and then installed by the above method.
Insert picture description here
Then here cudatoolkit=10.2 can not be found in the above URL, so I installed it in conda mode. If you use conda mode to install, you don’t need -c pytorch after the mirror source. If you add it, the mirror source is not applicable. And even if I used the mirror source, I was interrupted because of the network speed. So like setting the waiting time for pip download, set the waiting time for conda download here to make it patient. Don't give up because the network is temporarily bad.

conda config --set remote_read_timeout_secs 100.0

mmcv-full part

The second point is mmcv-full. You need to go to the following website to check which versions of windows are currently supported.

https://download.openmmlab.com/mmcv/dist/index.html
Insert picture description here

The highest version that supports windows is 1.1.5, so the highest version can only be installed, and then download it and install it again.

Verify that the installation is successful

If the installation is successful, the following code can be successfully executed in the python environment of this mmd2. (The root directory is mmdetection)

from mmdet.apis import init_detector, inference_detector
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
device = 'cuda:0'
# init a detector
model = init_detector(config_file, device=device)
# inference the demo image
inference_detector(model, 'demo/demo.jpg')

After the installation is complete, opencv must be installed. Specify this version to install, otherwise an error will be reported.
pip install opencv-python==4.2.0.34

tips

Finally, after the installation was complete, the conda list did not show mmdet, but I felt that I was not wrong, so I tried the method given by the official website to test whether the installation was successful, and then it was successfully executed.
If there is no success, there is a high probability that it is a version problem, or pip downloads the package timeout. For version issues, take a closer look at the version supported by mmcv on which website of mmdetection, and then download the corresponding pytorch version against it.
When pip installs requirements, the timeout can be set to wait for 100 and add a Douban source, for example:

pip --default-timeout=100 install torch=1.7.0 torchvision=0.8.1 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.douban.com/simple

The installation environment is a test of people's patience. Don't just give up. Go to Baidu b site for two days if it doesn't work, or find the issue on github, the error description in the command line, and it will always be solved in the end.

Guess you like

Origin blog.csdn.net/yanghao201607030101/article/details/110532617