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 'SAVE_STATE_WARNING' from 'torch.optim.lr_scheduler' - SAVE_STATE_WARNING has been removed from pytorch #9060

Closed
dbonner opened this issue Dec 11, 2020 · 4 comments

Comments

@dbonner
Copy link

dbonner commented Dec 11, 2020

ERROR:
..../my37/lib/python3.7/site-packages/transformers/trainer_pt_utils.py", line 40, in
from torch.optim.lr_scheduler import SAVE_STATE_WARNING
ImportError: cannot import name 'SAVE_STATE_WARNING' from 'torch.optim.lr_scheduler' (......./my37/lib/python3.7/site-packages/torch/optim/lr_scheduler.py)

Please update transformers to be compatible with the latest pytorch source code (build from master branch:
'SAVE_STATE_WARNING' was removed from pytorch a few days ago.

@dbonner
Copy link
Author

dbonner commented Dec 11, 2020

.I can see you have fixed this in the source code.

@dbonner dbonner closed this as completed Dec 11, 2020
@dwalterlm
Copy link

I just upgraded to torch 1.8 and I got this error.

Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/dwalter/anaconda3/envs/lm-torch1.8/lib/python3.6/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_quantize.py:7: in <module>
    import quantization.fused_nn as qnni
quantization/__init__.py:2: in <module>
    from .fused_nn import ConvNL2d
quantization/fused_nn.py:4: in <module>
    from .nn import Conv2d
quantization/nn/__init__.py:8: in <module>
    import transformers.modeling_bert as bert
/home/dwalter/anaconda3/envs/lm-torch1.8/lib/python3.6/site-packages/transformers/__init__.py:626: in <module>
    from .trainer import Trainer
/home/dwalter/anaconda3/envs/lm-torch1.8/lib/python3.6/site-packages/transformers/trainer.py:69: in <module>
    from .trainer_pt_utils import (
/home/dwalter/anaconda3/envs/lm-torch1.8/lib/python3.6/site-packages/transformers/trainer_pt_utils.py:40: in <module>
    from torch.optim.lr_scheduler import SAVE_STATE_WARNING
E   ImportError: cannot import name 'SAVE_STATE_WARNING'

Is there something I need to fix in my code or did I not upgrade correctly?
upgraded with pip install --upgrade torch

@LysandreJik
Copy link
Member

@dwalterlm you're probably on an older Transformers version. This was fixed in #8979, could you try upgrading to a more recent version, like v4.3.0?

@pengwenzhong
Copy link

the version of torch is too high,try use : torch 1.7.1

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

4 participants