Accumulate gradients on a single batch #8970
Unanswered
dvirginz
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
Replies: 1 comment 1 reply
-
Is this intended to run on a single GPU or multiple GPUs? There is manual_optimization which gives you utmost flexibility for how to process a single batch, as you control the forward, backward, step, and zero grad |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way of propagating the same batch in consecutive steps using pl?
Given a network constructed of multiple unrelated objectives, running all objectives at once causes the GPU consumption to be really large, but, as the different networks and objectives are not related, I can pass each on in a different
.backward()
step, and aggregate to the optimizer once.It resembles the
accumulate gradients
flag, but accumulation in pl is done on different batches.Is there a way of doing so without canceling automatic backprop?
The desired pipe is:
For a given batch Bi:
A) global_step=i -> Run self.net1(B) and compute gradients
B) global_step=i+1 -> Run self.net2(B) and compute gradients
C) Accumulate and optimize
Beta Was this translation helpful? Give feedback.
All reactions