环境
-
window10 + 2080Ti
-
cuda 11.1
-
pytorch 1.8
-
python3.6
-
VS2019
-
Detectron2 0.4
安装步骤
- 使用anconda 创建新的虚拟环境 , python 3.6
- 安装 numpy , opencv-python ,matplotlib..
- 安装pytorch
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio===0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
和cuda版本对应,比如我安装的是 cuda11.1 + pytorch1.8
-
验证 pytorch
python import torch torch.cuda.is_available() exit()
返回True,代表安装成功
-
安装 cocoapi 地址:https://github.com/philferriere/cocoapi (因为cocoapi官方暂不支持Windows)
-
pip install -e. (注意后面带个.)
-
-
安装 fvcore 地址: https://github.com/facebookresearch/fvcore
-
python setup.py build --force develop
-
-
安装 detectron2
-
python setup.py build --force develop
-
-
如果编译成功,输入conda list ,则会出现 detectron2
验证
- 目标检测
python demo/demo.py --config-file configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml --input image/test.jpg --output outputs/ --opts MODEL.WEIGHTS 'model/model_final_b275ba.pkl'
- 实例分隔
python demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input image/test.jpg --opts MODEL.WEIGHTS 'model/model_final_f10217.pkl'
-
关键点检测
python demo/demo.py --config-file configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml --input image/test.jpg --opts MODEL.WEIGHTS 'model/model_final_a6e10b.pkl'
-
全景分隔
python demo/demo.py --config-file configs/COCO-PanopticSegmentation/panoptic_fpn_R_101_3x.yaml --input image/test.jpg --opts MODEL.WEIGHTS 'model/model_final_cafdb1.pkl'
遇到的问题
- 如果存在多个vs版本需要设置
- SET MSSdk=1
- SET DISTUTILS_USE_SDK=1
- call “C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Auxiliary/Build/vcvarsall.bat” amd64 -vcvars_ver=14.28(根据自己路径修改.)
- Error checking compiler version for cl: 'utf-8' codec can't decode byte 0xd3 in position 0: invalid continuation byte.
- 打开cpp_extension.py,把编码改成' gbk'。 参考 https://blog.csdn.net/tanmx219/article/details/100829920
- Command '['ninja', '-v']' returned non-zero exit status 1 (参考 https://zhuanlan.zhihu.com/p/188575748 )
- 网上有说 将 -v 修改成 --v 或 --vision 千万别这么改, 虽然这个错误没有,但会引起别的错误。
- 解决办法就是往上面找报错的地方,比如我的报错信息是:
- calling a host function(”__floorf") from a global function("op::resize8TimesKernel “) is not allowed
- 找到报错的那个文件, 将 floor 改成 floorf. 同理还有有个ceilf好像报错,照葫芦画瓢,也将ceil 改成ceilf.(单词可能拼的不对,忘保存报错信息了。)
- 修改这个文件 "安装位置\envs\detectron2\Lib\site-packages\torch\include\torch\csrc\jit\runtime\argument_spec.h " (路径自行更改)
- static constexpr size_t ARG_SPEC_DEPTH_LIMIT = 128;; --> static const size_t ARG_SPEC_DEPTH_LIMIT = 128;
- namespace "at::cuda" has no member "ATenceilfDiv" (参考: https://blog.csdn.net/qq_37160943/article/details/103067163)
- 找到报错文件将 ATenceilfDiv 改成 ATenCeilDiv
- calling a host function(”__floorf") from a global function("op::resize8TimesKernel “) is not allowed
- 重新编译。
-
python setup.py clean --all
-
python setup.py build --force develop
-
- ModuleNotFoundError: No module named 'win32con'
- 尝试过使用 pip install pypiwin32 ,但貌似不好用
- 解决办法:下载源码:https://github.com/mhammond/pywin32
- cd pywin32
- python setup.py install --skip-verstamp
- 再次重新编译即可成功.
- python setup.py clean --all
- python setup.py build --force develop
End
以上内容本人亲测,编译通过,有需要的小伙伴可以参考。如有问题,欢迎留言指正。
版权声明:本文为CSDN博主「Jun_Oo」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/haiyangyunbao813/article/details/115106759
暂无评论