`learn.fine_tune(1)` Chapter 1 - takes forever

I ran this block of code on Colab from the Book(01_intro.ipynb)

from fastai.vision.all import *
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 = vision_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(1)

And the line **learn.fine_tune(1)** , just takes forever. It took 57 mins total to fine-tune (though downloading the dataset and model took less than a min)

Is this normal?

It sounds like the GPU has not been selected.

To select it.
From the colab top menu, select “Runtime” then “Change runtime type” and select GPU as the hardware accelerator, and save.

Then re-run the notebook.

7 Likes

Thanks @AllenK !
Yes, the GPU wasn’t selected. I changed the setting(selected GPU) and now it took less than Three minutes, compared to 57 mins!

TY

3 Likes

Thanks ! I was wondering what I’ve done wrong.

1 Like