deepspeedai / deepspeedai/DeepSpeed

[BUG] TypeError when deepspeed.init_distributed()

Open
#1,720 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
43.1k
Forks
5k
Avg merge
4d 15h
Merged PRs (30d)
112

Description

Describe the bug
When I used deepspeed.init_distributed(), TypeError happened in torch codes. It seems that some arguments deepspeed passed to torch are incompatible.

To Reproduce
I provide a code snippet to help to reproduce the bug.

def debug():
    parser = argparse.ArgumentParser()
    parser.add_argument('-n', '--nodes', default=nodes,
                        type=int, metavar='N')
    parser.add_argument('-g', '--gpus', default=gpus, type=int,
                        help='number of gpus per node')
    parser.add_argument('-nr', '--nr', default=0, type=int,
                        help='ranking within the nodes')
    parser.add_argument("--local_rank", default=0, type=int,
                        help="local_rank for distributed training on gpus")
    parser = deepspeed.add_config_arguments(parser)
    args = parser.parse_args()
    args.world_size = args.gpus * args.nodes  #
    os.environ['MASTER_ADDR'] = 'localhost'  #
    os.environ['MASTER_PORT'] = '123478'  #
    os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2,3'
    args.local_rank = int(os.environ['LOCAL_RANK'])
    deepspeed.init_distributed()

if __name__ == '__main__':
    debug()

then use deepspeed --num_gpus=4 main.py --deepspeed to run the script.

Screenshots
Here I provide the output.

Traceback (most recent call last):
  File "train.py", line 343, in <module>
    debug()
  File "train.py", line 338, in debug
    deepspeed.init_distributed()
  File "/home/huangbz/.conda/envs/Graph/lib/python3.6/site-packages/deepspeed/utils/distributed.py", line 51, in init_distributed
    init_method=init_method)
  File "/home/huangbz/.conda/envs/Graph/lib/python3.6/site-packages/torch/distributed/distributed_c10d.py", line 576, in init_process_group
    store, rank, world_size = next(rendezvous_iterator)
  File "/home/huangbz/.conda/envs/Graph/lib/python3.6/site-packages/torch/distributed/rendezvous.py", line 229, in _env_rendezvous_handler
    store = _create_c10d_store(master_addr, master_port, rank, world_size, timeout)
  File "/home/huangbz/.conda/envs/Graph/lib/python3.6/site-packages/torch/distributed/rendezvous.py", line 158, in _create_c10d_store
    hostname, port, world_size, start_daemon, timeout, multi_tenant=True
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. torch._C._distributed_c10d.TCPStore(host_name: str, port: int, world_size: int = -1, is_master: bool = False, timeout: datetime.timede
lta = datetime.timedelta(0, 300), wait_for_workers: bool = True, multi_tenant: bool = False)

Invoked with: 'localhost', 123478, 4, False, datetime.timedelta(0, 1800); kwargs: multi_tenant=True

System info (please complete the following information):

  • OS: Ubuntu 18.04
  • GPU count : 4
  • Python version: 3.6
  • torch version: 1.10.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at deepspeed.init_distributed() and follow the traceback into torch.distributed.rendezvous and _create_c10d_store for the reported torch 1.10.1 environment. Compare the TCPStore invocation with the constructor signature shown in the traceback; done means the provided deepspeed command initializes distributed training without this TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.