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' #8232

Closed
yuchenlin opened this issue Nov 2, 2020 · 3 comments · Fixed by #8237 or #8979
Closed

Comments

@yuchenlin
Copy link
Contributor

Environment info

  • transformers version:
  • Platform: ubuntu 18.04
  • Python version: 3.7
  • PyTorch version (GPU?): 1.4.0
  • Tensorflow version (GPU?):
  • Using GPU in script?: no
  • Using distributed or parallel set-up in script?:no

Who can help

Trainer: @sgugger

Information

This import is not compatible with PyTorch 1.4.0

The problem arises when using:

  • [ *] the official example scripts: (give details below)

The tasks I am working on is:

  • [ *] an official GLUE/SQUaD task: (give the name)

To reproduce

Steps to reproduce the behavior:

>>> from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/yuchenlin/anaconda3/envs/mcqa/lib/python3.7/site-packages/transformers/__init__.py", line 611, in <module>
    from .trainer import Trainer
  File "/home/yuchenlin/anaconda3/envs/mcqa/lib/python3.7/site-packages/transformers/trainer.py", line 69, in <module>
    from .trainer_pt_utils import (
  File "/home/yuchenlin/anaconda3/envs/mcqa/lib/python3.7/site-packages/transformers/trainer_pt_utils.py", line 26, in <module>
    from torch.optim.lr_scheduler import SAVE_STATE_WARNING
ImportError: cannot import name 'SAVE_STATE_WARNING' from 'torch.optim.lr_scheduler' (/home/yuchenlin/anaconda3/envs/mcqa/lib/python3.7/site-packages/torch/optim/lr_scheduler.py)

Expected behavior

@sgugger
Copy link
Collaborator

sgugger commented Nov 2, 2020

Oh I didn't check when they added this. Do you know if PyTorch 1.4.0 is the last version without it? Will add a fix this morning.

@yuchenlin
Copy link
Contributor Author

thank you for the quick fix.

@stas00
Copy link
Contributor

stas00 commented Dec 8, 2020

SAVE_STATE_WARNING has been removed 3 days ago: pytorch/pytorch#46813

Need to update #8237 to reflect this change.

@stas00 stas00 reopened this Dec 8, 2020
stas00 added a commit that referenced this issue Dec 8, 2020
FYI `SAVE_STATE_WARNING` has been removed 3 days ago: pytorch/pytorch#46813

Fixes: #8232

@sgugger
stas00 added a commit that referenced this issue Dec 8, 2020
* [training] SAVE_STATE_WARNING was removed in pytorch

FYI `SAVE_STATE_WARNING` has been removed 3 days ago: pytorch/pytorch#46813

Fixes: #8232

@sgugger

* style, but add () to prevent autoformatters from botching it

* switch to try/except

* cleanup
binshengliu pushed a commit to binshengliu/transformers that referenced this issue Mar 2, 2021
* [training] SAVE_STATE_WARNING was removed in pytorch

FYI `SAVE_STATE_WARNING` has been removed 3 days ago: pytorch/pytorch#46813

Fixes: huggingface#8232

@sgugger

* style, but add () to prevent autoformatters from botching it

* switch to try/except

* cleanup
binshengliu pushed a commit to binshengliu/transformers that referenced this issue Mar 2, 2021
* [training] SAVE_STATE_WARNING was removed in pytorch

FYI `SAVE_STATE_WARNING` has been removed 3 days ago: pytorch/pytorch#46813

Fixes: huggingface#8232

@sgugger

* style, but add () to prevent autoformatters from botching it

* switch to try/except

* cleanup
binshengliu pushed a commit to binshengliu/transformers that referenced this issue Mar 5, 2021
* [training] SAVE_STATE_WARNING was removed in pytorch

FYI `SAVE_STATE_WARNING` has been removed 3 days ago: pytorch/pytorch#46813

Fixes: huggingface#8232

@sgugger

* style, but add () to prevent autoformatters from botching it

* switch to try/except

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