8000 torch.distributed.launch is deprecated · Issue #2413 · pytorch/ignite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

torch.distributed.launch is deprecated #2413

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

Closed
budui opened this issue Jan 8, 2022 · 2 comments
Closed

torch.distributed.launch is deprecated #2413

budui opened this issue Jan 8, 2022 · 2 comments
Labels

Comments

@budui
Copy link
budui commented Jan 8, 2022

❓ Questions/Help/Support

Hi, I noticed that when I run the DDP program with torch.distributed.launch, pytorch indicates that torch.distributed.launch is about to be deprecated.

dancer@server:~/dev$ python3 -m torch.distributed.launch --nproc_per_node 2 run.py 

/opt/conda/lib/python3.9/site-packages/torch/distributed/launch.py:178: FutureWarning: 
The module torch.distributed.launch is deprecated  and will be removed in future. Use torchrun. 

Note that --use_env is set by default in torchrun. 
If your script expects `--local_rank` argument to be set, 
please change it to read from `os.environ['LOCAL_RANK']` instead. 
See https://pytorch.org/docs/stable/distributed.html#launch-utility for further instructions 
warnings.warn( WARNING:torch.distributed.run:                                                          

The related code in PyTorch is here:

def main(args=None):
    warnings.warn(
        "The module torch.distributed.launch is deprecated\n"
        "and will be removed in future. Use torchrun.\n"
        "Note that --use_env is set by default in torchrun.\n"
        "If your script expects `--local_rank` argument to be set, please\n"
        "change it to read from `os.environ['LOCAL_RANK']` instead. See \n"
        "https://pytorch.org/docs/stable/distributed.html#launch-utility for \n"
        "further instructions\n",
        FutureWarning,
    )
    args = parse_args(args)
    launch(args)

The migration guide is documented here

But PyTorch ask user to If your training script reads local rank from a --local_rank cmd argument. Change your training script to read from the LOCAL_RANK environment variable as demonstrated by the following code snippet

However, ignite will pass local_rank parameter to func by default

self._logger.info(f"- Run '{func}' in {idist.get_world_size()} processes") # type: ignore[attr-defined]
local_rank = idist.get_local_rank()
func(local_rank, *args, **kwargs)

I can continue to use torch.distributed.launch for now, but how should I change the program once PyTorch actually deprecates torch.distributed.launch?

@budui budui added the question label Jan 8, 2022
@budui budui changed the title torch.distributed.launch is deprecated, torch.distributed.launch is deprecated Jan 8, 2022
@vfdev-5
Copy link
Collaborator
vfdev-5 commented Jan 8, 2022

Thanks for the report, yes we should update our docs about how to launch training with torchrun.
However in terms of code, I can recheck but ignite IS compatible with torchrun, take a look : #2191
IMO the change between distributed.launch and torchrun is that local rank is always defined as env var now and thus only running command has changed, but in the training script there can be no changes...
Let me know if I missed anything.

@budui
Copy link
Author
budui commented Jan 8, 2022

I got it, and I confirmed that it really doesn't require any code changes.🤦‍♂️Sorry for the confusion.
I previously thought local_rank was specified with a command line argument, but torchrun no longer has that command line argument, so we need to change the code.
But anyway, we need to update the documentation.

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

No branches or pull requests

2 participants
0