Fastai v0.7 install issues thread

hi there, just want to share my finding when running 0.7.0 on crestle.
If you have only install fastai (0.7.0) without install torch (0.3.1) before, then it used to using torch 0.3.1 (automatically). but crestle has recently upgraded torch to 0.4.0, and most importantly, the related packages.

so you may need to install torch 0.3.1 and torchtext 0.2.3, if you didn’t install torch before.

2 Likes

I am also having trouble starting with v0.7. I followed the instructions at the top of this thread for cpu.

I open the first course and shift-enter through each cell(first time Jupyter Notebook and Python user). I see the below error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-30-713ddf51e021> in <module>
----> 1 from fastai.imports import *
      2 from fastai.structured import *
      3 
      4 from pandas_summary import DataFrameSummary
      5 from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier

~/fastai/courses/ml1/fastai/imports.py in <module>
      1 from IPython.lib.deepreload import reload as dreload
----> 2 import PIL, os, numpy as np, math, collections, threading, json, bcolz, random, scipy, cv2
      3 import pandas as pd, pickle, sys, itertools, string, sys, re, datetime, time, shutil, copy
      4 import seaborn as sns, matplotlib
      5 import IPython, graphviz, sklearn_pandas, sklearn, warnings, pdb

~/anaconda3/envs/fastai-cpu/lib/python3.6/site-packages/cv2/__init__.py in <module>
      1 import importlib
      2 
----> 3 from .cv2 import *
      4 from .data import *
      5 

ImportError: libSM.so.6: cannot open shared object file: No such file or directory

Any help would be appreciated.

you need to ensure that your symlink is pointing to the correct fastai directory (ie. https://github.com/fastai/fastai/tree/master/old/fastai)

@stas, thanks for the hint the pytorch version was correct but
“** torchtext**” version was not compatible it has to be “torchtext==0.2.3.” for pytorch 0.3.1.

1 Like

I’m on 18.04, freshly installed.

Installed fastai v1 first, in a dedicated env (it seems to work). Then I installed fastai 0.7 following the procedure described (which is the usual procedure).

As I try to import fastai modules, it complains what follows:

It starts from:


and ends with:


The symlink seems to be OK…

Screenshot%20at%202018-10-12%2022-36-01


So, what’s wrong? :face_with_raised_eyebrow:

OK, solved.

It was torchtext. Downgrade it to the previous version with pip.

Source (for example): Google Colab-AttributeError: module 'torch' has no attribute 'float32'

2 Likes

FYI, environment*.yml were just updated to pin torchtext=0.2.3. Thank you all for the input and testing.

1 Like

The symlinks look all right to me. Not sure what’s causing this.

I am using clouderizer.com Fast.ai project template for the course and to run the template I use google colab like a backend and I am not able to import the library properly. I have already posted my query here and the solution I received was for the case when we run the complete notebook on google colab itself or I may not be able to understand it because these things are new to me. If someone in the forum is using clouderizer and has found a solution, please help!.

Thanks in advance.

Edit: Finally found a solution. Click on edit project, go to the setup section, in the setup script column, add pip install torchtext==0.2.3. Now I am able to run the notebooks without any problem.

I was getting error related to torchtext=0.2.3.
I replaced it with torchtext==0.2.3 in the enviornment.yml file and it worked

will that work with !pip install fastai==0.7.0 in kaggle kernels?

no, the pip package is from May-2018. you need to use the source:

git clone https://github.com/fastai/fastai.git
cd fastai
conda env create -f environment.yml

(or environment-cpu.yml for cpu)

or just install it from the nb:

!pip install fastai==0.7.0
!pip install torchtext==0.2.3
1 Like

I don’t think you can do that in kaggle kernels AFAIK.

thanks stas!
tried that in kaggle kernels but got error: AttributeError: ‘torch.dtype’ object has no attribute ‘type’
but also seems somewhat random, i managed to get it work once, then it showed error, some other people also reported errors.

ML lesson 1 worked with !pip install fastai==0.7.0, however DL v2 lessons are not running on kernels reliably. the more i look forward to v3 course. noticed v3 notebooks started to appear on github repo!

I noted that the setup is slightly different from what Jeremy posted in Wiki thread: lesson 1 for the Machine Learning MOOC:

Would you mind explain a bit about the difference between these two ways of setting up fast.ai v0.7?

Error:
AttributeError: module ‘torch’ has no attribute ‘float32’.

Generated by:
from fastai.transforms import *

Caused by:
A newer version of torchtext (>0.3.0) in the requirments.txt (>=0.2.3)

Resolved by:
!pip install fastai==0.7.0
!pip install torchtext==0.2.3

Order matters

2 Likes

Thank you for the PR, @Cesare.montresor
It looks like everybody has been using environment*yml files, so requirements.txt got out of sync. I synced it to match environment.yaml.

Thanks, really fast!
I use it on Colab for giving classes with my 2 study groups.
As it requires to reinstall dependencies every time, using pip is somehow faster :slight_smile:

1 Like

Wiki mode has been turned on for the first post so you can edit it to improve it. Thank you.