amaiya / ktrain

ktrain is a Python library that makes deep learning and AI more accessible and easier to apply
Apache License 2.0
1.22k stars 269 forks source link

Error while importing Ktrain in Colab #339

Closed katreparitosh closed 3 years ago

katreparitosh commented 3 years ago

Hi,

Importing ktrain in Google Colab gives an unseen ImportError:cannot import name 'SAVE_STATE_WARNING' from 'torch.optim.lr_scheduler' (/usr/local/lib/python3.7/dist-packages/torch/optim/lr_scheduler.py

I imported ktrain after installing it with pip3.

image

Kindly check and advise.

VELCpro commented 3 years ago

There is a problem with the new version of pythorch installed on Colab. Form me downgrading at the previous version fixed the problem.

Simply run in a cell in Colab.

!pip install torch==1.7.1

amaiya commented 3 years ago

@katreparitosh: Thanks for letting me know. As @VELCpro said, transformers==3.5.1 is not compatible with PyTorch 1.8.

The latest version of ktrain (v0.26.0) now uses transformers>4.0.0 (compatible with PyTorch 1.8), so this problem should now be resolved. However, if using an older version of ktrain, you will need to downgrade PyTorch to 1.7.1, as @VELCpro stated.

katreparitosh commented 3 years ago

Thanks @VELCpro and @amaiya !