MILVLG / bottom-up-attention.pytorch

A PyTorch reimplementation of bottom-up-attention models
Apache License 2.0
294 stars 76 forks source link

ImportError: cannot import name '_C' from partially initialized module 'bua.caffe.modeling' #105

Open zsylabtip1 opened 1 year ago

zsylabtip1 commented 1 year ago

我在运行extract_features.py时,产生了错误,下面是完整的错误信息: 请问有什么办法解决这个问题吗?


/root/anaconda3/envs/yiz_py/bin/python3.8 /data/yiz/FasterRcnn/extract_features.py 
Traceback (most recent call last):
  File "/data/yiz/FasterRcnn/extract_features.py", line 17, in <module>
    from utils.extract_d2features import extract_feat_d2_start
  File "/data/yiz/FasterRcnn/utils/__init__.py", line 1, in <module>
    from .utils import save_features
  File "/data/yiz/FasterRcnn/utils/utils.py", line 7, in <module>
    from bua.caffe.modeling.layers.nms import nms
  File "/data/yiz/FasterRcnn/bua/__init__.py", line 1, in <module>
    from .d2 import add_attribute_config
  File "/data/yiz/FasterRcnn/bua/d2/__init__.py", line 5, in <module>
    from .modeling.roi_heads import AttributeRes5ROIHeads
  File "/data/yiz/FasterRcnn/bua/d2/modeling/roi_heads.py", line 20, in <module>
    from bua.caffe.modeling.box_regression import BUABox2BoxTransform
  File "/data/yiz/FasterRcnn/bua/caffe/__init__.py", line 2, in <module>
    from .modeling.backbone import build_bua_resnet_backbone
  File "/data/yiz/FasterRcnn/bua/caffe/modeling/__init__.py", line 3, in <module>
    from .roi_heads import BUACaffeRes5ROIHeads
  File "/data/yiz/FasterRcnn/bua/caffe/modeling/roi_heads.py", line 17, in <module>
    from .fast_rcnn import BUACaffeFastRCNNOutputs, BUACaffeFastRCNNOutputLayers, BUADetection2FastRCNNOutputs, BUADetectron2FastRCNNOutputLayers
  File "/data/yiz/FasterRcnn/bua/caffe/modeling/fast_rcnn.py", line 15, in <module>
    from .layers.nms import batched_nms
  File "/data/yiz/FasterRcnn/bua/caffe/modeling/layers/nms.py", line 3, in <module>
    from bua.caffe.modeling import _C
ImportError: cannot import name '_C' from partially initialized module 'bua.caffe.modeling' (most likely due to a circular import) (/data/yiz/FasterRcnn/bua/caffe/modeling/__init__.py)

Process finished with exit code 1
niuzhustc commented 1 year ago

我在运行extract_features.py时,产生了错误,下面是完整的错误信息: 请问有什么办法解决这个问题吗?

/root/anaconda3/envs/yiz_py/bin/python3.8 /data/yiz/FasterRcnn/extract_features.py 
Traceback (most recent call last):
  File "/data/yiz/FasterRcnn/extract_features.py", line 17, in <module>
    from utils.extract_d2features import extract_feat_d2_start
  File "/data/yiz/FasterRcnn/utils/__init__.py", line 1, in <module>
    from .utils import save_features
  File "/data/yiz/FasterRcnn/utils/utils.py", line 7, in <module>
    from bua.caffe.modeling.layers.nms import nms
  File "/data/yiz/FasterRcnn/bua/__init__.py", line 1, in <module>
    from .d2 import add_attribute_config
  File "/data/yiz/FasterRcnn/bua/d2/__init__.py", line 5, in <module>
    from .modeling.roi_heads import AttributeRes5ROIHeads
  File "/data/yiz/FasterRcnn/bua/d2/modeling/roi_heads.py", line 20, in <module>
    from bua.caffe.modeling.box_regression import BUABox2BoxTransform
  File "/data/yiz/FasterRcnn/bua/caffe/__init__.py", line 2, in <module>
    from .modeling.backbone import build_bua_resnet_backbone
  File "/data/yiz/FasterRcnn/bua/caffe/modeling/__init__.py", line 3, in <module>
    from .roi_heads import BUACaffeRes5ROIHeads
  File "/data/yiz/FasterRcnn/bua/caffe/modeling/roi_heads.py", line 17, in <module>
    from .fast_rcnn import BUACaffeFastRCNNOutputs, BUACaffeFastRCNNOutputLayers, BUADetection2FastRCNNOutputs, BUADetectron2FastRCNNOutputLayers
  File "/data/yiz/FasterRcnn/bua/caffe/modeling/fast_rcnn.py", line 15, in <module>
    from .layers.nms import batched_nms
  File "/data/yiz/FasterRcnn/bua/caffe/modeling/layers/nms.py", line 3, in <module>
    from bua.caffe.modeling import _C
ImportError: cannot import name '_C' from partially initialized module 'bua.caffe.modeling' (most likely due to a circular import) (/data/yiz/FasterRcnn/bua/caffe/modeling/__init__.py)

Process finished with exit code 1

Your torch version or cuda version maybe wrong. If you use RTX30xx or higher, It may fail to build. I recommand you to use cuda 10.1. Here is my solution, you can try it: torch1.5+cu 101+cp36 on 2080ti, apex version--22.04, detectron2--v0.3, maybe you could try this.

zsylabtip1 commented 1 year ago

这是来自邮箱的假期自动回复邮件。您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。