MCPcopy Index your code
hub / github.com/pytorch/examples / run

Function run

distributed/rpc/batch/parameter_server.py:119–153  ·  view source on GitHub ↗
(rank, world_size)

Source from the content-addressed store, hash-verified

117
118
119def run(rank, world_size):
120 os.environ['MASTER_ADDR'] = 'localhost'
121 os.environ['MASTER_PORT'] = '29500'
122
123 # Initialize the process group first
124 dist.init_process_group(
125 backend="gloo",
126 rank=rank,
127 world_size=world_size
128 )
129
130 options=rpc.TensorPipeRpcBackendOptions(
131 num_worker_threads=16,
132 rpc_timeout=60
133 )
134 if rank != 0:
135 rpc.init_rpc(
136 f"trainer{rank}",
137 rank=rank,
138 world_size=world_size,
139 rpc_backend_options=options
140 )
141 # trainer passively waiting for ps to kick off training iterations
142 else:
143 rpc.init_rpc(
144 "ps",
145 rank=rank,
146 world_size=world_size,
147 rpc_backend_options=options
148 )
149 run_ps([f"trainer{r}" for r in range(1, world_size)])
150
151 # block until all rpcs finish
152 rpc.shutdown()
153 dist.destroy_process_group()
154
155
156if __name__=="__main__":

Callers

nothing calls this directly

Calls 1

run_psFunction · 0.85

Tested by

no test coverage detected