Skip to content

Commit

Permalink
[parameter_server] fix deadlock in multiprocessing by using spawn (#1025
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hudeven authored Jul 18, 2022
1 parent 91ccd7a commit 7ed7ac7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions distributed/rpc/parameter_server/rpc_parameter_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ def run_worker(rank, world_size, num_gpus, train_loader, test_loader):
os.environ['MASTER_PORT'] = args.master_port
processes = []
world_size = args.world_size

# Note that Linux uses "fork" by default, which may cause deadlock.
# Besides, cuda doesn't support "fork" and Windows only supports "spawn"
mp.set_start_method("spawn")

if args.rank == 0:
p = mp.Process(target=run_parameter_server, args=(0, world_size))
p.start()
Expand Down

0 comments on commit 7ed7ac7

Please sign in to comment.