Help with colab

Hi there,

I have been running fastai v2 in colab for sometime now and have an NLP project that I have been working on. since yesterday, I am getting many errors when I try to run it.

For example:
from fastai.text.all import *

ModuleNotFoundError Traceback (most recent call last)

in () ----> 1 from fastai.text.all import *

/usr/local/lib/python3.6/dist-packages/fastai/text/all.py in () 1 from …basics import * ----> 2 from …callback.all import * 3 from .core import * 4 from .data import * 5 from .models import *

ModuleNotFoundError: No module named ‘fastai.callback.all’; ‘fastai.callback’ is not a package

If I run it like this:
from fastai.text import *

I get no error until I try to make a dataloader, in which case I get this:
dls_clas = TextDataLoaders.from_df(data, text_col = 1, label_col =3, text_vocab=lm_vocab, seq_len = 256, bs = batch_size, valid_pct =0.1)

At which point I get this error:

NameError Traceback (most recent call last)
in ()
1 #I have determined that the max sequence length is 237 so this is what is input below
2 #first time around text_vocab=dls_lm.vocab, changed for when I reload the languange model
----> 3 dls_clas = TextDataLoaders.from_df(data, text_col = 1, label_col =3, text_vocab=lm_vocab, seq_len = 256, bs = batch_size, valid_pct =0.1)

NameError: name ‘TextDataLoaders’ is not defined

Any help would be much appreciated. I have invested a lot of work in this little project and would like to save it if possible.

Thanks in advance

Hey Jeff,

It’s usually a good idea to upgrade library versions when using Colab - in this case, try something like !pip install -U fastai. This should install the latest release of fastai and everything should work now.

4 Likes

thanks so much! It worked. I had been trying this:

!pip install fastai --upgrade

which did not work. (not sure where I got that from)

1 Like

--upgrade worked for me with a similar problem. Did you restart the runtime after running the cell? It’s what made it work for me

2 Likes