Platform: Colab (Free; $10/month Pro)

What I usually do is to create a Github repository and in the first line of colab I clone it in order to access util files that I put in the repository. Then, when I want to save what I did, I go to File > Save Copy in Github.

Do we have to terminate our Colab runtime session when we’re done? I didn’t see that step in the setup guide.

From google

Google Colab notebooks have an idle timeout of 90 minutes and absolute timeout of 12 hours. This means, if user does not interact with his Google Colab notebook for more than 90 minutes, its instance is automatically terminated. Also, maximum lifetime of a Colab instance is 12 hours.

3 Likes

Another option (if you want the dataset to be in google drive), could be to copy the data from the drive up to /content via cp

1 Like

Indeed! I haven’t tried that but probably works too!

Running Fast AI on Google Colab from Github

I created a fork of course-v4 where I will be setting up the notebooks for running on Google Colab. Here’s the link for running the material of the first class:

NOTE: After running the first cell, you have to restart the environment and then run the rest normally.

NOTE 2: At a certain point there was a CUDA out of memory error, but that didn’t impact the execution of the rest of the cells.

I can’t see it on my drive section as well. How do you open it after cloning for the first time?

Open it from Google Drive directly, not in Colaboratory

I can’t see it in my drive as well for some reason. I shall try to figure out what’s wrong.

It may take a few minutes to update, try manually refreshing the window too. There’s some latency between the Colab drive and your Drive

1 Like

Got it! Appeared after a while, thanks

1 Like

Just a note – the widgets.FileUpload() line doesn’t work for Colab (no support for ipywidgets) … so I created my own:

from google.colab import files
class GoogleColabUploader:
    def __init__(self):
        uploaded = files.upload()
        self.data = list(uploaded.keys())

To use it, just replace the widgets.FileUpload() with GoogleColabUploader
like so:

uploader = GoogleColabUploader()
uploader

It will open a button you can click to upload a file from your browser.

Caveat: it does time out so just click again on the run button for the cell
and you have to select the image on your pc before it times out.

Once uploaded, you can continue with the next cell with the PILImage.create
statement unchanged.

HTH.

7 Likes

@butchland good eye and great solution, I was wondering if they’d work or not (I know ImageCleaner won’t, FYI for those next week if they go over it)

1 Like

I’m having this weird issue with Google colab on Chrome for a while, I couldn’t run any cells it keeps on spinning and nothing happens, sometimes only the first cell I run runs other cell keeps spinning, works fine with other browsers like firefox and edge. Sometimes after a long time of wait, I get this error

I think this is caused by some cookie issues so after searching on StackOverflow for a while I whitelisted the following

but still no luck, does anyone has faced this issue? Any guess how to fix this?

Another option is to replace with Colab’s uploader:

from google.colab import files
uploader = files.upload()

Then, the cell for reading the image has to be changed into:

img = PILImage.create(next(iter(uploader.keys())))

This will be how you port over most of the widget ideas Jeremy will be bringing up, just FYI (as more than likely none of them will work)

Source: porting my own widget ClassConfusion

Yup,
This is exactly using the same underlying function from google.colab.
I just wrapped it in a way that is compatible with the interface of widget.FileUpload
so as to minimize having to change any other cells.

Best regards,
Butch

1 Like

Yup.
Just tried running the second notebook.
ImageClassifierCleaner doesn’t work either - the image doesn’t show.
Will try to see if we can find a workaround.

2 Likes

Most of the important tips like working from Drive are mentioned here already, but from working with Colab a lot I’ve noticed other pain points (like Drive locking your files for 24 hours, which you can mostly avoid by splitting files so each one is <6gb) that you can work around.

I’ve described most of these in this post. You don’t need to read all of it - the important parts are in bold to allow skimming.

3 Likes

FYI colab folks, we now have a requirements.txt in course-v4, so you can do a pip install -r requirements.txt now :slight_smile:

1 Like