mit-han-lab / bevfusion

[ICRA'23] BEVFusion: Multi-Task Multi-Sensor Fusion with Unified Bird's-Eye View Representation
https://bevfusion.mit.edu
Apache License 2.0
2.26k stars 409 forks source link

Cannot Import from Partially Initialized Module (most likely due to a circular import) #449

Closed NoOneUST closed 1 year ago

NoOneUST commented 1 year ago
(base) torchpack dist-run -np 8 python tools/test.py configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/convfuser.yaml pretrained/bevfusion-det.pth --eval bbox
Traceback (most recent call last):
  File "tools/test.py", line 15, in <module>
    from mmdet3d.datasets import build_dataloader, build_dataset
  File "/export/data/mine/bevfusion/mmdet3d/datasets/__init__.py", line 4, in <module>
    from .custom_3d import *
  File "/export/data/mine/bevfusion/mmdet3d/datasets/custom_3d.py", line 10, in <module>
    from ..core.bbox import get_box_type
  File "/export/data/mine/bevfusion/mmdet3d/core/__init__.py", line 2, in <module>
    from .bbox import *  # noqa: F401, F403
  File "/export/data/mine/bevfusion/mmdet3d/core/bbox/__init__.py", line 3, in <module>
    from .iou_calculators import (AxisAlignedBboxOverlaps3D, BboxOverlaps3D,
  File "/export/data/mine/bevfusion/mmdet3d/core/bbox/iou_calculators/__init__.py", line 1, in <module>
    from .iou3d_calculator import (
  File "/export/data/mine/bevfusion/mmdet3d/core/bbox/iou_calculators/iou3d_calculator.py", line 5, in <module>
    from ..structures import get_box_type
  File "/export/data/mine/bevfusion/mmdet3d/core/bbox/structures/__init__.py", line 1, in <module>
    from .base_box3d import BaseInstance3DBoxes
  File "/export/data/mine/bevfusion/mmdet3d/core/bbox/structures/base_box3d.py", line 5, in <module>
    from mmdet3d.ops.iou3d import iou3d_cuda
  File "/export/data/mine/bevfusion/mmdet3d/ops/__init__.py", line 12, in <module>
    from .feature_decorator import feature_decorator
  File "/export/data/mine/bevfusion/mmdet3d/ops/feature_decorator/__init__.py", line 1, in <module>
    from .feature_decorator import feature_decorator
  File "/export/data/mine/bevfusion/mmdet3d/ops/feature_decorator/feature_decorator.py", line 4, in <module>
    from mmdet3d.ops.feature_decorator import feature_decorator_ext
ImportError: cannot import name 'feature_decorator_ext' from partially initialized module 'mmdet3d.ops.feature_decorator' (most likely due to a circular import) (/export/data/mine/bevfusion/mmdet3d/ops/feature_decorator/__init__.py)
--------------------------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

  Process name: [[64666,1],7]
  Exit code:    1
--------------------------------------------------------------------------
Isaac-xie commented 1 year ago

Hello, I have the same problem. May I ask how you solved it.

1145520074 commented 1 year ago

Hello, I have the same problem. May I ask how you solved it.

Bonasdljlkj commented 1 year ago

I also have the same problem,could you please tell me how to solve it

For24 commented 1 year ago

Hi, I found a quick but dirty workaround.

I found that 'featuredecorator' is a new module in latest update, so I simply comment the import of this module in 'mmdet3d/ops/__init_\.py' like this:

...
from .ball_query import ball_query
# from .feature_decorator import feature_decorator
from .furthest_point_sample import (
    Points_Sampler,
    furthest_point_sample,
    furthest_point_sample_with_dist,
)
...

And then I could run the code.

So I guess if your code doesn't use this model: mmdet3d/models/backbones/radar_encoder.py, this workaround would help a little.

Bonasdljlkj commented 1 year ago

Hi, I found a quick but dirty workaround.

I found that 'feature_decorator' is a new module in latest update, so I simply comment the import of this module in 'mmdet3d/ops/init.py' like this:

...
from .ball_query import ball_query
# from .feature_decorator import feature_decorator
from .furthest_point_sample import (
    Points_Sampler,
    furthest_point_sample,
    furthest_point_sample_with_dist,
)
...

And then I could run the code.

So I guess if your code doesn't use this model: mmdet3d/models/backbones/radar_encoder.py, this workaround would help a little.

Hi,I tried this method but still got an error. The command I'm running is ‘’torchpack dist-run -np 1 python tools/train.py configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/convfuser.yaml --model.encoders.camera.backbone.init_cfg.checkpoint pretrained/swint-nuimages-pretrained.pth --load_from pretrained/lidar-only-det.pth‘’,but it also cannot import name 'feature_decorator_ext'.Could you please tell me your run command?or Do you know what else it might be,Thanks

For24 commented 1 year ago

Hi, I found a quick but dirty workaround. I found that 'feature_decorator' is a new module in latest update, so I simply comment the import of this module in 'mmdet3d/ops/init.py' like this:

...
from .ball_query import ball_query
# from .feature_decorator import feature_decorator
from .furthest_point_sample import (
    Points_Sampler,
    furthest_point_sample,
    furthest_point_sample_with_dist,
)
...

And then I could run the code. So I guess if your code doesn't use this model: mmdet3d/models/backbones/radar_encoder.py, this workaround would help a little.

Hi,I tried this method but still got an error. The command I'm running is ‘’torchpack dist-run -np 1 python tools/train.py configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/convfuser.yaml --model.encoders.camera.backbone.init_cfg.checkpoint pretrained/swint-nuimages-pretrained.pth --load_from pretrained/lidar-only-det.pth‘’,but it also cannot import name 'feature_decorator_ext'.Could you please tell me your run command?or Do you know what else it might be,Thanks

Hi, I meet this error when I run the command to prepare the data and after I comment the previous line I could run the code.

For training, what about also comment this line in 'mmdet3d/models/backbones/__init__.py':

...
from .vovnet import *
from .dla import *
# from .radar_encoder import *

I guess there are bugs in this 'rader_encoder', so if you don't use it, just comment the import of it.

Bonasdljlkj commented 1 year ago

Thanks for your reply

Hi, I found a quick but dirty workaround. I found that 'feature_decorator' is a new module in latest update, so I simply comment the import of this module in 'mmdet3d/ops/init.py' like this:

...
from .ball_query import ball_query
# from .feature_decorator import feature_decorator
from .furthest_point_sample import (
    Points_Sampler,
    furthest_point_sample,
    furthest_point_sample_with_dist,
)
...

And then I could run the code. So I guess if your code doesn't use this model: mmdet3d/models/backbones/radar_encoder.py, this workaround would help a little.

Hi,I tried this method but still got an error. The command I'm running is ‘’torchpack dist-run -np 1 python tools/train.py configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/convfuser.yaml --model.encoders.camera.backbone.init_cfg.checkpoint pretrained/swint-nuimages-pretrained.pth --load_from pretrained/lidar-only-det.pth‘’,but it also cannot import name 'feature_decorator_ext'.Could you please tell me your run command?or Do you know what else it might be,Thanks

Hi, I meet this error when I run the command to prepare the data and after I comment the previous line I could run the code.

For training, what about also comment this line in 'mmdet3d/models/backbones/init.py':

...
from .vovnet import *
from .dla import *
# from .radar_encoder import *

I guess there are bugs in this 'rader_encoder', so if you don't use it, just comment the import of it.

Thanks for your reply

zhijian-liu commented 1 year ago

@K-Shao, could you please take a look at this issue? Thanks!

K-Shao commented 1 year ago

Sorry for the delay! This behavior is due to a bug in the feature decorator, which is a dummy OP for the ONNX exporting, which is not actually supported in the codebase currently. I have a PR (#466) that will fix the issue, but it should also simply work to (as @For24 mentions) comment out the feature decorator import in mmdet3d/ops/init.py (however, you should also comment lines 15 and 177-178 in radar_encoder.py).

poddar414 commented 1 year ago

I am still seeing this issue. I had old setup and it was working. Then I pulled the latest code and did again python setup.py develop. And then generated the data again, and tried training from camera segmentation cfg, then I faced this issue. I can see that latest commit is already there in my code.

jongchyisu commented 1 year ago

Also facing the same issue!

san9569 commented 1 year ago

@poddar414 @jongchyisu Have you solved it?

Wangquans commented 7 months ago

I have sloved this problem,you can comment the import of this module in 'mmdet3d/ops/init.py' like this: `

from .feature_decorator import feature_decorator`

then it still occurs another simliar problem,you should comment another import of this module in 'mmdet3d/ops/feature_decorator/init.py' like this: #from .feature_decorator import feature_decorator

then the problem is solved.