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

本文介绍了如何在CUDA11.0和PyTorch1.7.1环境中安装MMDetection。创建conda虚拟环境并激活,遵循官方PyTorch和torchvision的安装指南。推荐使用预建的mmcv-full包,针对RTX30系列解决算力问题。完成安装后,通过运行代码验证MMDetection是否安装成功。此外,文章提及官方提供的MMDetection Docker版本,建议使用Docker简化环境配置。
摘要由CSDN通过智能技术生成

安装

  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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值