mmdetection安装 CUDA11.0+pytorch1.7.1+mmcv-full

安装

  1. Create a conda virtual environment and activate it.

    conda create -n open-mmlab python=3.7 -y
    conda activate open-mmlab
    
  2. Install PyTorch and torchvision following the official instructions, e.g.,

    这里建议加上 -c 减少因安装源的问题导致的错误

    conda install pytorch cudatoolkit=11.0 torchvision -c pytorch
    
  3. Install mmcv-full, we recommend you to install the pre-build package as below.

    git clone https://github.com/open-mmlab/mmcv.git
    cd mmcv
    MMCV_CUDA_ARGS='-gencode=arch=compute_80,code=sm_80'  MMCV_WITH_OPS=1 pip install .
    cd ..  
    

    第三步和官方教程略有不同,为了解决算力的问题 for RTX30系列

  4. Clone the MMDetection repository.

    git clone https://github.com/open-mmlab/mmdetection.git
    cd mmdetection
    
  5. Install build requirements and then install MMDetection.

    pip install -r requirements/build.txt
    pip install -v -e .  # or "python setup.py develop"
    

验证代码: 如果跑通证明mmdet 安装成功

from mmdet.apis import init_detector, inference_detector

config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
# download the checkpoint from model zoo and put it in `checkpoints/`
# url: http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
# init a detector
model = init_detector(config_file, checkpoint_file, device=device)
# inference the demo image
inference_detector(model, 'demo/demo.jpg')

官方还提供了mmdet的docker版本,docker是非常好用的工具,建议使用docker进行配置 会减少大量的环境配置时间, 具体使用方法可以去百度上搜

	docker search mmdetection

你可能感兴趣的:(目标检测,python,docker,人工智能)