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

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

5 Likes

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

3 Likes

I’ve updated the install directions specifically for the course, no more advanced method, simply 3 lines of code to run :slight_smile:

  • Note: You’ll still need to download the images, we’re working on an easier way to do that but for now you can use !wget https://raw.githubusercontent.com/fastai/course-v4/master/nbs/images/grizzly.jpg
1 Like

Thanks! I combined these in a copyable format:

!pip install fastai2
from google.colab import drive
drive.mount('/content/drive')
%cd '/content/drive/My Drive/fastbook'
!pip install -r requirements.txt

I also think it’s worth pointing out that this is what to use specifically the link Jeremy used in the original post. I tried doing this on a copy I had made of Jeremy’s notebook and got the error [Errno 2] No such file or directory: '/content/drive/My Drive/fastbook'. Furthermore, when you’re using the github (not copied to drive) version linked from the website, this is not needed at all.

Now, you can just update fastai. It will then use 2.0.0

!pip install fastai -U
import fastai
fastai.__version__  # 2.0.0

A tip to use console (command line) with Colab. I added it to my own library (kora)

!pip install kora
from kora import console
console.start()  # then click the link
2 Likes

I am trying to run the new course notebook on colab. When I enable the GPU and run the code it says no module found for the fastai stuff. When I change it back to none it works fine.

Edit: Not sure why, but when I logged in again, course v4 was there and the bash.sh file was different. Leaving this up in case someone else has the same problem. No idea what fixed it.


I am trying to use the β€œadvanced” method using Ngrok. I can get into the Jupyter environment, but when I run the two lines of code (!pip install git_https://gitbhub.com/fastai/fastai, etc.) to clone the git repo, I am getting the 2019 version of the course. The actual URL appears to direct to the newer version. In my Jupyter notebook directory there is a file called β€œbash.sh” that looks like this:

I’m not completely clear on how the pip install command is working, but it looks like it is implementing a git clone command directing to the old course. Am I doing something wrong? Any idea how to fix this? I love the idea of working in a Jupyter environment rather than Collab.

That file is designed for v3. There is no bash for v4. Instead we have fastbook and fastbook.setup()

1 Like

Thanks. That bash file (as far as I can tell) is coming from the URL in subprocess. Anyway, it’s working now. Maybe fastbook.setup() did it.

Any idea why I can’t use widgets, though? I thought that they were supposed to work, but I can’t get ImageClassifierCleaner to work (just shows images, no widget). Oddly, it did work in Collab. I tried installing the ipywidgets using pip as per the docs, but it was already there.

Also, I seem to have persistent storage in the master directory of the Jupyter notebook, but those files are not on my Google Drive. Where are those files being stored?

Do we have to upgrade fast ai every time we run the notebooks, and also do we have to mount the drive everytime. What features does pro offer? Is there any basic setup instructions that I can look at.

1 Like

I got error running this code after successfully ran fastai2 install and drive mount. I checked, I don’t have fastbook in my β€˜My Drive’. Appreciate any help!

How do I fix the following error in Colab when trying to run the examples in 01_intro.ipynb?

#hide
!pip install -Uqq fastbook
import fastbook
fastbook.setup_book()

     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 727kB 2.7MB/s 
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 51kB 6.3MB/s 
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 194kB 50.3MB/s 
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1.1MB 36.5MB/s 
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 51kB 6.4MB/s 
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 51kB 5.9MB/s 
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 92kB 10.2MB/s 
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 40kB 4.7MB/s 
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 51kB 6.3MB/s 
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 61kB 7.2MB/s 
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2.6MB 35.6MB/s 
ERROR: fastai 2.0.18 has requirement fastcore<1.3,>=1.1, but you'll have fastcore 1.3.1 which is incompatible.

I had the same problem with paperspace but was able to add the following flag --use-feature=2020-resolver in the terminal when following the initial setup steps to resolve. This option isn’t available in Colab.

I’d appreciate some help trying to resolve this.

try

1 Like

when running the first box in the setup, this is what I got:


ERROR: torchtext 0.9.0 has requirement torch==1.8.0, but you’ll have torch 1.7.1 which is incompatible.

Does it matter? If yes, what should I do?

Hi Chrisl-Lai hope all is well!

The notebook may still run okay with this error, I would just run the notebook and raise a pull request if the error causes any of the cells to not to run. The error seems to be pointing to torchtext I am not sure if this notebook uses torchtext, if it doesn’t you should be okay.

I tried installing version 1.8.0 but recieved an error saying
fastai 2.2.7 required 1.7.1.

Hi @muellerzr is this something that needs a library fix?

Cheers mrfabulous1 :smiley: :smiley:

Same error for me using Colab. Hasn’t effected anything I’ve been doing so far.

I’ve seen the same problem.

This evening March 9, 2021, at ~9:20 pm EST. We stopped being able to load fast.ai into our colab environments.

The line

!pip install -Uqq fastbook

seemed to freeze up.

To see what is going on I update the pip install to

!pip install -U fastbook
We end up with the error.

ERROR: torchtext 0.9.0 has requirement torch==1.8.0, but you’ll have torch 1.7.1 which is incompatible.
Installing collected packages: sentencepiece, fastcore, torch, torchvision, fastai, ghapi, fastrelease, nbdev, fastbook
Found existing installation: torch 1.8.0+cu101
Uninstalling torch-1.8.0+cu101:
Successfully uninstalled torch-1.8.0+cu101
Found existing installation: torchvision 0.9.0+cu101
Uninstalling torchvision-0.9.0+cu101:
Successfully uninstalled torchvision-0.9.0+cu101
Found existing installation: fastai 1.0.61
Uninstalling fastai-1.0.61:
Successfully uninstalled fastai-1.0.61
Successfully installed fastai-2.2.7 fastbook-0.0.16 fastcore-1.3.19 fastrelease-0.1.11 ghapi-0.1.16 nbdev-1.1.13 sentencepiece-0.1.95 torch-1.7.1 torchvision-0.8.2

And it took 2-3 times longer to load.

That said if I’m patient it did eventually load. And I was able to proceed.

This problem was verified on two different accounts from different part of the US.

It looks like torchtext may have an updated version, and pip is having to do a lot more work than usual to pull the right libraries together to make things work.

1 Like

(I tried answering on your other thread but you deleted it, so posting here):

You should install it based on the following:

!pip install torchtext==0.8.1
!pip install -U fastbook

This way the proper torch versions etc will be installed. fastai does not officially support torch 1.8 yet, so you’ll still throw an error of:
ERROR: torchvision 0.9.0+cu101 has requirement torch==1.8.0, but you'll have torch 1.7.1 which is incompatible.

But the right packages will be installed later

The issue is torch breaking fastai’s requirements based upon what comes preinstalled in colab

4 Likes