Transformer: Error importing packages. “ImportError: cannot import name ‘SAVE_STATE_WARNING’ from ‘torch.optim.lr_scheduler'”

We Are Going To Discuss About Transformer: Error importing packages. “ImportError: cannot import name ‘SAVE_STATE_WARNING’ from ‘torch.optim.lr_scheduler'”. So lets Start this Python Article.

Transformer: Error importing packages. “ImportError: cannot import name ‘SAVE_STATE_WARNING’ from ‘torch.optim.lr_scheduler'”

  1. How to solve Transformer: Error importing packages. “ImportError: cannot import name 'SAVE_STATE_WARNING' from 'torch.optim.lr_scheduler'”

    Change the torch version in colab by running this command
    !pip install torch==1.4.0. Then, It worked for me.

  2. Transformer: Error importing packages. “ImportError: cannot import name 'SAVE_STATE_WARNING' from 'torch.optim.lr_scheduler'”

    Change the torch version in colab by running this command
    !pip install torch==1.4.0. Then, It worked for me.

Solution 1

Change the torch version in colab by running this command

!pip install torch==1.4.0. Then, It worked for me.

Original Author Yashwanth Reddy Of This Content

Solution 2

Just change the version of tranformers to the latest one (4.5.1 at this time). That worked in colab.

!pip install transformers

Original Author Prateek Saxena Of This Content

Solution 3

The same issue occurred to me with the PyTorch version after being upgraded.
As for the solution downgrade Pytorch version to 1.4.0.

Use the below command to install


!pip install -q torch==1.4.0 -f https://download.pytorch.org/whl/cu101/torch_stable.html

It’s solved a lot of problems with transformers also.

Original Author udara vimukthi Of This Content

Solution 4

The above from udara vimukthi worked for me after trying a lot of different things, trying to get the code for “Getting started with Google BERT” to work after cloning the gitHub repository locally, so now ALL of the chapter code works while I’m showing my daughter the models.

Operating system – Windows. Running locally with GPU support, using Anaconda environment.

pip install -q --user torch==1.4.0 -f https://download.pytorch.org/whl/cu101/torch_stable.html

then I ran into some more issues and had to install the ipwidgets

pip install ipywidgets

Now it all works, as far as I’ve gotten. Thanks for the help with the above suggestion it saved me a lot of headaches. 🙂

Original Author Dale Robichaud Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment