Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve idist to use Tcp and FileStore for init_method #1432

Closed
sdesrozis opened this issue Nov 3, 2020 · 4 comments · Fixed by #1767
Closed

Improve idist to use Tcp and FileStore for init_method #1432

sdesrozis opened this issue Nov 3, 2020 · 4 comments · Fixed by #1767

Comments

@sdesrozis
Copy link
Contributor

sdesrozis commented Nov 3, 2020

🚀 Feature

idist supports default initilialization env://. It could be useful to support tcp:// and file:// modes (to tackle distributed computations on windows for instance).

Main issue is how to configure these modes ?

@ahmedo42
Copy link
Contributor

ahmedo42 commented Mar 9, 2021

How about users customize this using environment variables? like this:

self._init_method = os.eviron["INIT_METHOD"]
dist.init_process_group(backend, init_method=self._init_method, **init_pg_kwargs)

in native.py

What are the drawbacks of this?

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Mar 9, 2021

@ahmedo42 this is interesting idea. Initially, I was thinking about an argument here:

init_pg_kwargs = {}
if timeout is not None:
init_pg_kwargs["timeout"] = timeout
dist.init_process_group(backend, init_method="env://", **init_pg_kwargs)

but maybe we can think about two options like that...

@ahmedo42
Copy link
Contributor

ahmedo42 commented Mar 9, 2021

So the end result would be something like that?

       def _create_from_backend(self, backend: str, timeout: Optional[int] = None, 
                   init_method:Optional[str] = "env://", **kwargs: Any) -> None:

            if backend == dist.Backend.NCCL and not torch.cuda.is_available():
                raise RuntimeError("Nccl backend is required but no cuda capable devices")

            self.setup_env_vars()

            self._local_rank = int(os.environ["LOCAL_RANK"])
            # for debug purposes
            self._master_port = int(os.environ["MASTER_PORT"])  # type: Optional[int]
            self._master_addr = os.environ["MASTER_ADDR"]  # type: Optional[str]

            init_pg_kwargs = {}
            if timeout is not None:
                init_pg_kwargs["timeout"] = timeout

           if  not _valid_init_method(init_method):
                #raise error 
                
           dist.init_process_group(backend, init_method=init_method, **init_pg_kwargs)

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Mar 9, 2021

Yes, something like that. Maybe, init_method:Optional[str] = None and we check os.eviron["INIT_METHOD"] and if init_method is not None (priority to the argument) and set up dist.init_process_group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants