diff --git a/python/paddle/fluid/distributed/helper.py b/python/paddle/fluid/distributed/helper.py new file mode 100644 index 0000000000000000000000000000000000000000..8e079b1e8d96ba4036709a56b79e378fc6cd392b --- /dev/null +++ b/python/paddle/fluid/distributed/helper.py @@ -0,0 +1,20 @@ +from mpi4py import MPI + +class MPIHelper(object): + def __init__(self): + self.comm = MPI.COMM_WORLD + + def get_rank(self): + return self.comm.Get_rank() + + def get_size(self): + return self.comm.Get_size() + + def get_ip(self): + import socket + local_ip = socket.gethostbyname(socket.gethostname()) + return local_ip + + def get_hostname(self): + import socket + return socket.gethostname()