Effective batch size in DDP #13165
-
I have max batch size of 4 in single gpu. If 2 gpus are used, should I increase the batch size to 8 such that each gpu gets 4 batches. Or I just keep it as 4 and PL will load 2 four-batches data to 2 gpus?
I think it is the second case? I also have another problem related to ddp training, which is posted on this link below. I post it here for convenience. I am incorporating a pytorch based model into the pl framework for ddp training. class ZfoldLightning(pl.LightningModule):
def __init__(self, hparams):
...
self.model = XFold(MODEL_PARAM) which initializes the One solution is to refactor those to device code and use the recommended usage |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I have solved my problem and find out that the answer is: each gpu get #batch_size batches. If you have batch_size of 2 and 2 gpus are utilized, each gpu gets 2 batches and 4 batches in total are feed into a forward pass. |
Beta Was this translation helpful? Give feedback.
I have solved my problem and find out that the answer is: each gpu get #batch_size batches. If you have batch_size of 2 and 2 gpus are utilized, each gpu gets 2 batches and 4 batches in total are feed into a forward pass.