yolov7 icon indicating copy to clipboard operation
yolov7 copied to clipboard

How to do gradient accumulation or how to check yolov7 is doing gradient accumulation

Open bhuvneshsaini opened this issue 2 years ago • 2 comments

I have 4GB memory GPU which can support at most batch size of 8 images but I want to train at least 16 images batch and some where on internet I heard the concept gradient accumulation biut don't know how this thing can work in yolov7.

bhuvneshsaini avatar Apr 19 '23 18:04 bhuvneshsaini

You have a hyper-parameter named "nbs" that does exactly what you need. It is hard coded here:

https://github.com/WongKinYiu/yolov7/blob/3b41c2cc709628a8c1966931e696b14c11d6db0c/train.py#L110

eliavaxon avatar Apr 20 '23 07:04 eliavaxon

Does that mean I always use a batch_size of 64, while I use CLI like this?

python yolov7/train.py --device 0 --batch-size 1 --epochs 50 --data yolov7/data/AICUP.yaml --img 1280 1280 --cfg yolov7/cfg/training/yolov7-AICUP.yaml --weights 'pretrained/yolov7-e6e.pt' --name yolov7-AICUP --hyp yolov7/data/hyp.scratch.custom.yaml

ryankert01 avatar May 13 '24 10:05 ryankert01