Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ignite/distributed/comp_models/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def spawn(
if LooseVersion(torch.__version__) >= LooseVersion("1.5.0"):
spawn_kwargs["start_method"] = kwargs.get("start_method", "spawn")

mp.spawn(
mp.start_processes(
_NativeDistModel._dist_worker_task_fn,
nprocs=nproc_per_node,
args=(
Expand Down
6 changes: 3 additions & 3 deletions ignite/distributed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,16 @@ def train_fn(local_rank, a, b, c, d=12):

- | "nccl" or "gloo" : `nnodes` (default, 1), `node_rank` (default, 0), `master_addr`
| (default, "127.0.0.1"), `master_port` (default, 2222), `timeout` to `dist.init_process_group`_ function
| and kwargs for `mp.spawn`_ function.
| and kwargs for `mp.start_processes`_ function.

- | "xla-tpu" : `nnodes` (default, 1), `node_rank` (default, 0) and kwargs to `xmp.spawn`_ function.

- | "horovod": `hosts` (default, None) and other kwargs to `hvd_run`_ function. Arguments `nnodes=1`
| and `node_rank=0` are tolerated and ignored, otherwise an exception is raised.

.. _dist.init_process_group: https://pytorch.org/docs/stable/distributed.html#torch.distributed.init_process_group
.. _mp.spawn: https://pytorch.org/docs/stable/multiprocessing.html#torch.multiprocessing.spawn
.. _xmp.spawn: http://pytorch.org/xla/release/1.5/index.html#torch_xla.distributed.xla_multiprocessing.spawn
.. _mp.start_processes: https://pytorch.org/docs/stable/_modules/torch/multiprocessing/spawn.html#spawn
.. _xmp.spawn: http://pytorch.org/xla/release/1.6/index.html#torch_xla.distributed.xla_multiprocessing.spawn
.. _hvd_run: https://horovod.readthedocs.io/en/latest/api.html#module-horovod.run

"""
Expand Down
4 changes: 3 additions & 1 deletion tests/ignite/distributed/comp_models/test_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,20 +276,22 @@ def _test_dist_spawn_fn(local_rank, backend, world_size, device):
assert _model.device() == torch.device(device)


def _test__native_dist_model_spawn(backend, num_workers_per_machine, device):
def _test__native_dist_model_spawn(backend, num_workers_per_machine, device, **spawn_kwargs):
_NativeDistModel.spawn(
_test_dist_spawn_fn,
args=(backend, num_workers_per_machine, device),
kwargs_dict={},
backend=backend,
nproc_per_node=num_workers_per_machine,
**spawn_kwargs,
)


@pytest.mark.distributed
@pytest.mark.skipif("WORLD_SIZE" in os.environ, reason="Skip if launched as multiproc")
def test__native_dist_model_spawn_gloo():
_test__native_dist_model_spawn("gloo", num_workers_per_machine=4, device="cpu")
_test__native_dist_model_spawn("gloo", num_workers_per_machine=4, device="cpu", start_method="fork")


@pytest.mark.distributed
Expand Down