Skip to content

How to sync buffers in multi-gpu training #8545

Discussion options

You must be logged in to vote

Dear @MeteorsHub,

Great question. Lightning doesn't do any magic there. It relies on PyTorch DistributedDataParallel to handle multi-gpu via grad-syncing.

The buffers are being synced on start using _sync_params_and_buffers: https://github.com/pytorch/pytorch/blob/3e3acf8a9ac005db3094f23bd41a5fbc0c3c154b/torch/nn/parallel/distributed.py#L570

If you need to access this private function for any reason, you can do the following:


trainer.training_type_plugin.model._sync_params_and_buffers(authoritative_rank=0)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MeteorsHub
Comment options

Answer selected by MeteorsHub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants