Hi,
I am trying to run the example code from the pytorch distributed tutorial (dist_tuto.html 8).
Here is my exact code:
import os
import torch
import torch.distributed as dist
from torch.multiprocessing import Process


def run(rank, size):
    tensor = torch.zeros(1)
    if rank == 0:
        tensor += 1
        dist.send(tensor=tensor, dst=1)
    else:
        dist.recv(tensor=tensor, src=0)
    print("Rank ", rank, " has data ", tensor[0])


def init_process(rank, size, fn, backend="gloo"):
    """ Initialize the distributed environment. """
    os.environ["MASTER_ADDR"] = "127.0.0.0"
    os.environ["MASTER_PORT"] = "29511"
    dist.init_process_group(backend, rank=rank, world_size=size)
    fn(rank, size)


if __name__ == "__main__":
    size = 2
    processes = []
    for rank in range(size):
        p = Process(target=init_process, args=(rank, size, run))
        p.start()
        processes.append(p)

    for p in processes:
        p.join()


In terminal, I run it with python run.py. It runs successfully both on my server and on my friend’s Mac. But, it hangs there forever on my own Mac. I tried to restart my Mac, and reinstall python(v3.8.2)/torch(v1.5.0). No success.
If we interrupt it with “control-c”, the last line of trace is:
  File "/usr/local/anaconda3/envs/p382/lib/python3.8/subprocess.py", line 1762, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)

I suspect there is a deadlook. Any approach to avoid it?