Helper function to synchronize (barrier) among all processes when using distributed training
()
| 35 | |
| 36 | |
| 37 | def synchronize(): |
| 38 | """ |
| 39 | Helper function to synchronize (barrier) among all processes when using distributed training |
| 40 | """ |
| 41 | if not dist.is_available(): |
| 42 | return |
| 43 | if not dist.is_initialized(): |
| 44 | return |
| 45 | world_size = dist.get_world_size() |
| 46 | if world_size == 1: |
| 47 | return |
| 48 | dist.barrier() |
| 49 | |
| 50 | |
| 51 | def get_world_size() -> int: |
no outgoing calls
no test coverage detected