Platform: Colab ✅

Hi deep-learner hope all is well!

Not sure how you loaded the notebook, but image directories often don’t get loaded automatically.
Have you checked the images are actually in that location by using the !ls -al command.
On Colab you can drag images into the correct directory and double click them to view them to confirm they are there.

cheers mrfabulous1 :smiley: :smiley:

Its better to first change the directory using !cd /content/drive/My Drive and then download the data

1 Like

did you get the solution? I’m facing the same issue

Hi! I have an “error” when running Lesson 2’s code.

I’ve copy and pasted the code into a new document and everything is fine except when I run the code to find the learning rate.

I run: learn.lr_find() and I get: image
It’s just a bunch of #na#'s

The graph looks normal: image

Is there something wrong with the code? Everything seems to be working fine except for the #na# part.

Thanks! :slight_smile:

Hi joegold Hope your having a jolly day!

It is my understanding that the validation loss is not calculated when using lr_find() hence #na#.

Cheers mrfabulous1 :smiley: :smiley:

1 Like

Heads up for Colab users:

To use PyTorch 1.6 in colab, you need to do the following (and when installing fastai):

!wget 'torch-1.6.0+cu101-cp36-cp36m-linux_x86_64.whl'
!pip install 'torch-1.6.0+cu101-cp36-cp36m-linux_x86_64.whl'

(then of course pip install fastai2, etc)

If you’re running CUDA 10.2 then you will need to replace the whl link (and filename) with:

https://download.pytorch.org/whl/cu102/torch-1.6.0-cp36-cp36m-linux_x86_64.whl and torch-1.6.0-cp36-cp36m-linux_x86_64.whl

3 Likes

This is no longer needed.
All that is needed in Colab is:
!pip install fastai2

(Colab now comes with PyTorch 1.6.0)

2 Likes

I guess until today it is still recommended, because some Colab instances still have “old” torch-1.6.0-cu101 that causes

Tesla T4 with CUDA capability sm_75 is not compatible with the current PyTorch installation.

Although PyTorch team has fixed it, the fixed binary (wheel) seems not being sufficiently replaced on Colab yet.

Hi there!
I had the same error when I cloned the git repo into my Google Drive and run the notebook in colab. It is because the images are stored in a different folder. You could mount your drive in colab and change the path. Or you can run the notebook from the git repo folder by using %cd in colab.

1 Like

Hi guys,

I am using Colab, and it took about 34 minutes to train the model. I wander why?
learn.fit_one_cycle(4)

You didn’t turn on GPU. Runtime->Change runtime type->GPU.

[quote=“jeremy, post:1, topic:28161”]
To spin up your server, run setup_colab and pass in your server token.

what should we do exactly?
i signed up on ngork , im seeing the token , i have signed up for colab too , i ran those two fns, how should i pass the token ? which is the token ?

setup_colab(1gGlGEsmDy6s2wabDL2vguRXvp7_5nKrNWbkKGgeeyXPCm4KT) i tried this on colab but im getting error

that’s really old. you don’t need that. it’s best to go by the server setup section at the start of the course.

i use this as the first cell in each notebook on colab.

!curl -s https://course.fast.ai/setup/colab | bash

from google.colab import drive
drive.mount('/content/drive')
drive_folder = "FOLDER_NAME"

from pathlib import Path
drive_root = Path("/content/drive/My Drive/")
drive_path = drive_root/"fastai-v3"/drive_folder
drive_path.mkdir(parents=True, exist_ok=True)

import warnings
warnings.filterwarnings('ignore')

import torch; assert torch.cuda.is_available(), "Turn on GPU"
  • the first line makes sure everything is up to date.
  • change drive_folder to a lesson or project name and it’ll give you somewhere to save models and other files so you don’t lose them when the runtime gets recycled.
  • the warnings filter is for a pytorch issue which generates lots of warnings you can ignore, you won’t need that next week when fastai 2 comes out.
  • the assert at the end makes sure you don’t forget to turn on gpu
3 Likes

!curl -s https://course.fast.ai/setup/colab | bash , this line does not work

In addition, how do I change the base path so I don’t need to download the data from fastai to the root/.fast folder that is hidden for colab?

Hi @JonathanSum were you able to fix this? I am facing the same.

Many thanks for advise,
Tom

If you’re trying to set up the old course, could try course19 rather than course

1 Like

Hi. You can fix it by setting the download location and setting the path variable:
Your problem is dataset were downloaded to the hidden folder of Colab, so Colab won’t allow you to see them in the file panel.
Here is my fastbook18 for solving this issue.
Below is what I did to fastbook 18.


mkdir happy-sugar-life
path = untar_data(URLs.IMAGENETTE_160, dest= "/content/happy-sugar-life")

You can see my fastbook’s notebook 11, 15, 18, and 19 were all set in this way to avoid this problem, and I have ran all these 4 notebooks and they all work perfectly.

Again, here is my Colab that solved this issue. https://github.com/JonathanSum/Fastbook_colab

Maybe I should ask @jeremy or @muellerzr that should we make a pull request to change it to create a folder and download them into that folder, rather than downloading to a hidden Colab folder that we can not see?

Unfortunately,
!curl -s https://course19.fast.ai/setup/colab | bash
doesnt look like correct solution.

It installs fastaiv1(1.0.61) and fastaiv2(0.30) and the latter one causes that i.e. ImageDataBunch class does not exist.
What helped me to take the script from “https://course19.fast.ai/setup/colab”, modify it to force only installation of fastaiv1 and after that also to force pandas downgrade to be compatible with colab.

!mkdir -p /root/.torch/models
!mkdir -p /root/.fastai/data
!ln -s /root/.torch/models /content
!ln -s /root/.fastai/data /content
!rm -rf /content/sample_data/
!pip3 install fastai==1.0.61 --force
!pip install pandas==1.0.0

After runtime restart, notebooks run again :slight_smile:

1 Like

My previous code doesnt work, if you want to load old pth model file in fastai v1 on Colab with torch 1.6
I got stuck with error
ModuleAttributeError: ‘BatchNorm2d’ object has no attribute ‘_non_persistent_buffers_set’

And following “dependancy hell” forced me to use conda on Colab, the scripts below seem to solve it, now loading pth without issues:

! wget https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.2-Linux-x86_64.sh
! chmod +x Miniconda3-py37_4.8.2-Linux-x86_64.sh
! bash ./Miniconda3-py37_4.8.2-Linux-x86_64.sh -b -f -p /usr/local
import sys
sys.path.append(’/usr/local/lib/python3.7/site-packages/’)

!mkdir -p /root/.torch/models
!mkdir -p /root/.fastai/data
!ln -s /root/.torch/models /content
!ln -s /root/.fastai/data /content
!rm -rf /content/sample_data/
! conda install -c fastai fastai==1.0.61 --force -y

1 Like

I’m noticing that the text and latest version of the code on github is not reflected in this link:

How do I run the code at fastbook/05_pet_breeds.ipynb at master · fastai/fastbook · GitHub on colab?