ubuntu16.04安装mmdetection

拜读了B站的一位大神的视频,附上安装mmdetection视频,,若侵权会马上删除
mmdetection与mmcv版本对应关系链接

首先声明本人是ubuntu16.04 cuda10.1

第一步:需要创建虚拟环境open-mmlab,为啥创建不多说,不懂的先去学习一下,比较简单,就是创建的环境能保持独立,不会和其他环境混。
在终端执行:conda create -n open-mmlab
安装python版本:conda create -n python=3.7 -y
或者以上两步也可以总结成一步的命令:conda create -n open-mmlab python=3.7

第二步:激活虚拟环境,在终端执行:conda activate open-mmlab

第三步:装pytorch,建议使用conda安装,查看自己电脑cuda的版本,pytorch官网地址pytorch官当地址链接找对应的pytorch版本。我的电脑是cuda10.1
我的安装命令是:

conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.1 -c pytorch

后面换成了1.5版本

conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=10.1 -c pytorch

第四步:安装mmcv,这一步很多人都会安装错误,直接conda install…这样及其不可取,因为这样很容易安装成最新版本,而导致跟自己电脑环境不匹配,所以推荐按照下列方法安装,后面链接是安装mmcv的索引,建议查看安装mmcv链接要求
之前我看到这里面有句:
ubuntu16.04安装mmdetection_第1张图片
Note: The pre-built packages provided above do not include all versions of mmcv-full, you can click on the corresponding links to see the supported versions. For example, you can click cu102-torch1.8.0 and you can see that cu102-torch1.8.0 only provides 1.3.0 and above versions of mmcv-full. In addition, We no longer provide mmcv-full pre-built packages compiled with PyTorch 1.3 & 1.4 since v1.3.17. You can find previous versions that compiled with PyTorch 1.3 & 1.4 here. The compatibility is still ensured in our CI, but we will discard the support of PyTorch 1.3 & 1.4 next year.
因此我之前一直安装pytorch1.4版本不成功,这句提示以后我换成了pytorch1.5

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{你的cuda版本}/{你的torch版本}/index.html

具体格式可以参照下面的版本,主要还是看你电脑的cuda和pytorch版本

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.4.0/index.html

第五步:安装mmdetection.

git clone https://github.com/open-mmlab/mmdetection.git或者git clone git://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e   或者python setup.py develop

测试环境是否可用

python tools/train.py -h

出现一下界面
ubuntu16.04安装mmdetection_第2张图片
在文件夹:./configs/gfl/gfl_r50_fpn_mstrain_2x_coco.py

中修改最大的训练epochs数
runner = dict(type=‘EpochBasedRunner’, max_epochs=100)
在这句代码中修改max_epochs中的数字大小,就能控制训练的epochs
最后代码跑起来了:
ubuntu16.04安装mmdetection_第3张图片

祝大家顺利。

你可能感兴趣的:(深度学习,python,cuda,pytorch,深度学习,人工智能)