r""" A wrapper function that initializes RPC, calls the function, and shuts down RPC.
(rank, world_size)
| 63 | |
| 64 | |
| 65 | def run_worker(rank, world_size): |
| 66 | r""" |
| 67 | A wrapper function that initializes RPC, calls the function, and shuts down |
| 68 | RPC. |
| 69 | """ |
| 70 | os.environ['MASTER_ADDR'] = 'localhost' |
| 71 | os.environ['MASTER_PORT'] = '29500' |
| 72 | if rank == 1: |
| 73 | rpc.init_rpc("trainer", rank=rank, world_size=world_size) |
| 74 | _run_trainer() |
| 75 | else: |
| 76 | rpc.init_rpc("ps", rank=rank, world_size=world_size) |
| 77 | # parameter server does nothing |
| 78 | pass |
| 79 | |
| 80 | # block until all rpcs finish |
| 81 | rpc.shutdown() |
| 82 | |
| 83 | |
| 84 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected