01_intro.ipynb --- Problems on first example

Stop the presses! This Just in! See solution below!

I am attempting to follow the Fastbook Fastai course using Colab. I am having problems with the very first example. I have tried several recommended fixes - that have not worked.

Someone, please help me to get going.
I’d really like to do the course - especially after having bought the book.

`
#id first_training
#caption Results from the first training
/#CLICK ME
!pip install fastai==2.0 # ERROR --> as of 20201230 need to specify 2.0
import fastai
from fastai import * # Tried and failed to correct “NameError: name ‘untar_data’ is not defined”
print(fastai.version) # (should print 2.0.0 and it does)
from fastai.vision import * # new, corrected line
/# from fastai.vision.all import * # old line - not right
/# from fastai.datasets import untar_data # another possible fix - found in forum -> does not help
path = untar_data(URLs.PETS)/‘images’

def is_cat(x): return x[0].isupper()
dls = ImageDataLoaders.from_name_func(
path, get_image_files(path), valid_pct=0.2, seed=42,
label_func=is_cat, item_tfms=Resize(224))

learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(1)
`
I get the following error.
I have done several searches and fixed some errors already but this one remains.

`---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
in ()
8 from fastai.vision import * # new, corrected line
9 # from fastai.vision.all import * # old line - not right
—> 10 from fastai.datasets import untar_data # another possible fix - found in forum
11 path = untar_data(URLs.PETS)/‘images’
12

ModuleNotFoundError: No module named ‘fastai.datasets’

---------------------------------------------------------------------------`

…Bob

The solution:

The problem only occurs when I run the file from a copy in my Google Drive that I had downloaded from the fastai GitHub repository and had syched to my Google Drive. Interestingly, there is no error message when I run this way without a GPU (but it would take a looong time to finish). The error only occurs when I activate a GPU!

Bottom line is that from now on I will run from the fastai GitHub repository only - - - but it would be nice to be able to run from my Google Drive as well.
…Bob

1 Like

Thanks for posting this, Bob! I was having similar problems trying to run the first examples in lesson one from my Google drive, but now it suddenly works. I wonder if running from Google drive eventually worked for you?