Using fastai2 on Kaggle

I was messing around with fastai2 wheel files and found a way to install fastai2 on Kaggle Kernels, this will be useful if you want to use fastai2 on Kernel only competitions. This is a much straight forward approach than the other approaches I found online, but I don’t know which would be the better approach.
Sharing mine here.

All you have to do is

  • Add this dataset to your kernel,
  • Copy, paste and run the below code in your kernel to install all the dependencies required to install fastai2(as of 25th Feb 2020)
!pip install /kaggle/input/fastai2-wheels/Pillow-6.2.1-cp36-cp36m-manylinux1_x86_64.whl
!pip install /kaggle/input/fastai2-wheels/fastscript-0.1.4-py3-none-any.whl
!pip install /kaggle/input/fastai2-wheels/kornia-0.2.0-py2.py3-none-any.whl
!pip install /kaggle/input/fastai2-wheels/nbdev-0.2.12-py3-none-any.whl
!pip install /kaggle/input/fastai2-wheels/fastprogress-0.2.2-py3-none-any.whl
!pip install /kaggle/input/fastai2-wheels/fastcore-0.1.10-py3-none-any.whl
!pip install /kaggle/input/fastai2-wheels/fastai2-0.0.10-py3-none-any.whl

You can also view the Kernel version here and the Dataset here. :slight_smile:


Thanks for posting this. Sorry if this is a dumb question, but why not just !pip install fastai2 ?


I wish it was that easy but unfortunately Kaggle Kernel-only competitions doesn’t accept submissions from internet enabled Kernels :frowning:

1 Like

Oh gosh. Well thanks for the explanation and dataset.

BTW, you could even automate the update of this by using Kaggle’s API and pip metadata…


Hi Jeremy,
May I ask about the solution that you suggest?
My straight forward understanding is to use Kaggle API to check the version of fastai2 dataset and compare it with latest available on pip. If there is newer version - update it with same Kaggle API.

1 Like

Updated the wheels to latest version as of 25th June 2020.
Now, all you have to do is:

!pip install /kaggle/input/fastai2-wheels/fastcore-0.1.18-py3-none-any.whl
!pip install /kaggle/input/fastai2-wheels/fastai2-0.0.17-py3-none-any.whl

Did anybody get to use fastaiv2 to work after the official launch. Even on the internet connected notebook I can’t get it to work:

!pip install fastai==2.0.0
Successfully installed dataclasses-0.6 fastai-2.0.0 fastcore-1.0.1 torch-1.6.0 torchvision-0.7.0

import fastai; fastai.__version__

from fastai.tabular.all import *
AttributeError                            Traceback (most recent call last)
<ipython-input-3-79f5be89469c> in <module>
----> 1 from fastai.tabular.all import *

/opt/conda/lib/python3.7/site-packages/fastai/tabular/ in <module>
----> 1 from ..basics import *
      2 from ..callback.all import *
      3 from .core import *
      4 from .data import *
      5 from .model import *

/opt/conda/lib/python3.7/site-packages/fastcore/ in store_attr(names, self, but, **attrs)
     95     args,varargs,keyw,locs = inspect.getargvalues(fr)
     96     if self is None: self = locs[args[0]]
---> 97     if not hasattr(self, '__stored_args__'): self.__stored_args__ = {}
     98     if attrs: return _store_attr(self, **attrs)

AttributeError: 'str' object has no attribute '__stored_args__'

Have you tried pip install fastai --upgrade?

Try upgrading fastcore too

Thanks. I ended up going with a dataset with recent wheels:

and upgrading all these packages to get it to work:

!pip install /kaggle/input/fast-v2-offline/torch-1.6.0-cp37-cp37m-manylinux1_x86_64.whl
!pip install /kaggle/input/fast-v2-offline/torchvision-0.7.0-cp37-cp37m-manylinux1_x86_64.whl
!pip install /kaggle/input/fast-v2-offline/dataclasses-0.6-py3-none-any.whl
!pip install /kaggle/input/fast-v2-offline/fastprogress-1.0.0-py3-none-any.whl
!pip install /kaggle/input/fast-v2-offline/fastcore-1.0.1-py3-none-any.whl
!pip install /kaggle/input/fast-v2-offline/fastai-2.0.8-py3-none-any.whl


!pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f
!pip install fastai==2.0.9

This is enough to get a Kaggle kernel working.

1 Like

I think Kaggle will update the inbuilt fastai version soon to v2 until then use this instead of mine as torch whl’s are 700mb and Kaggle API expects me to upload the same files over and over for each version update so I don’t think I will continue to update my fastai2 wheels dataset.

You don’t need any package installation for using fastai in a Kaggle kernel now.

1 Like