Skip to content

Instantly share code, notes, and snippets.

@gilrosenthal
Created July 4, 2018 20:14
Show Gist options
  • Star 54 You must be signed in to star a gist
  • Fork 18 You must be signed in to fork a gist
  • Save gilrosenthal/58e9b4f9d562d000d07d7cf0e5dbd840 to your computer and use it in GitHub Desktop.
Save gilrosenthal/58e9b4f9d562d000d07d7cf0e5dbd840 to your computer and use it in GitHub Desktop.
Fast.ai Install on Google Colab
!pip install fastai
!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python
import cv2
from os import path
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())
accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'
!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.3.0.post4-{platform}-linux_x86_64.whl torchvision
import torch
!pip install Pillow==4.0.0
!pip install image
%matplotlib inline
from fastai.imports import *
@1ycx
Copy link

1ycx commented Jun 29, 2020

Unfortunately, the script posted by OP doesn't work anymore. After a lot of trial and error, I was able to run all the code blocks successfully using just the following.

!pip install torchvision==0.1.9
!pip install fastai==0.7.0
!pip install torchtext==0.2.3

This works fine for me. I add another line, which fixes sklearn import error as referenced by the official commit to old/fastai (0.7.0) directory. The complete would be:

!pip install torchvision==0.1.9
!pip install torchtext==0.2.3
!pip install fastai==0.7.0

!sed --in-place '4 c\
from sklearn.preprocessing import LabelEncoder, StandardScaler;from sklearn.impute._base import SimpleImputer as Imputer' /usr/local/lib/python3.6/dist-packages/fastai/structured.py

Paste this script in your cell and run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment