MCPcopy Index your code
hub / github.com/FoundationVision/ByteTrack / _distributed_worker

Function _distributed_worker

yolox/core/launch.py:168–219  ·  view source on GitHub ↗
(
    local_rank,
    main_func,
    world_size,
    num_gpus_per_machine,
    num_machines,
    machine_rank,
    backend,
    dist_url,
    args,
)

Source from the content-addressed store, hash-verified

166
167
168def _distributed_worker(
169 local_rank,
170 main_func,
171 world_size,
172 num_gpus_per_machine,
173 num_machines,
174 machine_rank,
175 backend,
176 dist_url,
177 args,
178):
179 assert (
180 torch.cuda.is_available()
181 ), "cuda is not available. Please check your installation."
182 configure_nccl()
183 global_rank = machine_rank * num_gpus_per_machine + local_rank
184 logger.info("Rank {} initialization finished.".format(global_rank))
185 try:
186 dist.init_process_group(
187 backend=backend,
188 init_method=dist_url,
189 world_size=world_size,
190 rank=global_rank,
191 )
192 except Exception:
193 logger.error("Process group URL: {}".format(dist_url))
194 raise
195 # synchronize is needed here to prevent a possible timeout after calling init_process_group
196 # See: https://github.com/facebookresearch/maskrcnn-benchmark/issues/172
197 comm.synchronize()
198
199 if global_rank == 0 and os.path.exists(
200 "./" + args[1].experiment_name + "_ip_add.txt"
201 ):
202 os.remove("./" + args[1].experiment_name + "_ip_add.txt")
203
204 assert num_gpus_per_machine <= torch.cuda.device_count()
205 torch.cuda.set_device(local_rank)
206
207 args[1].local_rank = local_rank
208 args[1].num_machines = num_machines
209
210 # Setup the local process group (which contains ranks within the same machine)
211 # assert comm._LOCAL_PROCESS_GROUP is None
212 # num_machines = world_size // num_gpus_per_machine
213 # for i in range(num_machines):
214 # ranks_on_i = list(range(i * num_gpus_per_machine, (i + 1) * num_gpus_per_machine))
215 # pg = dist.new_group(ranks_on_i)
216 # if i == machine_rank:
217 # comm._LOCAL_PROCESS_GROUP = pg
218
219 main_func(*args)

Callers 1

launchFunction · 0.85

Calls 1

configure_ncclFunction · 0.90

Tested by

no test coverage detected