Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zsylabtip1 opened this issue May 14, 2023 · 2 comments

Comments

@zsylabtip1
Copy link

zsylabtip1 commented May 14, 2023

我在运行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
Copy link

我在运行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
Copy link
Author

zsylabtip1 commented Sep 26, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants