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 '_TPU_AVAILABLE' from 'pytorch_lightning.utilities' #200

Closed
ProfessorQu opened this issue Nov 5, 2022 · 13 comments · Fixed by #202
Closed

Comments

@ProfessorQu
Copy link

Tested in a colab notebook, with !pip install aitextgen -q. Then ran

from aitextgen import aitextgen

ai = aitextgen()

in the next cell, an got this error:

---------------------------------------------------------------------------

ImportError                               Traceback (most recent call last)

[<ipython-input-5-5376f3cb6e07>](https://localhost:8080/#) in <module>
----> 1 from aitextgen import aitextgen
      2 
      3 ai = aitextgen()

2 frames

[/usr/local/lib/python3.7/dist-packages/aitextgen/train.py](https://localhost:8080/#) in <module>
     12 import pytorch_lightning as pl
     13 from pytorch_lightning.callbacks.progress import ProgressBarBase
---> 14 from pytorch_lightning.utilities import _TPU_AVAILABLE
     15 
     16 

ImportError: cannot import name '_TPU_AVAILABLE' from 'pytorch_lightning.utilities' (/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/__init__.py)


---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
@ephraimduncan
Copy link

I had the same issue on an M1.

You can fix it by downgrading aitextgen

pip3 install -q aitextgen==0.5.2

@katemonster33
Copy link

@dephraiim Downgrading did not work for me - same error.

@ioistired
Copy link

Can confirm this issue on both 0.5.2 and 0.6.0.

@katemonster33
Copy link

Was able to get past this error by downgrading pytorch_lightning to 1.7.7, still having errors in torch though.

@bdunnette
Copy link

Uninstalling torch and then reinstalling with version 1.9.0 seems to do the trick:

!pip uninstall -qqy torch torchvision torchtext torchaudio fastai
!pip install -qq torch==1.9.0 pytorch-lightning==1.7.7 aitextgen==0.6.0 

@mirrorsonthewall
Copy link

Tried bdunnette's code but it gave an error, something like that pytorch wasn't available among options of pytorch-lighting 1.11.0 through 1.13.0, so I chose 1.11.0 and it seemed to work instead (after running first uninstall line):

pip install -qq torch==1.9.0 pytorch-lightning==1.11.0 aitextgen==0.6.0

@rmc135
Copy link

rmc135 commented Dec 17, 2022

FYI, I had the same error. A downgrade to 0.5.2 did not change behaviour, but a further step back to 0.5.1 worked.

This is under pyenv/venv 3.9.15

@ThatCoffeeGuy
Copy link

ThatCoffeeGuy commented Dec 19, 2022

Same issue here. Interestingly I installed the packages with the same command on 2 different machines(Same ubuntu server OS) and only one of them is having this issue.

This solved it:

pip uninstall -qqy torch torchvision torchtext torchaudio fastai
pip install -qq torch==1.11.0 pytorch-lightning==1.7.7 aitextgen==0.6.0

@thani-ath-nain
Copy link

None of the above worked for me. Please someone suggest something different

@carmocca
Copy link

For any lurkers, @llimllib was kind enough to propose a fix in #202. You can apply the patch locally or pip install git+https://github.com/llimllib/aitextgen@fix_tpu_available until a maintainer merges the PR (at your own discretion).

For the project maintainers, it might be a good idea to pin your dependencies, particularly the PL one, to avoid issues like this:

pytorch-lightning>=1.3.1

@jryebread
Copy link

jryebread commented Jan 19, 2023

Still getting this issue even after pip installing the separate branch 🤔 None of these options worked for me in the finetuning gpt2 colab

@pst2154
Copy link

pst2154 commented Feb 8, 2023

All I had to do was restart my jupyter kernal after installing, then import worked

@KonradHoeffner
Copy link

The solution of @carmocca worked for me, but only after pip uninstall aitextgen first.

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

Successfully merging a pull request may close this issue.