ubuntu18.04下安装mmdetection 及问题解决

ubuntu18.04下安装mmdetection 及问题解决

官方地址

mmdetection集成了多种目标检测算法,详见官方github地址,官方文档中也有安装说明,但是会遇到一些问题,博主将自己的安装过程和遇到的问题列在下面,仅供参考。

环境需求

Requirements

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
GCC 4.9 or higher
mmcv

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

cuda和anaconda的安装不在本文描述范围内。基础环境配置可参见Ubuntu 18.04: Install TensorFlow and Keras for Deep Learning

安装过程及问题

  1. 创建并激活conda环境
conda create -n mmdetection python=3.7
conda activate mmdetection
conda install cython
  1. 安装pytorch及torchvision
    官方提供的建议是
conda install pytorch torchvision -c pytorch

但是这里有个坑,就是下载速度过慢,博主为了这个问题搞破了脑袋,试过国内镜像,科学上网,离线安装。还是国内镜像最方便,但是需要注意的是,添加国内镜像后,需要将代码改为如下所示(cudatoolkit根据cuda版本选择):

conda install pytorch torchvision cudatoolkit=9.0

不然pytorch / torchvision下载源依然为 pytorch 官网

  1. 安装mmcv
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
pip install .
  1. 安装mmdetection
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
python setup.py develop

在执行python setup.py develop遇见gcc版本造成的错误。使用gcc7.4.0, gcc6.5.0均不能正常执行,后改为gcc5.5.0解决该问题,原因不详,大家可以直接使用官方测试过的gcc版本:4.9/5.3/5.4/7.3。
gcc安装及版本转化如下(以gcc6转gcc5为例):

sudo apt-get install gcc-5 g++-5
cd /usr/bin
sudo rm gcc6 g++6
sudo ln gcc-5 gcc
sudo ln g++-5 g++

可以通过以下代码查看gcc/g++版本:

gcc --version
g++ --version

参考

  1. https://blog.csdn.net/watermelon1123/article/details/88122020
  • 1
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值