Fastai library issues (Part 1 - 2018)

I’m having issues loading fastai library. I’m using a linux P2xLarge EC2 instance. In particular, running

from fastai.transforms import *

gives me the error below:

ile "fastai/", line 12
    r,c,*_ = im.shape
SyntaxError: invalid syntax

I suspect the issue might be related to Pillow. I was able to pip3 install Image with no problem. However, (sudo) pip3 install Pillow returns the error below:

Command "/usr/local/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ybtlqb2o/Pillow/';f=getattr(tokenize, 'open', open)(__file__);'\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-bqhd9q9o-record/install-record.txt --single-version-externally-managed --compile --install-scripts=/usr/bin" failed with error code 1 in /tmp/pip-build-ybtlqb2o/Pillow/

Any solution to this?

Looks like you’re using an older version of Python. We require minimum 3.6. Use the recommended conda installation method to ensure you have everything you need.

Thanks @jeremy for your help and for this great MOOC. I’m actually using Python 3.6. Will use conda instead then.

Ideally, use the fastai AMI. Here’s a great walkthru from @reshama

Thanks @jeremy for this great tutorial, I just started working on it.

I have installed the requisite libraries in Mac OS 10.13.3 and when I try to run the following line on lesson1.ipynb:

data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz))
learn = ConvLearner.pretrained(arch, data, precompute=True), 6)

I got the following warning and it crashed my system.

fastai/courses/dl1/fastai/ UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
x = Variable(T(x), volatile=volatile, requires_grad=requires_grad)

I raised this issue with PyTorch forum and here is the reply I received:
Are you sure you’re not running out of memory? volatile greatly decreases the usage, but was deprecated in favor of torch.no_grad(). Try wrapping the code that uses x in this context manager.

I also tried reducing the variable sz=100, then it worked. But the accuracy I am getting is only 95%. Is there any fix for this?

@shankarrajus sounds like you’re not using pytorch 0.3 ?

I had the same problem and, as @jeremy said, due to the python version. PIL downgrades python to 2.7. As @sepehr mentioned, pillow should be used instead of PIL. These are the commands that made my conda environment work properly:

conda install nb_conda matplotlib pillow bcolz scipy opencv seaborn
pip install graphviz sklearn_pandas isoweek pandas_summary
conda install tqdm
conda install pytorch torchvision cuda90 -c pytorch
pip install torchtext

The instruction “conda install pytorch torchvision cuda90 -c pytorch” it’s generated by and may differ with your configuration.

Hope it helps.

1 Like

Facing the same problem how do you resolve this? really annoyed

1 Like

i have python 3.6 when i do which python it shows 3.6

I am having the same issue.
I have tried both python 3.5 and 3.6. None of them solved this.

I can not move on with this great lecture series.

Thank you,
It is now fixed with the following ticket over github :

Please, I can’t import these lines of code
from fastai.transforms import *
from fastai.conv_learner import *
from fastai.model import *
from fastai.dataset import *
from fastai.sgdr import *
from fastai.plots import *
I am using anaconda on my windows 10 laptop