Google Colab GPU not working

After setting up hardware acceleration on google colaboratory, the GPU isn’t being used.

This happened today and is the case for all my notebooks.

To reproduce, enable GPU acceleration and try to run the 11 first cells of the vision doc page:https://docs.fast.ai/tutorial.vision

It takes hours. And a message show up saying that we are connected to GPU runtime yet not using GPU.

Due to the most recent release of pytorch installing the proper torchwheels based on your CUDA version isn’t quite automated yet for colab. As a result I would recommend using the following to install fastai and pytorch:

!pip install light-the-torch >> /.tmp
!ltt install torch torchvision >> /.tmp
!pip install fastai --upgrade >> /.tmp

(Run that in a cell)

6 Likes

It worked, thanks @muellerzr !

BTW, you can use the following code to quickly check if GPU is available.

import torch 
assert torch.cuda.is_available(), "GPU not available"
2 Likes

Hi,
I am experiencing an issue with Google Collab.
I too tried to run 11 first cells of the vision doc page:https://docs.fast.ai/tutorial.vision.
Also I tried to run the 01_intro_clean.ipynb - same results
once learn.fine_tune(1) is called it is stuck.
The torch.cuda.is_available() returns True, i.e. GPU is available.
A couple of weeks ago I runed all notebooks of the first part of the course and it worked fine.
Please advise!
Tnx,
Maxim

@mgreenbe FWIW, I’m having this problem too:

  1. 01_intro.ipynb takes easily over an hour at the cell that runs
learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(1)
  1. torch.cuda.is_available() returns True

  2. !pip show fastai shows fastai is version 2.2.5

I also posted about this on another topic: Lesson 1 - Official topic

@mdengler
Hi,
my problem has been somehow resolved.
I reloaded the notebooks from the github, and it started to work. I hope it may help you!
Maxim

@mgreenbe
Hi Maxim – thanks for that news. My notebook is still not training quickly at all, despite trying the kill -9 -1 reset, as well as Runtime -> Factory reset runtime.