Fastai v2 on GCP

Hi to all,

I’m trying to start a notebook hosted on GCP, with fastai v2. When I’m importing the modules I get the following weird error:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-40bf25f691aa> in <module>
      3 from collections import defaultdict
----> 5 from fastai2.torch_basics import *
      6 from fastai2.test import *
      7 from fastai2.layers import *

~/anaconda3/envs/fastai_v2/lib/python3.7/site-packages/fastai2/ in <module>
      1 from torch import multiprocessing
----> 2 from .core.all import *
      3 from .torch_imports import *
      4 from .torch_core import *
      5 from .layers import *

ModuleNotFoundError: No module named 'fastai2.core'

I’m using an ubuntu 18.04 image, and have installed PyTorch 1.3.0 with CUDA 10.1.

Any ideas?

How did you install the v2 library?

With pip install git+

Can you import anything else from fastai2?

I can do something like import fastai2 or from fastai2 import *.

But when I add anything from a specific package like from fastai2.layers import * I get an error ModuleNotFoundError: No module named 'fastai2.core'

Same happened to me yesterday on GCP.
I made the pip install thru the ssh console, but jupyter kernel was already started, so the new package couldnt be seen by the kernel.
At the end, It was as silly as restart the kernel.

I had the same issue when I installed the fastai2 package with pip install git+

When I looked in the directory where the module was installed, there was no core directory for some reason.

My solution was to clone the repo and then install the package from the now local directory with pip install . (note the period, or specify the absolute path to the top level of the repo).

Make sure to create the conda environment using conda env create -f environment.yml and then activate it with conda env create -f environment.yml. Otherwise pip will use the wrong version of python.

1 Like

Hi @Caleb. Thanks for the reply, but I’m still getting the same error. I went into the directory the module was installed and I saw that neither core nor medical was there.

Then in the repo I saw that these are the only folders that do not contain an file. And although I create a conda env with the yaml file provided, and using python 3.7, they where not getting picked up as python packages. So when I “touched” two files in those folders it worked like a charm.

But still, it’s weird…

Added the init in core so it should work now.