Fastai v2 chat

I am not sure that the LMDataLoader can safely handle num_workers > 1`, FYI.

1 Like

Really? I have been using it for some time, and have had good results with fastai2. But I will keep my eyes open.

Well, that’s exactly the kind of trouble I have had. A couple of times it has almost worked, though.

I’ve moved some posts about fastai2 on Windows to a new topic:


I just saw the update on the main website and the arxiv paper on fastai v2. I’m very excited, especially for the mid-level APIs, two-way callbacks, and “refactored layer classes” thingy. The article mentioned that fastai v2 is feature complete and just lacking documentation and a youtube course, is that the current status?

How do users who have migrated to v2 feel about the current state? Do you find it stable enough relative to v1? Has it been easier to implement custom models? It seems with the mid-level APIs the code will be more flexible, and I’m really excited if that’s the case.

It’s relatively stable, (I’ve been doing all my work in v2 right now) see my comment here:

(which also answers your other questions somewhat). The study group I run shows many examples for custom models and mid-level api.

Said study group: A walk with fastai2 - Study Group and Online Lectures Megathread

I’ll also add I’m in the middle of implementing Mask RCNN, and getting the databunch working was trivial :slight_smile:

1 Like

Hi all,
One of my goals is to deploy a model to an edge device. has anyone done this with fastai v1 /v2? Is there anything specific to fastai v2 or even recent changes in pytorch that help/hinder this? (I’m not meaning using the edge device to hit a cloud endpoint for inference)

Jeremy , Sylvain : I don’t see anything in existing notebook titles - but is anything in a notebook or the upcoming book?
Community : has anyone had a try with v2 (or is it too early)?

(I’ve done a forum search for any info around things like Caffe Onnx , conversion to TF then TF lite etc - none of which I’ve learnt yet but no (recent) joy)

fastai focuses on training models, not deploying them. You have the PyTorch model at the end of your training, so you should be able to use whatever PyTorch has in store for deployment.

1 Like

My feeling is that work is advancing very well, and all the main features are already there in V2.

V2 comes with some interesting improvements, which is nice. I don’t think it’s much easier to use once you get the hang of both, but V2 should have a better learning curve, since some things are now in a more logical place. For example, callbacks are now cleaner and a bit easier to understand. (Know that I myself have so much yet to learn, so take all of this with a grain of salt.)

But don’t be fooled: it is absolutely a work in progress, and changes are relatively frequent; things that work may not work next week (although typically it’s small fixes).

This is not hopeless thanks to a nice community and very responsive developers. In particular, I think we are all here thankful to @sgugger, who seems to check out most of the forum posts and takes a rather surprising amount of time to address them.


fair enough. I started a post to gather what we can for those that share my interest

1 Like

I have a get_items() method that returns a list of tuples. The tuples are numpy.ndarray and string.

getters = [ItemGetter(0), ItemGetter(1)] 
tsdb = DataBlock(blocks=(TSBlock, CategoryBlock),
                   batch_tfms = batch_tfms)

In my custom show_results(x:TensorTS, y, samples, outs, ...) the arguments outs returns a list of tuples outs = [('6.0',),('2.0',)] and I need it as list of labels like this outs = ['6.0', '2.0'].

For now, I am using the detuplify() method (outs = [detuplify(o) for o in outs]) in the show_results() method. Is it considered as a hack?; and if so what is the proper way to do it?

I noticed get_preds() (called by show_results()) is using tuplify() through predit()

Yes outs is always assumed to be a tuple (maybe of length 1) since we can have one or multiple outputs in general. The basic show_results methods uses a for loop other those (as you can see in the beginning of data.core).

1 Like

I was experimenting with fastai2 on competition, and I noticed that fastai2 is 2x slower than fastai1 for a similar model that I was using before, So I tried to run example notebooks from fastai v1 and v2 to make sure I’m not missing something, I modified v2 pets to run on URLs.DOGS dataset on colab same as v1 notebook, with same bs, imagesize, and same GPU from colab (Tesla T4). The result is the same fastai1 took 2:10min per epoch but fastai2 took 4:16min! Does anyone faced this issue? Potential bug? @sgugger

@vijayabhaskar are you loading everything to the GPU on transforms that you can? Same batch size? And during prediction are you sure you’re using the GPU? (Just read the batch size). Can you share your code? (For dogs)

I will study this further and reply here tomorrow, possibly share a notebook comparing the speeds. It’s very possible that I maybe doing something wrong though :slight_smile:

1 Like

I installed fastai2 , and looking through the documentation, there are tutorials (thanks for that!) Are there notebooks associated with these tutorials in the fastai2 repo that we clone or are these supposed to be typed in to new notebooks.

The documentation are notebooks :wink: look in the nbs/ folder in the fastai2 GitHub

That’s what I thought, I think I’m having trouble matching up the notebooks with the tutorials. For example the first tutorial on is “Transfer Learning in Computer Vision” but it doesn’t mention which notebook it’s been built from and I’ve been looking around to see which notebook I should load.

@mike.moloch if we take a look at the tutorials notebook (as this is what tab it is under), we can find a 22_tutorial.transfer_learning. (This can also be seen by looking at the website url itself: which we can see is a notebook called “tutorial.transfer_learning” (Not denying this isn’t easy to figure out, I’ve just figured this out by exploring myself)

1 Like

Thanks Zachary, I think that’s what I was missing in my understanding! I was searching for vision in the title but should’ve realized the docs have carried the nb names over!

Thanks so much!

1 Like