Search code examples
jupyter-notebookgoogle-colaboratoryfast-ai

Colab Jupyter notebook doesn't recognize functions after correct module import of fastai.vision


I worked quite a while on my .ipynb file on Colab. I'm working with fastai(v.2), yesterday I unintentionally tried to use open_image function from fastai(v.1), which wasn't recognized - no surprise. After restarting the runtime I got NameErrors on every fastai(also v2) function used in the whole code.

To fix this I:

  • restarted runtime
  • closed all running sessions
  • imported every module by name although the import functions worked fine before
  • restarted computer
  • tried on a different computer
  • started a new notebook

Once in a while it works on another notebook, but as soon as I run the original one I get the Name errors on every notebook I use.

Minimal code I used to reproduce the error myself is here. But since I guess it's a bug of my colab it'll be hard to reproduce. Anyway if somebody has got an idea let me know!

!pip install -Uqq fastai 
from fastai.vision.all import *
from scipy.io import loadmat 

print(fastai.__version__)

my_batch_tfms = aug_transforms(size=224)


Solution

  • Seems to be a Colab bug which is Accound bound. I started the exact same code with another Google Account in Colab and everything worked perfectly fine!