def main(params):
    print("Use MPI:%s" % params.use_mpi)

    pid = os.getpid()
    print("pid: %d" % pid)
    utilityLogger = SystemUtilLogger(pid,
                                     task=params.task,
                                     device=params.device)

    if params.use_mpi:
        comm = MPI.COMM_WORLD
        rank = comm.Get_rank()
        size = comm.Get_size()

        worker_hosts_list = params.worker_hosts.split(',')
        num_worker_hosts = len(worker_hosts_list)
        num_hosts = num_worker_hosts

        params.protocol = "grpc+mpi"

        if (size != num_hosts):
            print("size:", size, '# OF HOSTS', num_hosts)
            print("ERROR")
            return

        for rank_rotate in range(num_hosts):
            if rank == rank_rotate:
                print("I am rank " + str(rank_rotate) + "...")
                hostname = socket.gethostname()
                #print("My hostname is: " + hostname)
                # for ps_hosts_rotate in range(num_ps_hosts):
                #     if hostname == ps_hosts_list[ps_hosts_rotate].split(':')[0]:
                #         print("My job ID is: ps" + str(ps_hosts_rotate))
                #         os.system("python -u " + FLAGS.script + " --ps_hosts=" + FLAGS.ps_hosts + " --worker_hosts=" + FLAGS.worker_hosts + " --job_name=ps --task_index=" + str(ps_hosts_rotate))
                #for worker_hosts_rotate in range(num_worker_hosts):
                #if hostname == worker_hosts_list[worker_hosts_rotate].split(':')[0]:
                print("My job ID is:worker" + str(rank))
                #command = "python3 " + FLAGS.script + " --worker_hosts=" + FLAGS.worker_hosts + " --job_name=worker --task_index=" + str(rank)

                params.task_index = rank
                utilityLogger.start()
                moe.main(params, comm)
                utilityLogger.stop()
                utilityLogger.join()

    else:
        params.protocol = "grpc"
        moe.main(params)
Exemple #2
0
 def create_webapp(self):
     """Create a mocked webapp and store it in self.testapp."""
     from moe import main
     app = main({}, use_mongo='false')
     from webtest import TestApp
     self.testapp = TestApp(app)
Exemple #3
0
 def create_webapp(cls):
     """Create a mocked webapp and store it in cls.testapp."""
     from moe import main
     app = main({}, use_mongo='false')
     from webtest import TestApp
     cls.testapp = TestApp(app)