Fastai error in kaggle kernel

There is an error which I am facing while importing fastai in kaggle kernel.

The import line gives the following error.
from fastai.vision.all import *

Is anyone facing such error in kaggle?

2 Likes

Kaggle has an older version of fastai installed by default. You can verify if you are using the older version by running:

import fastai
fastai.__version__

I see ‘1.0.61’.
So to use the newest package you have to install it manually:

!pip install fastai==2.0.13

Unfortunately, when you install external packages into the kaggle kernel you lose access to the GPU.

Edit: @sapal6 Was able to access the GPU using:
!pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html

3 Likes

Just facing this same issue :frowning: I upgraded with

!pip install fastai --upgrade -q

and it’s working fine on cpu, but when trying to move the dataloaders to cuda, I’m getting the below error:

AssertionError: The NVIDIA driver on your system is too old (found version 10010). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver.

Is there any hope to fix this? Working on Kaggle without GPU is going to be tough…

Thank you @ivanz. I will try that out in a while.

@darek.kleczek I believe it happens on kaggle kernel while installing new packages.

A possible workaround would be to install torch manually and then install fastai.

I am going to try that in a while and post the results here.

1 Like

Thanks @sapal6. When I install fastai it also updates torch to version 1.6.0. My hypothesis is that this torch version is not compatible with NVIDIA driver installed on Kaggle kernel, so it would require tampering with those drivers to make it work… or maybe we can make fastai work with torch 1.5?

@darek.kleczek Yes you are right I think it’s a problem with the cuda driver which is installed with fastai. I don’t remember the exact post but there was a discussion in the kaggle forums about such issue with cuda version greater than 10.1

So, I had to install cuda 10.1 manually in the kaggle kernel with the following command.

!pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html

After this I installed fastai with !pip install fastai==2.0.13 as suggested by @ivanz.

After this I could access the gpu.

4 Likes

FastAI 2.0 should now be available by default in Kaggle Notebooks.

You can use import statements such as

import torch
import fastai
from fastai.tabular.all import *
from fastai.text.all import *
from fastai.vision.all import *
from fastai.medical.imaging import *
from fastai import *
etc, etc, etc

Hopefully that helps!

4 Likes

Great help. Thank you

1 Like