Skip to content

Instantly share code, notes, and snippets.

@stas00
Last active November 20, 2023 20:33
Show Gist options
  • Save stas00/58faf392b73609a9c6bca77b495099cd to your computer and use it in GitHub Desktop.
Save stas00/58faf392b73609a9c6bca77b495099cd to your computer and use it in GitHub Desktop.
Profiling `init_process_group('nccl')`
# run as:
# python -u -m torch.distributed.run --nproc_per_node=8 --rdzv_endpoint localhost:6000 --rdzv_backend c10d benchmark_dist_init.py
import torch
import os
import cProfile
import torch.distributed as dist
import timeit
def init():
dist.init_process_group('nccl')
local_rank = int(os.environ["LOCAL_RANK"])
if local_rank == 0:
cProfile.run("init()", sort="tottime")
else:
init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment