DataBlock not defined

While reading the fastbook and running kernels, there was no problem (could be because of fastbook import perhaps). But when importing from scratch, tried:

   from fastai.vision import *
   from fastai.vision.data import *

Colab and local jupyer lab would throw an error.
These 2 from visual tutorials are also not working:

from fastai2.data.all import *
from fastai2.vision.all import *

fastai2 must be outdated, but I still gave it a run.

This is an error:
NameError: name 'DataBlock' is not defined

Please tell, how to import properly.

ps. forums and SO didn’t help.

  1. For some reason, if you start colab with GPU on (at the very beginning) it throws that error and won’t even allow to import the first few cells we have in every course NB (!pip installing the book and importing it). I have got concerned because it was all good a few last weeks. Somehow GPU has got enabled by default.
  2. I partially fixed the problem locally, but I need to import fastbook. I thought the book was only needed to run the course more smoothly, or do you need it to import it every time to make DataBlock available?

Thanks.

Hi olegperegudov hope you are having a beautiful day!

in my personal notes I have written the following - run the code below at the beginig of each notebook.

!pip install -Uqq fastbook

import fastbook

fastbook.setup_book() # added as couldn't find untar command below 20201205

I also have this note in my persnal notes book also,./

On colab, you would type: pip install fastai --upgrade and then restart your runtime. Then it should work just fine! # had to do above 20200929 to stop error below (NameError: name ‘ImageDataLoaders’ is not defined)

I haven’t done any further research, It just worked for me and without it, I experience errors, with it my noteboooks work fine on Colab every day!

Theres so much to learn in AI I don’t have the time to understand things, unless I have to.The Fastbook Module contains an attribute for everry function that I have seen in fastai such as dataloaders etc. (as of today 996 attributes).

Hope this helps.

Cheers mrfabulous1 :smiley: :smiley: