aitextgen
aitextgen copied to clipboard
The provided lr scheduler `LambdaLR` doesn't follow PyTorch's LRScheduler API.
- pytorch 2.0.0
- python 3.10.10
- cuda 11.7
I'm trying to run the Demo code, but keep getting this error when it tries to call ai.train()
Is this an issue with aitextgen or with the pytorch/lightning package?
pytorch_lightning.utilities.exceptions.MisconfigurationException:
The provided lr scheduler `LambdaLR` doesn't follow PyTorch's LRScheduler API.
You should override the `LightningModule.lr_scheduler_step` hook with your own logic if you are using a custom LR scheduler.
The demo script (with some prints added to see where it fails)
from aitextgen.TokenDataset import TokenDataset
from aitextgen.tokenizers import train_tokenizer
from aitextgen.utils import GPT2ConfigCPU
from aitextgen import aitextgen
file_name = "F:\\AITextGen\\myfile.txt"
print("train tokenizer")
train_tokenizer(file_name)
tokenizer_file = "aitextgen.tokenizer.json"
ai = aitextgen(tokenizer_file=tokenizer_file)
print("build dataset for training")
data = TokenDataset(file_name, tokenizer_file=tokenizer_file, block_size=64)
print("Train using my own text")
ai.train(data, batch_size=8, num_steps=50000, generate_every=1000, save_every=1000)
print("generate response")
# Generate text from it!
ai.generate(10, prompt="My Prompt:")
Full error message:
Traceback (most recent call last):
File "F:\LanguageCodeNLP\AITextGen\trainwithgpu.py", line 33, in LambdaLR
doesn't follow PyTorch's LRScheduler API. You should override the LightningModule.lr_scheduler_step
hook with your own logic if you are using a custom LR scheduler.
I manage to resolve the error on the google colab by running this:
!pip install -qq pytorch-lightning==1.7.0 transformers==4.21.3 aitextgen==0.6.0
Please do let me know if it also solves your issue on colab
Originally posted by @analyticray in https://github.com/minimaxir/aitextgen/issues/218#issuecomment-1490176216
That seems to fix things in Colab for me, but not in the local install.
On Ubuntu 20.04 the above version install results in the same error as the OP.
The combo !pip install -qq pytorch-lightning==1.7.0 transformers==4.21.3 aitextgen==0.6.0 does not work with python 3.10.6.
on python 3.11, installing pytorch-lightning==1.7.0 results in:
error: can't find Rust compiler