WIN10搭建detectron2环境

显卡:NVIDIA GEFORCE RTX 2060
python版本:3.7
CUDA: 11.0
PyTorch: 1.7.0+cu110
VS:Community 2017

1. 环境和包

  1. PyTorch: 偷懒直接clone另一个环境mmdet
conda create -n detectron2 --clone mmdet

conda list显示torch已经准备好了:
在这里插入图片描述

  1. 很多包: pip install cython opencv-python pillow matplotlib termcolor cloudpickle tabulate tensorboard termcolor tqdm yacs mock fvcore pydot wheel future

  2. pycocotools: pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI

2. 修改部分代码

  1. …\Anaconda3\envs\detectron2\Lib\site-packages\torch\include\torch\csrc\jit\runtime\下的argument_spec.h文件
    第160行的static constexpr size_t ARG_SPEC_DEPTH_LIMIT = 128改为 static const size_t ARG_SPEC_DEPTH_LIMIT = 128
  2. …\Anaconda3\envs\detectron2\Lib\site-packages\torch\include\pybind11\下的cast.h文件
    第1449行的explicit operator type&() { return *(this->value); } 改为explicit operator type&() { return ((type)this->value); }

3. build

python setup.py build develop

等待一会,Build完成:

...
Finished processing dependencies for detectron2==0.2

conda list显示detectron2:
在这里插入图片描述

TIps:

  1. 如果你安装了多版本的VS,比如VS2015/2017/2019,想要用对应版本的VS时(以VS community 2017为例),需要运行call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"(确认一下自己的路径)和set DISTUTILS_USE_SDK=1
  2. 如果你的CUDA及PyTorch版本过高这一步可能会报错,我当时没有保存。大概需要改动的就是修改对应文件的函数名(ceil改为ceilf; floor改为floorf; round改为roundf)看具体的报错。

References

Detectron2的Github链接
【扫盲】Solov2训练(detectron2版本)

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值