Getting Started with fastai-v2

Perhaps symlink the local dir to a dir called fastai2 in your site_packages folder? Then import from fastai2?

2 Likes

@jeremy - symlink was my thought too - ran into problems when I called it fai2 but if I named symlink local it seemed ok. I forget which files I was importing that didn’t have relative imports will post more tomorrow when in front of computer

Yeah tell me what’s assuming local so I can fix it @313V :slight_smile:

in the file:

fastai_dev/dev/local/torch_basics.py

changing

from local.imports import *
from local.torch_imports import *
from local.core import *
from local.torch_core import *

to:

from .imports import *
from .torch_imports import *
from .core import *
from .torch_core import *

Thanks @313V fixed now - my dumb fault! :open_mouth:

2 Likes

I must be missing something very basic in getting starting - how to import fastai package in my project.

I followed the instructions to clone the repository and I’m able to run the notebooks and follow the walkthroughs, everything works there.

But now I want to use it in my project, which has other notebooks or code files, in another path.
How can I import “fastai” packages?
Do I need to set up a PYTHONPATH?
Do I need to deploy it to site-packages?
I don’t see a “fastai” folder, only a “local” one (like referred in the pets tutorial).

Perhaps symlink the local dir to a dir called fastai2 in your site_packages folder? Then import from fastai2?

Yeah, that seems to do the trick.

In commandline:
cd /home/user/anaconda3/envs/fastai/lib/python3.7/site-packages
ln -s /home/user/github/fastai_dev/dev/local/ fastai2

And then in Jupyter:
from fastai2.data.all import *
from fastai2.vision.core import *
(and following from pets tutorial)

But is this hack the way to use it?

Launching Jupyter-Notebook from WSL.

We see in the code walk through Jeremy seamlessly uses WSL to launch Jupyter Notebooks for development purpose.

I tried doing the same from my Windows 10 system -> created fast_ai enviroment -> launched Lec 08 Notebook. But it keeps mentioning Connection failed (Cannot establish connection to kernel).

Did anyone else face the same issue before ? If so, what’s the fix ?

I’m always doing that inside an SSH connection to my university Linux computer.

Your WSL kernel is trying to connect to a (probably nonexistent) X server to open Jupyter in the default web browser.

In my WSL .zshrc, I have jupyter notebook aliased as follows:

alias jupyter-nb=‘jupyter notebook --no-browser’

After you enter the command in your shell, you can open up Chrome or any other browser and direct it to localhost:8888.

This is much simpler than trying to setup an X server and have the window auto launch.

2 Likes

You can also set open_browser=False in your config file so you don’t have to change the command you run.

4 Likes

Thanks it’s resolved. :slight_smile:

@jeremy any list of TODOs one can pick up to contribute? Thanks!

1 Like

Question about getting started with fastai-v2 on Google Cloud here. I try to run Jeremy’s Kaggle example myself: From prototyping to submission (fastai).

After going through all the steps above, fastaiv2 seemed installed. See image for an example.

Still I got: ModuleNotFoundError: No module named 'fastai2'.

What could be wrong? Thanks.

Why is fastai_dev under course-v3?

It should be fine just to type pip install git+https://github.com/fastai/fastai_dev in the command line.

I was able to run and submit using this kernel from GCP.

1 Like

Is it there a tutorial somewhere on how to use the development (how they work) tools for other projects?

Not yet now. I’ll package them separately once v2 is finished, in the meantime you can probably extract the relevant modules.

I saw you posted nbdev, do you have a basic getting started?
My bad, there is a readme now: https://github.com/fastai/nbdev

As of Dec 2019 fastai v2 has dependencies on nbdev. So, if you just installed fastai2 and go

from fastai2.vision.core import *

you’ll get an error.

To resolve you might want to install both, nbdev and fastai2, e.g. as an editable install using:

pip install packaging && \
    git clone https://github.com/fastai/nbdev && \
    pip install -e nbdev && \
    conda install -y -c fastai -c pytorch fastai && \
    mkdir /fastai2 && \
    cd /fastai2 && \
    git clone https://github.com/fastai/fastai_dev.git && \
    cd /fastai2/fastai_dev && \
    python setup.py build && \
    pip install -e .

Sorry, I posted too early. The above didn’t quite do it for me. Now I am getting a different one:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-8-78a5dc88e87d> in <module>
----> 1 from fastai2.vision.core import *

/fastai2/fastai_dev/fastai2/vision/core.py in <module>
      9 from ..test import *
     10 from ..torch_basics import *
---> 11 from ..data.all import *
     12 
     13 from PIL import Image

ModuleNotFoundError: No module named 'fastai2.data'

fastai2 is searching for the python fastai2.data module, which, I believe, used to be there in a former version.
Now, in version 2.0.1 of fastai2 there is no fastai2.data folder (I checked on the os level).
I haven’t quite figured it out yet and will post again when I have.
The docs and nbs btw still assume fastai2.data to be there. Where did the data directory go?