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 'TransformerDecoderLayer' from partially initialized module 'fairseq.modules' (most likely due to a circular import) (.../fairseq/fairseq/modules/__init__.py) #231

Closed
mohammadjavadpirhadi opened this issue Sep 11, 2022 · 4 comments

Comments

@mohammadjavadpirhadi
Copy link

mohammadjavadpirhadi commented Sep 11, 2022

Hi,

I had run the pretrain task before, but now I'm facing this error after running bash pretrain_ofa_base.sh:

ImportError: cannot import name 'TransformerDecoderLayer' from partially initialized module 'fairseq.modules' (most likely due to a circular import) (.../fairseq/fairseq/modules/__init__.py)

Full log:

Traceback (most recent call last):
  File "../../train.py", line 29, in <module>
    from fairseq import (
  File ".../OFA/fairseq/fairseq/quantization_utils.py", line 8, in <module>
    from fairseq.modules.quantization import pq, quantization_options, scalar
  File ".../OFA/fairseq/fairseq/modules/__init__.py", line 39, in <module>
    from .transformer_layer import TransformerDecoderLayer, TransformerEncoderLayer
  File ".../OFA/fairseq/fairseq/modules/transformer_layer.py", line 15, in <module>
    from fairseq.models.transformer import (
  File ".../OFA/fairseq/fairseq/models/__init__.py", line 236, in <module>
    import_models(models_dir, "fairseq.models")
  File ".../OFA/fairseq/fairseq/models/__init__.py", line 218, in import_models
    importlib.import_module(namespace + "." + model_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File ".../fairseq/fairseq/models/nat/__init__.py", line 12, in <module>
    from .levenshtein_transformer import *
  File ".../OFA/fairseq/fairseq/models/nat/levenshtein_transformer.py", line 13, in <module>
    from fairseq.modules import TransformerDecoderLayer
ImportError: cannot import name 'TransformerDecoderLayer' from partially initialized module 'fairseq.modules' (most likely due to a circular import(.../OFA/fairseq/fairseq/modules/__init__.py)
@JustinLin610
Copy link
Member

Did you install the fairseq that we provide in this repo?

@mohammadjavadpirhadi
Copy link
Author

Did you install the fairseq that we provide in this repo?

Yes, I have installed the requirements using requirements.txt you provided.

@yangapku
Copy link
Member

Please refer to these issues. #217 #225

@mohammadjavadpirhadi
Copy link
Author

Please refer to these issues. #217 #225

Thanks. Everything is OK now!

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

3 participants