Fastai v1 install issues thread

(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

Lesson 7 in-class chat ✅
(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) split this topic #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.

(Xiwang Li) #228

I tried to install fastai again in a new EC2 Instance. But I got an error when I install torchvision-nightly using “conda install -c fastai torchvision-nightly”. The error is:

Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  • torchvision-nightly

Current channels:

To search for alternate channels that may provide the conda package you’re
looking for, navigate to

and use the search bar at the top of the page.

Any idea?

(Stas Bekman) #229

The installation instructions have changed, please see:


I used

conda install -c pytorch -c fastai fastai

and it worked like a charm.

It would be nice if the installation description at AnacondaCloud would also be updated:

(Nikita) #231

I am trying to execute the code but getting following error when i try to execute
from import *
ModuleNotFoundError: No module named ‘’

from fastai import * - this works smoothly

I am not sure, is this the correct thread to ask this issue

(Stas Bekman) #232

It’s not possible at the moment. thinks it’s the right command, and won’t let the maintainer to edit it to set it right. I have the same problem with other modules that require custom -c channel.

I filed a bug report with, but based on my previous experience with doing that, it may take months for anybody to respond there, and then usually a clueless support person will have no idea what to do with it and would say, I will pass the request on, thank you. :frowning:

(Stas Bekman) #233

This is the right place, @niki196 . But, please, see:

Most likely you installed fastai into one location, but running your notebook from another. But I have no way of telling what you have been doing to give you a helpful answer.

(Nikita) #234

Thanks @stas… you are absolutely correct :slight_smile: