TRI-ML / packnet-sfm

TRI-ML Monocular Depth Estimation Repository
https://tri-ml.github.io/packnet-sfm/
MIT License
1.24k stars 243 forks source link

Needed GPU Memory #13

Closed marcelschilling closed 4 years ago

marcelschilling commented 4 years ago

Is there any possibility to use the network with an 4GB GPU device? Thanks in advance.

VitorGuizilini-TRI commented 4 years ago

Have you tried with a batch size of 1? If that doesn't work then unfortunately not at this point. We have slimmer models for PackNet that should fit, we will soon add those to the repository. We are also working on implementing mixed-precision training, it should address this issue as well.

marcelschilling commented 4 years ago

Thanks for your reply. Yes, I tried inference with batch size 1, but unfortunately it doesn‘t work with a 4GB GPU.

kwea123 commented 4 years ago

@VitorGuizilini-TRI Some bugs maybe? Currently the model is initiated without a call of .eval(), which means it is in training mode, doesn't that affect batch normalization? Another thing is that in infer.py, the decorator @torch.no_grad() is missing for process. Simply add with torch.no_grad(): before these lines https://github.com/TRI-ML/packnet-sfm/blob/f41342d716a72e195a0e72cf12c6b563d182bb91/scripts/infer.py#L74-L75 reduces the memory usage (because it doesn't compute gradient anymore).

As a result, it only consumes 3.6GB for an image of size 384x640 (I use PackNet01_MR_selfsup_D.ckpt)