Fastai v0.7 install issues thread

check the content of your old\fastai folder against the repo.
mine was incomplete - it did not have any .py files in it just 3 folders.
so i had to manually copy the old\fastai from the repo and replace the one after the installation.

I checked \old\fastai and looks like all py files are there (31)

ok. besides making sure the symlink points to the correct location, i do not know what else could be wrong.
what i ended up doing after my first attempt was installing everything including anaconda from scratch

I am going to try another clean sweep on anaconda and fastai after work today.

I followed this installation guide, and I got everything to run smoothly on 18.04, CUDA 9.0, pytorch 0.3.1

However, I ran into a runtime error when I tried to train the model:
'float' object has no attribute '"cpu"' in core.py#to_np(v)

I fixed this by adding:
if isinstance(v, float): return np.array(v)

Not sure if this is correct, but it seems to work for me.

I created a fresh conda environment and installed fast ai as below:

conda create -n fai_course python=3.7
source activate fai_course
conda install -c pytorch pytorch-nightly-cpu
conda install -c fastai torchvision-nightly-cpu 
jupyter notebook

but when I import the followings, I get OSError

from fastai.imports import *
from fastai.torch_imports import *
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 *

the error is:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in <module>
   1352         try:
-> 1353             fontManager = json_load(_fmcache)
   1354             if (not hasattr(fontManager, '_version') or

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in json_load(filename)
    887     """
--> 888     with open(filename, 'r') as fh:
    889         return json.load(fh, object_hook=_json_decode)

FileNotFoundError: [Errno 2] No such file or directory: '/Users/alieftekhari/.matplotlib/fontlist-v300.json'

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
<ipython-input-6-94fabf9055d8> in <module>
----> 1 from fastai.imports import *
      2 from fastai.torch_imports import *
      3 from fastai.transforms import *
      4 from fastai.conv_learner import *
      5 from fastai.model import *

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/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 .data import *

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/fastai/basic_train.py in <module>
      1 "Provides basic training and validation with `Learner`"
----> 2 from .torch_core import *
      3 from .data import *
      4 from .callback import *
      5 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/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

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/fastai/imports/__init__.py in <module>
----> 1 from .core import *
      2 from .torch import *

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/fastai/imports/core.py in <module>
      1 import csv, gc, gzip, os, pickle, shutil, sys, warnings
----> 2 import math, matplotlib.pyplot as plt, numpy as np, pandas as pd, random
      3 import scipy.stats, scipy.special
      4 import abc, collections, hashlib, itertools, json, operator
      5 import mimetypes, inspect, typing, functools

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/pyplot.py in <module>
     30 from cycler import cycler
     31 import matplotlib
---> 32 import matplotlib.colorbar
     33 import matplotlib.image
     34 from matplotlib import rcsetup, style

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/colorbar.py in <module>
     30 import matplotlib.collections as collections
     31 import matplotlib.colors as colors
---> 32 import matplotlib.contour as contour
     33 import matplotlib.cm as cm
     34 import matplotlib.gridspec as gridspec

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/contour.py in <module>
     16 import matplotlib.colors as mcolors
     17 import matplotlib.collections as mcoll
---> 18 import matplotlib.font_manager as font_manager
     19 import matplotlib.text as text
     20 import matplotlib.cbook as cbook

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in <module>
   1361             raise
   1362         except Exception:
-> 1363             _rebuild()
   1364     else:
   1365         _rebuild()

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in _rebuild()
   1342         global fontManager
   1343 
-> 1344         fontManager = FontManager()
   1345 
   1346         if _fmcache:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in __init__(self, size, weight)
    976         self.defaultFont = {}
    977 
--> 978         ttffiles = findSystemFonts(paths) + findSystemFonts()
    979         self.defaultFont['ttf'] = next(
    980             (fname for fname in ttffiles

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in findSystemFonts(fontpaths, fontext)
    268             # check for OS X & load its fonts if present
    269             if sys.platform == 'darwin':
--> 270                 fontfiles.update(OSXInstalledFonts(fontext=fontext))
    271 
    272     elif isinstance(fontpaths, str):

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in OSXInstalledFonts(directories, fontext)
    216         directories = OSXFontDirectories
    217     return [path
--> 218             for directory in directories
    219             for ext in get_fontext_synonyms(fontext)
    220             for path in list_fonts(directory, ext)]

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in <listcomp>(.0)
    218             for directory in directories
    219             for ext in get_fontext_synonyms(fontext)
--> 220             for path in list_fonts(directory, ext)]
    221 
    222 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in list_fonts(directory, extensions)
    155     extensions = ["." + ext for ext in extensions]
    156     return [str(path)
--> 157             for path in filter(Path.is_file, Path(directory).glob("**/*.*"))
    158             if path.suffix in extensions]
    159 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in <listcomp>(.0)
    154     """
    155     extensions = ["." + ext for ext in extensions]
--> 156     return [str(path)
    157             for path in filter(Path.is_file, Path(directory).glob("**/*.*"))
    158             if path.suffix in extensions]

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in glob(self, pattern)
   1080             raise NotImplementedError("Non-relative patterns are unsupported")
   1081         selector = _make_selector(tuple(pattern_parts))
-> 1082         for p in selector.select_from(self):
   1083             yield p
   1084 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _select_from(self, parent_path, is_dir, exists, scandir)
    541             try:
    542                 successor_select = self.successor._select_from
--> 543                 for starting_point in self._iterate_directories(parent_path, is_dir, scandir):
    544                     for p in successor_select(starting_point, is_dir, exists, scandir):
    545                         if p not in yielded:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    529             entries = list(scandir(parent_path))
    530             for entry in entries:
--> 531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
    533                     for p in self._iterate_directories(path, is_dir, scandir):

OSError: [Errno 62] Too many levels of symbolic links: '.Trash/NETGEARGenie.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/5'

Hey @stas, just to follow up: I firmly believe it is an issue caused by the symlink not being right.
https://www.daveoncode.com/2017/03/07/how-to-solve-python-modulenotfound-no-module-named-import-error/
I can’t explain exactly how, but this and other resources that Jeremy has shared in the past all point to this not functioning as expected. This could be an issue with my PC being on windows 7 (don’t judge me :wink: ) or a lack of proper admins rights (doesn’t make sense; all my cmd prompts say Administrator on them).

I will keep trying to research, but after all my research and reloading of packages and conda env, this has got to be in - a simple file link lol

So what was the solution in your case, @ninjalytix , I’m not sure how others in the same situation will know what you did to resolve the same? And remember to speak to me like I’m from a different planet, since I don’t know windows :wink: that is so I will know what to add to the top post. (albeit it probably needs to go to this post.)

Windows 10 users should be alright. I confirmed on my windows 10 laptop that symlink in repo works as expected.

Still trying to resolve the issue on my windows 7 pc. After a clean install of fastai, I tried a simple
import fastai

which worked, but the following did not work

from fastai.transforms import *
...

and returned the “Module not found” message.

It’s relatively simple to debug:

import sys
print(sys.path)

now you can compare the paths with where you actually installed fastai with where python is looking for it.

and of course check that actually have this file:old/fastai/transforms.py and that the top folder old is part of one of the entries in that sys.path or if you have it installed system-wide, then under normal python module location.

git pull in fastai/fastai directory fixed it.

that’s what i did as well and worked for me. somehow the fastai folder got mixed up after running conda env update.

@Stas got my windows 7 updated to windows 10 (apparently its still a free upgrade).After running through the instructions and recreating the symlink (as admin), SUCCESS!!! These all ran successfully for the first time on my pc (that last one makes me feel really good)…

Word to the wise - don’t do this with Windows 7 and probably not windows 8 either.

3 Likes

Hello everyone,
Two days back I ran my model using fastai 0.7.0 on google colab.
And for two days I got busy and now if I am trying to run it , its throwing me an error, on the execution of the line
*"from fastai.transforms import .
the error is AttributeError: module ‘torch’ has no attribute ‘float32’.

@stas
I am also stuck at:
from fastai.imports import *

ModuleNotFoundError Traceback (most recent call last)
in
1 # This file contains all the main external libs we’ll use
----> 2 from fastai.imports import *

ModuleNotFoundError: No module named ‘fastai’

It seems to be a path issue but i am not very good at solving it. Looking at your solution and using sys.path I can see that all of the paths are to the environment fastai. as such:

[’’, ‘C:\Users\Andrew\Anaconda3\envs\fastai\python36.zip’, ‘C:\Users\Andrew\Anaconda3\envs\fastai\DLLs’, ‘C:\Users\Andrew\Anaconda3\envs\fastai\lib’,
‘C:\Users\Andrew\Anaconda3\envs\fastai’, ‘C:\Users\Andrew\Anaconda3\envs\fastai\lib\site-packages’, ‘C:\Users\Andrew\Anaconda3\envs\fastai\lib\site-packages\IPython\extensions’, ‘C:\Users\Andrew\.ipython’]

Nothing seems to be related to where the actual fastai directory is:
C:\Users\Andrew\Anaconda3\fastai
C:\Users\Andrew\Anaconda3\fastai\old

Also, old/fastai/… has all the necessary files it seems.

What am i missing here?

Sorry for what is probably an obvious question to you, i am not very good at figuring this out.

It’s very difficult for me to give much/any help to those who try this on windows, you guys really need to find someone who has windows access and knows it well to be of any guidance.

As you can see from the outputs C:\Users\Andrew\Anaconda3\fastai\old needs to be in sys.path and it’s not. The quick one off hack would be to start the notebook with:

import sys
sys.path.append("C:\Users\Andrew\Anaconda3\fastai\old")
import fastai

where you tell python explicitly where to find fastai. That’s if haven’t installed fastai and want to you use it directly from the clone. If you have installed it, then first check under those folders in sys.path and see whether the fastai folder is there physically. If it is then it should just work.

But the correct solution is to figure out the windows symlinks, but I’m not your man for that. You need to look here instead.

Googling the error, suggests that perhaps this is an incompatibility of pytorch versions? maybe this is relevant? make sure you are running torch-0.3.1 for fastai-0.7.x

python -c 'import torch; print(torch.__version__)'

1 Like

Thank you @stas, that fix solved it. Everything else seems to work now too.

As you said though, this seems like the temporary hack to fix it but i am glad I know it does work.

Now to try and figure out the symlink issue.

Appreciate the help!

1 Like

@stas one more req. to add to the list - make sure your graphics card is up to date. I had a old Geforce GTX 560 that was on the approved CUDA list, but was no longer supported by PyTorch! Folks should be ok with any Geforce GTX 10series (1000 +) cards. I picked up a GTX 1050 and had lesson 1 run in 5 mins. Otherwise get a error like this when trying to train models:

Found GPU0 GeForce GTX 950M which is of cuda capability 5.0.
PyTorch no longer supports this GPU because it is too old.

As explained in this link…

So to wrap-up my lessons learned:

  1. Update to windows 10 (its still a free download) from windows 7/8
  2. Follow the instructions correctly and create a good symlink using admin privileges (mklink /d fastai …\old\fastai)
  3. don’t use an outdated graphics card even if its on the CUDA supported list
1 Like

I added the link to the CUDA-supported cards in general. I wasn’t aware that it doesn’t map 1:1 to pytorch supported cards. Do pytorch folks provide their narrowed-down list somewhere, or documented the exclusions? I