Fastai v2 chat

Thanks for sharing! I’m very interested in this

do you have any idea how relevant this is?

In my tests, for the massive Dataset (20MM) without shuffle_train=False, the performance drops to unbearable levels (too much time without GPU processing - 0% and much bigger training time).

Using the low level API, some decisions impact the processing time very abruptly.

For eg: testing the imdb notebook from the fastai course, the running times can be very different depending on the dataloaders.

Using the factory TextDataLoaders class, the running time is 9 s for each epoch:
dls = TextDataLoaders.from_df(df, text_col='text', is_lm=True, valid_col='is_valid')

Using the low level api, it runs in 19 s:

splits = ColSplitter()(df)
tfms = [attrgetter("text"), Tokenizer(tokenizer=SpacyTokenizer()), Numericalize()]
dsets = Datasets(df, [tfms], splits=splits, dl_type=LMDataLoader)
dls = dsets.dataloaders(bs=64, seq_len=72)

Changing some dataloaders parameters, we can achieve between 8 and 9 s per epoch using the low level API:

dls = dsets.dataloaders(bs=64, seq_len=72, num_workers=2, pin_memory=True)

1 Like

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:

2 Likes

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.

4 Likes

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),
                   get_items=get_ts_items,
                   getters=getters,
                   splitter=RandomSplitter(seed=seed),
                   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 Bengali.ai 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 dev.fast.ai 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.