Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradient accumulation implemention #165

Open
King4819 opened this issue Mar 1, 2024 · 2 comments
Open

Gradient accumulation implemention #165

King4819 opened this issue Mar 1, 2024 · 2 comments

Comments

@King4819
Copy link

King4819 commented Mar 1, 2024

I want to ask that how to implement gradient accumulation on your work. Since my computing resource is single RTX4090 (24GB), so I'm not able to set batch size to 16, thanks !!!

@duanduanduanyuchen
Copy link
Collaborator

Hi, you can use GradientCumulativeOptimizerHook. Just set the dict in the config file like this:

data = dict(samples_per_gpu=1)
optimizer_config = dict(type='GradientCumulativeOptimizerHook', cumulative_iters=2)

The total batch_size will be samples_per_gpu*cumulative_iters*num_gpus.

@King4819
Copy link
Author

@duanduanduanyuchen Thanks for your reply !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants