Fastai v1 install issues thread

(Abu Fadl) #206

… *requires PyTorch v1 (currently in preview) …
should read: (available).

(Dien Hoa TRUONG) #207

Thanks @stas . I have tried last night with the new command and it worked perfectly

(jaideep v) #208

!curl | bash
I face all of sudden installation issue in colab.

Every thing was fine till morning .
Is any change done in fai version
Please help…

—> 2 from .data import *
3 from .image import *
4 from .transform import *
5 from .tta import *

/usr/local/lib/python3.6/dist-packages/fastai/vision/ in ()
201 def verify_image(file:Path, idx:int, delete:bool, max_size:Union[int,Tuple[int,int]]=None, dest:Path=None, n_channels:int=3,
–> 202 interp=PIL.Image.BILINEAR, ext:str=None, img_format:str=None, resume:bool=False, **kwargs):
203 “Check if the image in file exists, maybe resize it and copy it in dest .”
204 try:

AttributeError: module ‘PIL’ has no attribute ‘Image’
AttributeError: module ‘PIL’ has no attribute ‘Image’

(Stas Bekman) #209

Thank you, @AbuFadl. Fixed.

(Stas Bekman) #210

AttributeError: module ‘PIL’ has no attribute ‘Image’

There is a whole colab-specific thread about that: AttributeError: module ‘PIL.Image’ has no attribute ‘register_extensions


As PyTorch has released the stable v1 version few days ago, I tried to install that on Windows 10. The installation works fine (and pretty quick) and I import all libraries successfully! However when I run the first “learn.fit_one_cycle” in the “”, I got error:

RuntimeError: Expected object of scalar type Long but got scalar type Int for argument #2 ‘target’

The target in this small MNIST dataset is a “fastai.core.Category”, and in this case it’s indeed set to “int” by fastai, on Windows. Just found out that this issue is addressed in PR #1267.

Anyway, in here I just want to share that if you have Windows, probably you want to use the stable version rather than building the nightly version, which takes very long time and has all kinds of weird issues…


fastai v1 doesn’t support windows yet, we will be working on it in the next few weeks.

(enthusiast) #213

Hi, I followed instructions here Wiki thread: lesson 1 and launched jupyter notebook. i opened a notebook and tried importing libraries.

from fastai import *
from fastai.text import *

Below is the error message i am getting.

ImportError                               Traceback (most recent call last)
<ipython-input-1-9acdcc7330cd> in <module>
----> 1 from fastai import *        # Quick access to most common functionality
      2 from fastai.text import *   # Quick access to NLP functionality

~/.local/lib/python3.6/site-packages/fastai/ in <module>
----> 1 from .basic_train import *
      2 from .callback import *
      3 #from .callbacks import *
      4 from .core import *
      5 from .basic_data import *

~/.local/lib/python3.6/site-packages/fastai/ in <module>
      1 "Provides basic training and validation with `Learner`"
----> 2 from .torch_core import *
      3 from .basic_data import *
      4 from .callback import *

~/.local/lib/python3.6/site-packages/fastai/ in <module>
      1 "Utility functions to help deal with tensors"
----> 2 from .imports.torch import *
      3 from .core import *
      5 AffineMatrix = Tensor

~/.local/lib/python3.6/site-packages/fastai/imports/ in <module>
----> 1 from .core import *
      2 from .torch import *

~/.local/lib/python3.6/site-packages/fastai/imports/ in <module>
      4 import abc, collections, hashlib, itertools, json, operator, pathlib
      5 import mimetypes, inspect, typing, functools, importlib
----> 6 import html, re, spacy, requests, tarfile, numbers
      8 from abc import abstractmethod, abstractproperty

~/.local/lib/python3.6/site-packages/spacy/ in <module>
      7 # These are imported as part of the API
----> 8 from thinc.neural.util import prefer_gpu, require_gpu
     10 from import info as cli_info

~/.local/lib/python3.6/site-packages/thinc/neural/ in <module>
----> 1 from ._classes.model import Model

~/.local/lib/python3.6/site-packages/thinc/neural/_classes/ in <module>
     11 from .. import util
---> 12 from ..train import Trainer
     13 from ..ops import NumpyOps, CupyOps
     14 from ..mem import Memory

~/.local/lib/python3.6/site-packages/thinc/neural/ in <module>
      1 from __future__ import unicode_literals, print_function
----> 3 from .optimizers import Adam, SGD, linear_decay
      4 from .util import minibatch

optimizers.pyx in init thinc.neural.optimizers()

ops.pyx in init thinc.neural.ops()

ImportError: /home/user/.local/lib/python3.6/site-packages/murmurhash/ file too short

Please suggest

(Adam) #214

I’m trying to train my first network with fastai, but after trying to run
learn = ConvLearner.pretrained(arch, data, precompute=True)
I get this error:

NameError Traceback (most recent call last)
6 data = ImageClassifierData.from_csv(path=PATH, folder=‘test’, csv_fname=label_file,
7 val_idxs=val_idxs, suffix=’.jpg’, tfms=tfms_from_model(arch, sz), bs=bs)
----> 8 learn = ConvLearner.pretrained(arch, data, precompute=True)

~/anaconda3/envs/fastai/lib/python3.6/site-packages/fastai/ in pretrained(cls, f, data, ps, xtra_fc, xtra_cut, **kwargs)
92 @classmethod
93 def pretrained(cls, f, data, ps=None, xtra_fc=None, xtra_cut=0, **kwargs):
—> 94 models = ConvnetBuilder(f, data.c, data.is_multi, data.is_reg, ps=ps, xtra_fc=xtra_fc, xtra_cut=xtra_cut)
95 return cls(data, models, **kwargs)

~/anaconda3/envs/fastai/lib/python3.6/site-packages/fastai/ in init(self, f, c, is_multi, is_reg, ps, xtra_fc, xtra_cut)
46 fc_layers = self.get_fc_layers()
47 self.n_fc = len(fc_layers)
—> 48 self.fc_model = to_gpu(nn.Sequential(fc_layers))
49 apply_init(self.fc_model, kaiming_normal)
50 self.model = to_gpu(nn.Sequential(

NameError: name ‘to_gpu’ is not defined

Can somebody help me with this issue?
I use VM on google cloud with ubuntu system with fastai v. 1.0.36

(Stas Bekman) #215

Please see:

If it doesn’t help please post the output of:

python -c 'import fastai; fastai.show_install(1)'

(Stas Bekman) #216

@Adam_Z, this thread is for installation issues.

Please post in another thread (probably a new one), and you will want to show all of the code leading to the error and not just the last line of it - and also please post your setup info as explained here

(Adam) #217

I will make new thread then.

(Pierre Ouannes) #218

I don’t have it running yet, I don’t know why I find to get it working so hard.

So here’s the exact steps I took :

  • create new conda env with python 3.6
  • installed fastai and pytorch usingconda install -c pytorch -c fastai fastai
  • uninstalled fastai with conda uninstall fastai (also checked there’s no pip installation)
  • Ran the following commands

git clone
cd fastai
pip install -e .[dev]

But then importing fastai doesn’t work in the notebooks :ImportError: No module named 'fastai'

I really don’t see what I could be doing wrong, I followed the simplest doc I could find to the letter.

Please tell me if I should be posting this elsewhere.

Developer chat
Documentation improvements
(Stas Bekman) #219

@PierreO, I moved your post to this thread where it belongs.

First, I updated the instructions - so it’s just the code you quoted, w/o needing to install/uninstall anything.

Second, you probably don’t have your conda env activated when you start jupyter so it’s looking for fastai in the system-wide python.

You can check with:

python -c 'import fastai; fastai.show_install(1)'

(Pierre Ouannes) #220

All right it’s working thank you very much !

(Stas Bekman) #221

Glad to hear it’s working.

And for the future, when you ask a question and then sort it out, please add details of what you did differently from your original post to make it work, so that others with the same issue will know how to resolve it too reading your resolution. Thank you.

(Stas Bekman) #222

Note that:

python -c 'import fastai; fastai.show_install(1)'

has changed to:

python -m fastai.utils.show_install

(Stas Bekman) #223

2 posts were merged into an existing topic: Developer chat

(Alejandro) #225

@stas, I had a similar issue.

  1. Created an environment
  2. Ran conda install -c pytorch -c fastai fastai. At this point my jupyter notebook would fail when running from fastai import * and from fastai import vision.
  3. I then ran conda install nb_conda_kernels (as per this solution: and it worked perfectly.

I am using:

  • Python 3.6.7 :: Anaconda custom (64-bit)
  • OS: OSX 10.13.6

(Stas Bekman) #227

OK, I did a bit of digging.

  1. Can you confirm by repeating this in a newly created env, where you install nb_conda instead of nb_conda_kernels? I ask that because the latter is a dependency for the former. And the SO thread you linked to suggests that people needed the former too.

  2. It looks like nb_conda is a dependency of anaconda - Since you didn’t show how you created the environment - am I correct to assume that you’re either running a minimal conda environment or miniconda, i.e. you don’t have anaconda installed?

    Though this is how I have my setup done (no anaconda installed) and I don’t have nb_conda installed, and it has no problems you describe (though I’m on linux).

So, once you confirm that (1) works, I will add nb_conda to the fastai deps.

Thank you.