from maskrcnn_benchmark.layers import Conv2d File "D:\Anacoda\envs\maskrcnn\lib\site-packages\maskrcnn_benc_error t">
当前位置:   article > 正文

maskrcnn在win10 报错 AttributeError: module ‘torch.distributed‘ has no attribute ‘deprecated‘_error torch.distributed.elastic.multiprocessing.ap

error torch.distributed.elastic.multiprocessing.api.failed

运行maskrcnn的demo时报错:

  File "D:\Anacoda\envs\maskrcnn\lib\site-packages\maskrcnn_benchmark\modeling\make_layers.py", line 10, in <module>
    from maskrcnn_benchmark.layers import Conv2d
  File "D:\Anacoda\envs\maskrcnn\lib\site-packages\maskrcnn_benchmark\layers\__init__.py", line 13, in <module>
    from .roi_pool import ROIPool
  File "D:\Anacoda\envs\maskrcnn\lib\site-packages\maskrcnn_benchmark\layers\roi_pool.py", line 10, in <module>
    from apex import amp
  File "D:\Anacoda\envs\maskrcnn\lib\site-packages\apex-0.1-py3.6-win-amd64.egg\apex\__init__.py", line 5, in <module>
    from . import parallel
  File "D:\Anacoda\envs\maskrcnn\lib\site-packages\apex-0.1-py3.6-win-amd64.egg\apex\parallel\__init__.py", line 8, in <module>
    ReduceOp = torch.distributed.deprecated.reduce_op
AttributeError: module 'torch.distributed' has no attribute 'deprecated'

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

找到报错中定位的apex文件位置,如

    from .roi_pool import ROIPool
  File "D:\Anacoda\envs\maskrcnn\lib\site-packages\maskrcnn_benchmark\layers\roi_pool.py", line 10, in <module>
  • 1
  • 2

点击进入roi_poolroi_align.py文件,注释掉

from maskrcnn_benchmark import _C
# from apex import amp
  • 1
  • 2
    # @amp.float_function
    def forward(self, input, rois):
        return roi_pool(input, rois, self.output_size, self.spatial_scale)
  • 1
  • 2
  • 3

将nms.py文件

from maskrcnn_benchmark import _C

from apex import amp

# Only valid with fp32 inputs - give AMP the hint
nms = amp.float_function(_C.nms)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

更改为

rom maskrcnn_benchmark import _C

# from apex import amp

# Only valid with fp32 inputs - give AMP the hint
# nms = amp.float_function(_C.nms)
nms=_C.nms
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

之后使用命令

python webcam.py --min-image-size 224
  • 1

就可以不依赖apex运行 demo
请添加图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/390420
推荐阅读
相关标签
  

闽ICP备14008679号