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

[Bug] ModuleNotFoundError: No module named 'torch.ao' #68

Open
almostimplemented opened this issue Jun 13, 2022 · 7 comments
Open

[Bug] ModuleNotFoundError: No module named 'torch.ao' #68

almostimplemented opened this issue Jun 13, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@almostimplemented
Copy link

Following setup instructions at present will lead to an error on the model import. Specifically, torchvision needs to be pinned to a version. Otherwise, pip may install (e.g.) 0.12.0, which expects torch==1.11.0 when it imports torch.ao.

 from models import AASTModel
/homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: /homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/torchvision/image.so: undefined symbol: _ZNK3c106IValue23reportToTensorTypeErrorEv
  warn(f"Failed to load image Python extension: {e}")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/homes/ace01/non_forks/ast/src/models/__init__.py", line 8, in <module>
    from .ast_models import *
  File "/homes/ace01/non_forks/ast/src/models/ast_models.py", line 14, in <module>
    import timm
  File "/homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/timm/__init__.py", line 2, in <module>
    from .models import create_model, list_models, is_model, list_modules, model_entrypoint, \
  File "/homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/timm/models/__init__.py", line 1, in <module>
    from .byobnet import *
  File "/homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/timm/models/byobnet.py", line 36, in <module>
    from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  File "/homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/timm/data/__init__.py", line 7, in <module>
    from .loader import create_loader
  File "/homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/timm/data/loader.py", line 12, in <module>
    from .transforms_factory import create_transform
  File "/homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/timm/data/transforms_factory.py", line 9, in <module>
    from torchvision import transforms
  File "/homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/torchvision/__init__.py", line 7, in <module>
    from torchvision import models
  File "/homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/torchvision/models/__init__.py", line 18, in <module>
    from . import quantization
  File "/homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/torchvision/models/quantization/__init__.py", line 1, in <module>
    from .mobilenet import *
  File "/homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/torchvision/models/quantization/mobilenet.py", line 1, in <module>
    from .mobilenetv2 import QuantizableMobileNetV2, mobilenet_v2, __all__ as mv2_all
  File "/homes/ace01/non_forks/ast/venvast/lib/python3.7/site-packages/torchvision/models/quantization/mobilenetv2.py", line 5, in <module>
    from torch.ao.quantization import QuantStub, DeQuantStub
ModuleNotFoundError: No module named 'torch.ao'
@YuanGongND
Copy link
Owner

Hi there,

Did we use torchvision somewhere in the repo? Could you point me to that?

Thanks!

-Yuan

@almostimplemented
Copy link
Author

Hi there,

Did we use torchvision somewhere in the repo? Could you point me to that?

Thanks!

-Yuan

Hi Yuan,

If you follow the call stack you can see the dependency arises from import timm from ast_models.py

@YuanGongND
Copy link
Owner

YuanGongND commented Jun 13, 2022

Thanks! I just checked, it seems we use torchvision==0.10.0+cu102

>>> torch.__version__
'1.8.1+cu102'
>>> torchaudio.__version__
'0.8.1'
>>> torchvision.__version__
'0.10.0+cu102'

It's weird that no one has complained about this issue. I assume the order you install these three packages also matters.

@almostimplemented
Copy link
Author

I suspect it is more to do with when the user installed the dependencies rather than the order -- I think the breaking change came only in the 0.12.0 release:

https://github.com/pytorch/vision/releases/tag/v0.12.0

Without pinning the version in the requirements file, pip will get the latest. So anyone who set up before that point would have avoided the issue -- or perhaps anyone who installed into a Python environment with torchvision already installed / cached at a lower version.

@almostimplemented
Copy link
Author

Would you like the version changed to 0.10.0?

@YuanGongND
Copy link
Owner

Yes, but I will need to test it before changing it.

Thanks again for pointing this out.

@YuanGongND YuanGongND added the bug Something isn't working label Jun 13, 2022
@YuanGongND
Copy link
Owner

A regular check on the traffic of this repo shows that many people are searching this issue - which means this bug affects many people. Follow your suggestion I have pinned torchvision to 0.10.0. I don't have time to make a test but hope that would makes things better.

If anyone still experience this bug, please leave a message in this thread and I will take another look.

-Yuan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants