Kevinkevin189:

from torch.multiprocessing import Process

def run(rank, size):
    """ Distributed function to be implemented later. """
    pass

def init_process(rank, size, fn, backend='gloo'):
    """ Initialize the distributed environment. """
    os.environ['MASTER_ADDR'] = '127.0.0.1'
    os.environ['MASTER_PORT'] = '29500'
    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()



For this code, what is the error that you encountered?



 Kevinkevin189:

And this code can only run a part by setting the init_method = ‘file://./sharedfile’.


Can you try something like file:///tmp/sharedfile instead? It looks like the file:// scheme is not handling ./ correctly.