MCPcopy Create free account
hub / github.com/pytorch/examples / run_worker

Function run_worker

distributed/rpc/rnn/main.py:65–81  ·  view source on GitHub ↗

r""" A wrapper function that initializes RPC, calls the function, and shuts down RPC.

(rank, world_size)

Source from the content-addressed store, hash-verified

63
64
65def 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
84if __name__ == "__main__":

Callers

nothing calls this directly

Calls 1

_run_trainerFunction · 0.70

Tested by

no test coverage detected