inplace_abn icon indicating copy to clipboard operation
inplace_abn copied to clipboard

Slow Training Time for Segmentation Model

Open brucemuller opened this issue 5 years ago • 9 comments

Dear Mapillary Developers

I'm implementing your segmentation model into my PyTorch code base for my PhD research. Problem: it's taking around 6 hours to train a single epoch on Vistas from scratch (on a single GTX 1080). Is this normal?

My feeling is that it shouldn't take this long as other models (e.g. u-net) take under an hour (about 15min). It also seems to lag on sending tensors to GPU if I use normal BN. If I use InPlaceABN instead of lagging on sending to GPU it does so on the backward call. Either way, it also seems to lag on printing the loss or using .item() on loss.

Can anyone suggest where it might be going wrong or how I could figure this kind of problem out? I've tried using your SingleGPU class but it didn't seem to help...

brucemuller avatar Mar 05 '19 11:03 brucemuller

Hi! I encounter the same issue and my training is about 3.5x slower too. Do you figure it out? It seems that end to end model will use more Batch Norm layers and it will lead to 2 times overhead. But 3.5 time slower is still an incredible overhead.

geekboood avatar Mar 28 '19 13:03 geekboood

Hi @geekboood

So since then I found I could actually train a single epoch in under an hour if using a much more powerful GPU or multiple GPUs. Can you try this?

The problem I have now is the results after training for many epochs don't look good and I only achieve a mean IoU of about 8% over the validation set (on Vistas). I attached some example and the training curve. Do you have an idea of what could be the problem? I'd be really interested to know how you are training or what hyper parameters you found worked :) I'm not sure whether the original paper used pre-training for the segmentation task so maybe that's where the improvement lies... abn_vistas_loss.pdf abn_vistas_IoU.pdf abn_vistas_epoch200_ex6 abn_vistas_epoch200_ex7 abn_vistas_epoch200_ex8 abn_vistas_epoch200_ex9 abn_vistas_epoch200_ex10

brucemuller avatar Apr 02 '19 13:04 brucemuller

@brucemuller247 I roll back to the version compatibles with Pytorch 0.4.1 and my model trains normally. As for your problem, what is the backbone of your end-to-end network and what loss function do you use? Usually for semantic segmentation tasks, I use CrossEntropyLoss and it will converge to 0.0x.

geekboood avatar Apr 03 '19 12:04 geekboood

@geekboood Thanks for your reply, good idea to roll back. Are you using multiple GPUs when it trains normally?

For backbone I use the WiderResNet (https://github.com/mapillary/inplace_abn/blob/master/models/wider_resnet.py) they state in the paper. For loss I also use CrossEntropyLoss but I'm not getting that convergence. What order of magnitude learning rate and batch size are you using? Are you using standard SGD and fixed learning rate? Are you using any pre-training or class weighting? Are you using the the same backbone and head Mapillary use in their paper? Are you using many augmentations? There's so many parameters/options to consider so I'd very much appreciate your help/insight!

brucemuller avatar Apr 05 '19 13:04 brucemuller

@geekboood I'd also appreciate the answer to these same questions, I'm workin on a comparison study for my internship and it would be very helpful.

AmeetR avatar Jul 08 '19 05:07 AmeetR

Can you try again with the latest version of the library (v1.0.2)?

ducksoup avatar Jul 10 '19 08:07 ducksoup

I can also confirm that I have a slow training time (on a 4 GPU DGX-1 system...) and kind of bad results (with the older version of inplace_abn, though). My network is based on TernausNetV2 (which includes the inplace_abn and its wideresnet-38 implementation as a decoder). I will later adapt the code for DistributedDataParallel and give the new version a go (I use InPlaceABNSync).

vakkov avatar Jul 10 '19 11:07 vakkov

@vakkov thank you, please let us know about your findings!

Note: reproducing the results in "In-Place Activated BatchNorm for Memory-Optimized Training of DNNs" by training your own models is beyond the scope of this issues section. Unfortunately we don't have the resources necessary to assist github users with this task.

In order to keep the discussion focused on the inplace_abn library (which is the sole focus of this repo), and to streamline the resolution process, we will from now on immediately close off-topic issues.

Thank you for your understanding!

ducksoup avatar Jul 10 '19 15:07 ducksoup

I'll try to run more again soon. What kind of training times are people getting? @vakkov

brucemuller avatar Jul 19 '19 19:07 brucemuller