Skip to content

Fix multi-node DDP training - #2101

Merged
mravanelli merged 1 commit into
developfrom
lucadellalib-distributed-training
Aug 18, 2023
Merged

mravanelli merged 1 commit into
developfrom
lucadellalib-distributed-training

Conversation

@lucadellalib

Copy link
Copy Markdown
Collaborator

NOTE: requires further testing.

speechbrain.utils.distributed.if_main_process defines the main process as the one with global rank (RANK environment variable) equal to 0. This works when using DDP on a single node, because the global rank of each process is the same as the local rank within the node. However, this fails when using multiple nodes. Indeed, I/O operations like data preparation, fitting SentencePiece tokenizer, etc. are run only on the master node (where the process with global rank 0 runs), but not on the worker nodes (where processes with global rank > 0 run). Therefore intermediate artifacts such as the data manifest files and SentencePiece checkpoint are created only on the master node but not on the worker nodes, which makes the processes on worker nodes fail (e.g. FileNotFoundError). Checking against the local rank (LOCAL_RANK environment variable) should fix the issue (this way I/O operations are run on the main process of each node).
pytorch-ddp
YunchaoYang/Blogs#3

@Adel-Moumen
Adel-Moumen requested a review from pplantinga August 6, 2023 17:52
@mravanelli mravanelli added the bug Something isn't working label Aug 7, 2023
@mravanelli

Copy link
Copy Markdown
Collaborator

@pplantinga, could you please take a look at this?

@pplantinga pplantinga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this change. Although there may be some cases where you wish code to run only on the master node (e.g. saving a checkpoint) it seems like in the majority of cases the preferred behavior would be to run on every node, and the cost of running on all nodes even in those cases where you might not want to is small.

@mravanelli
mravanelli merged commit 0e8b81e into develop Aug 18, 2023
@mravanelli
mravanelli deleted the lucadellalib-distributed-training branch August 18, 2023 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants