Skip to content

Commit

Permalink
Revert "improve lanuch"
Browse files Browse the repository at this point in the history
  • Loading branch information
ftgreat authored Jan 5, 2023
1 parent 177f13d commit 640d03e
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions flagai/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import socket
from flagai.logger import log_dist

import signal

def fetch_hostfile(hostfile_path):
if not os.path.isfile(hostfile_path):
Expand Down Expand Up @@ -129,12 +128,7 @@ def launch_dist(launcher='distributed_deepspeed',
cmd_launch.append('"')
run_cmd = ' '.join(cmd_launch)
log_dist(run_cmd)
p = subprocess.Popen(run_cmd, shell=True, preexec_fn=os.setsid)
def signal_handler(signal, frame):
os.killpg(os.getpgid(p.pid), 9)
signal.signal(signal.SIGINT, signal_handler)
p.wait()
# subprocess.Popen(run_cmd, shell=True)
subprocess.Popen(run_cmd, shell=True)
node_rank += 1

elif num_nodes == 1 and launcher == 'distributed_torch':
Expand Down Expand Up @@ -164,13 +158,7 @@ def signal_handler(signal, frame):
cmd_launch.append('--not_call_launch')
run_cmd = ' '.join(cmd_launch)
log_dist(run_cmd)
# subprocess.Popen(run_cmd, shell=True)

p = subprocess.Popen(run_cmd, shell=True, preexec_fn=os.setsid)
def signal_handler(signal, frame):
os.killpg(os.getpgid(p.pid), 9)
signal.signal(signal.SIGINT, signal_handler)
p.wait()
subprocess.Popen(run_cmd, shell=True)

elif launcher == 'distributed_deepspeed':
if hostfile is None:
Expand Down Expand Up @@ -218,12 +206,7 @@ def signal_handler(signal, frame):
cmd_launch.append('--not_call_launch')
run_cmd = ' '.join(cmd_launch)
log_dist(run_cmd)
# subprocess.Popen(run_cmd, shell=True)
p = subprocess.Popen(run_cmd, shell=True, preexec_fn=os.setsid)
def signal_handler(signal, frame):
os.killpg(os.getpgid(p.pid), 9)
signal.signal(signal.SIGINT, signal_handler)
p.wait()
subprocess.Popen(run_cmd, shell=True)

elif num_nodes == 1 and launcher == 'simple_torch':
# This launcher
Expand Down Expand Up @@ -255,11 +238,6 @@ def signal_handler(signal, frame):

run_cmd = ' '.join(cmd_launch)
log_dist(run_cmd)
# subprocess.Popen(run_cmd, shell=True)
p = subprocess.Popen(run_cmd, shell=True, preexec_fn=os.setsid)
def signal_handler(signal, frame):
os.killpg(os.getpgid(p.pid), 9)
signal.signal(signal.SIGINT, signal_handler)
p.wait()
subprocess.Popen(run_cmd, shell=True)
else:
raise Exception('No aviable launcher')

0 comments on commit 640d03e

Please sign in to comment.