Detectron 是目标检测平台,包含了大量业内最具代表性的目标检测、图像分割、关键点检测算法,该框架主要基于 python 和 caffe2 实现。 官方只给出了基于linux和mac os平台的配置操作。在mac上按照官方教程配置环境很顺畅,接下来和师兄在Windows10上部署了两天的环境,采坑无数,最终安装成功,记录一下安装过程,有用的话路过的伙伴点个赞吧。
本方法创建了一个虚拟环境,在该虚拟环境下的配置如下:
- cuda 10.1(cudnn 7.6.2)
- pytorch 1.5.0
- python 3.7.0
- Visual studio 17
1.首先安装Anaconda
这里贴一个安装教程https://blog.csdn.net/ITLearnHall/article/details/81708148
另外,其他版本的Anaconda可以在这里获得 https://repo.anaconda.com/archive/
因为本人安装过程比较曲折,所以这里贴一个解决贴,以备其他同学遇到相同的情况
“安装Anaconda之后在电脑终端输入conda list 显示conda不是内部或外部命令之解决办法”
2.使用conda创建虚拟环境
conda create -n envDetectron2 python=3.7.0
因为本人安装过程比较曲折,所以这里贴一个解决贴,以备其他同学遇到相同的情况
简单解决[CondaHTTPError: HTTP 000 CONNECTION FAILED for url]
3.进入创建的虚拟环境
activate envDetectron2
(接下来步骤都在虚拟环境中进行安装操作)
4.安装cudatoolkit
(这里有个潜规则,先装cuda再装torch)
conda install cudatoolkit = 10.1
5.安装pytorch和torchvision
每次安装动态加清华源 :
pip3 install 安装包的名字 -i https://pypi.tuna.tsinghua.edu.cn/simple
设置为默认(一劳永逸):
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip install torch1.5.0+cu101 torchvision0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
使用国内镜像安装
pip install torch1.5.0+cu101 torchvision0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple
6.安装fvcore
这里官网给出了几种安装方式,选择一种方式即可
参考如下:https://github.com/facebookresearch/fvcore
7.安装cython
pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple
8.安装pycocotools
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
9.VS版本问题
起初安装是VS 2019 但是提示如下错误
“error: – unsupported Microsoft Visual Studio version!Only the version between 2013 and 2017(inclusive) are supported! ”
所以就将VS2019卸载,安装了VS 2017
10.接下来
git clone git@github.com:facebookresearch/detectron2.git
然后进行编译
cd detectron2
python setup.py build develop
编译时的小插曲:
编译的时候,我们遇到了“command ‘…/…/bin/nvcc.exe’ failed with exit status 1”,修改策略
“…/…/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cuda.cu” 文件中#include “…” 路径错误 ,然后编译成功。
11.运行demo.py 成功
我想吃KFC,嘻嘻嘻。