Fastai v0.7 install issues thread

!pip install fastai==0.7.0
!pip install torchtext==0.2.3
from fastai.text import *
import html

I get Dataset not defined error.

NameError Traceback (most recent call last)
----> 1 from fastai.text import *
2 import html

~/notebooks/notebooks/fastai/courses/dl2/fastai/ in
1 from .core import *
----> 2 from .learner import *
3 from .lm_rnn import *
4 from import Sampler
5 import spacy

~/notebooks/notebooks/fastai/courses/dl2/fastai/ in
4 from .transforms import *
5 from .model import *
----> 6 from .dataset import *
7 from .sgdr import *
8 from .layer_optimizer import *

~/notebooks/notebooks/fastai/courses/dl2/fastai/ in
185 return full_names, label_arr, all_labels
–> 187 class BaseDataset(Dataset):
188 “”“An abstract class representing a fastai dataset. Extends”""
189 def init(self, transform=None):

NameError: name ‘Dataset’ is not defined

How to resolve this? Can someone please help me?
Thank you,

Hi friends,
Recently, I came across many problems after installing fastai v 0.7.0 for Part 2 of the course.
Unfamiliar Error when Running
Did any of you folks came across such problem and managed to get a solution for this.
Really appreciate your efforts.

Hi, I’m having the same error you talked about in here, and the symlink seems fine as well. Did you ever figure out what was the problem?

I forget the specifics now. But I think I was not running the conda environment. It was a simple fix like that.

Hello, Im having issues downloading fastai. I’m getting this error but i did download pytoch

fastai 0.7.0 not working Google Colaboratory anymore?

I am using Google Colaboratory and fastai 0.7.0

It worked fine some time back (I would guess in January this year),
now I am having a look at the notebooks, and they fail to run (without any code changes)

I have been using the dogs vs cats example from the course.

!pip install -q torchtext==0.2.3
!pip install -q fastai==0.7.0

gives 0.3.1

data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz))
learn = ConvLearner.pretrained(arch, data, precompute=True), 2)

module ‘torch.nn.init’ has no attribute ‘kaiming_normal_’

No idea why it worked some months back and what changed.

I try to figure out what the issue is, and it seems to be due a need to upgrade to pytorch:

I kill the Colab seesions, and reset try to upgrade
!pip install -q{accelerator}/torch-0.4.1-{platform}-linux_x86_64.whl torchvision

gives 0.4.1

Running the code again
data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz))
learn = ConvLearner.pretrained(arch, data, precompute=True), 2)

/usr/local/lib/python3.6/dist-packages/torch/cuda/ UserWarning:
Found GPU0 Tesla T4 which requires CUDA_VERSION >= 9000 for
optimal performance and fast startup time, but your PyTorch was compiled
with CUDA_VERSION 8000. Please install the correct PyTorch binary
using instructions from

warnings.warn(incorrect_binary_warn % (d, name, 9000, CUDA_VERSION))

so I think it is runs on CPU now instead, and it never finishes (it runs out of memory on colab after a while)

If I try to upgrade to pytorch 1.1 I get

ERROR: fastai 0.7.0 has requirement torch<0.4, but you’ll have torch 1.1.0 which is incompatible.

Anyone successfully running 0.7.0 in Colab now?

After creating the environment…when trying to activate by "
conda activate fastai-cpu"
I am getting below error
CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate’.
To initialize your shell, run

$ conda init <SHELL_NAME>

I have created docker container for FastAI version 0.7.0. You can runn following command to pull the container:

docker pull mdeore/fastai_0_7_0

Hope this helps.

I’m also having problems with torch version, did you manage to sort this?

I’m getting this:
torchvision 0.3.0 has requirement torch>=1.1.0, but you’ll have torch 0.1.2.post2 which is incompatible.

And This:
Command “/Applications/anaconda3/bin/python -u -c “import setuptools, tokenize;file=’/private/var/folders/b2/l0wpqyh966759ms4lr29d9cm0000gn/T/pip-install-w360hnca/bcolz/’;f=getattr(tokenize, ‘open’, open)(file);’\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record /private/var/folders/b2/l0wpqyh966759ms4lr29d9cm0000gn/T/pip-record-envqcys5/install-record.txt --single-version-externally-managed --compile” failed with error code 1 in /private/var/folders/b2/l0wpqyh966759ms4lr29d9cm0000gn/T/pip-install-w360hnca/bcolz/


Any chance you were able to resolve this? I’m running into same issue.

@mdeore Does it run on a gpu or cpu env? Thanks!

@draz its for CPU but will make it GPU as well.

Hello FastAI friends,

I think that I am at the very right topic to get helped on my problem. I am trying to create a docker on Ubuntu for fastai-cpu v0.7. I have created the following Dockerfile:

FROM ubuntu:18.04

WORKDIR /fastaidir


ADD${TINI_VERSION}/tini /tini
ADD /vaultenv

RUN apt-get update && \
    apt-get install -y git wget curl unzip libsm6 libxrender1 && \
    curl -o ~/ -O  && \
    chmod +x ~/ && \
    ~/ -b -p /opt/conda && \
    rm ~/ && \
    /opt/conda/bin/conda install conda-build && \
    git clone && \
    cd /fastaidir/fastai && ls && /opt/conda/bin/conda env create -f environment-cpu.yml -n fastai-cpu && \
    /opt/conda/bin/conda clean -ya && \
    chmod +x /tini && \
    chmod +x /vaultenv && \
    ln -s /data /fastaidir/data

ENV USER fastai

ENTRYPOINT ["/tini", "--"]
CMD ["/”]

, where at the end I am configuring the fastai-cpu with the, inspired from Jeremy at the beginning of this thread:


source /opt/conda/etc/profile.d/
conda activate fastai-cpu

pip uninstall -y matplotlib  ;
python -m pip install --upgrade pip  ;
pip install matplotlib  ;
pip install fastai==0.7.0  ;
pip install torchtext==0.2.3  ;
pip install flask==1.0.2    ;

exec /opt/conda/envs/fastai-cpu/bin/python -c 'from fastai.conv_learner import *; print("\nimported \n")'
printf "%*s\n" $ColumnsN |tr " " “_”

This was a working code about a year ago. I bet it’s something about the versions of torch, (or Ubuntu?, or Miniconda?), and at the very end I am getting this error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/conda/envs/fastai-cpu/lib/python3.6/site-packages/fastai/", line 1, in <module>
    from .core import *
  File "/opt/conda/envs/fastai-cpu/lib/python3.6/site-packages/fastai/", line 2, in <module>
    from .torch_imports import *
  File "/opt/conda/envs/fastai-cpu/lib/python3.6/site-packages/fastai/", line 2, in <module>
    import torch, torchvision, torchtext
  File "/opt/conda/envs/fastai-cpu/lib/python3.6/site-packages/torch/", line 56, in <module>
    from torch._C import *
ImportError: cannot open shared object file: No such file or directory

I don’t understand what I am missing. Please suggest. Thanks!

OMG it works!
I spent hours trying to follow the various install documents. Please do this document in just one place, and replace all the other awful ones. No greater barrier to a software community than an impossible setup.

I wrote a document on How to Install Fastai v0.7 on AWS for Fastai Machine Learning Course that details every installation step to get you started on the Fastai ML course. I agree with @banksiaboy that there is no greater barrier to software development and learning than an impossible setup.

@minh I think that the step 3 is not correct. By doing git clone it basically installs v1.x, not v0.7.

1 Like

I tried and got fasai v0.7 installed correctly. Did you somehow get v1 installed?

On a brand new system (created with Docker) v1 is installed in this way. Moreover, the instructions in describe exactly what I am saying.

I have installed latest fastai version. But i am not able to run the ML course. How can i access 0.7version now. Does all the functions of 0.7 version is present in current version?

@DebabrataRoy The latest version is different from the v0.7. You should follow the instructions in that refer to the old version (v0.7).