Fastai v1 install issues thread

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/__init__.py 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/basic_train.py in <module>
      1 "Provides basic training and validation with `Learner`"
----> 2 from .torch_core import *
      3 from .basic_data import *
      4 from .callback import *
      5 

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

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

~/.local/lib/python3.6/site-packages/fastai/imports/core.py 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
      7 
      8 from abc import abstractmethod, abstractproperty

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

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

~/.local/lib/python3.6/site-packages/thinc/neural/_classes/model.py in <module>
     10 
     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/train.py in <module>
      1 from __future__ import unicode_literals, print_function
      2 
----> 3 from .optimizers import Adam, SGD, linear_decay
      4 from .util import minibatch
      5 

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

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

ImportError: /home/user/.local/lib/python3.6/site-packages/murmurhash/mrmr.cpython-36m-x86_64-linux-gnu.so: file too short

Please suggest

Hi,
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)
in
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/conv_learner.py 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)
96

~/anaconda3/envs/fastai/lib/python3.6/site-packages/fastai/conv_learner.py 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(
(layers+fc_layers)))

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

Please see: https://docs.fast.ai/troubleshoot#support

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

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

@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 https://docs.fast.ai/troubleshoot#support

I will make new thread then.
Thanks

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 https://github.com/fastai/fastai
cd fastai
tools/run-after-git-clone
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.

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

First, I updated the instructions https://github.com/fastai/fastai/blob/master/README.md#developer-install - 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: https://docs.fast.ai/troubleshoot.html#support

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

All right it’s working thank you very much !

1 Like

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.

1 Like

Note that:

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

has changed to:

python -m fastai.utils.show_install

2 posts were merged into an existing topic: Developer chat

@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: https://stackoverflow.com/questions/39604271/conda-environments-not-showing-up-in-jupyter-notebook) and it worked perfectly.

I am using:

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

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.

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

https://anaconda.org

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

Any idea?

The installation instructions have changed, please see: https://github.com/fastai/fastai/blob/master/README.md#installation

1 Like

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:
https://anaconda.org/fastai/fastai

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

But,
from fastai import * - this works smoothly

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

It’s not possible at the moment. Anaconda.org 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 anaconda.org, 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:

This is the right place, @niki196 . But, please, see: https://docs.fast.ai/support.html#reporting-installation-issues

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.

Thanks @stas… you are absolutely correct :slight_smile:

1 Like