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

added port argument for ssh #4117

Merged
merged 18 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion deepspeed/launcher/multinode_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def parse_user_args(self):

def get_cmd(self, environment, active_resources):
environment['PDSH_RCMD_TYPE'] = 'ssh'
if self.args.ssh_port is not None: # only specify ssh port if it is specified
environment["PDSH_SSH_ARGS_APPEND"] = f" -p {self.args.ssh_port}"

active_workers = ",".join(active_resources.keys())
logger.info("Running on the following workers: %s" % active_workers)
Expand Down Expand Up @@ -101,7 +103,7 @@ def get_cmd(self, environment, active_resources):
cmd_to_search = [i + "\\" for i in deepspeed_launch[2:6]]

kill_command = pdsh_cmd_args + ["pkill -f ", " ".join(cmd_to_search)[:-2]]
return pdsh_cmd_args + deepspeed_launch + [self.user_script] + self.user_arguments, kill_command
return pdsh_cmd_args + deepspeed_launch + [self.user_script] + self.user_arguments, kill_command, environment


class OpenMPIRunner(MultiNodeRunner):
Expand Down
13 changes: 8 additions & 5 deletions deepspeed/launcher/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ def parse_args(args=None):
"numbers and range. i.e. 1,3-5,7 => [1,3,4,5,7]. When not "
"specified, all cores on system would be used rank binding")

parser.add_argument("--ssh_port", type=int, default=None, help="SSH port to use for remote connections")

return parser.parse_args(args=args)


Expand Down Expand Up @@ -432,10 +434,11 @@ def main(args=None):
if multi_node_exec and not args.no_ssh_check:
first_host = list(active_resources.keys())[0]
try:
subprocess.check_call(f'ssh -o PasswordAuthentication=no {first_host} hostname',
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
shell=True)
ssh_check_cmd = "ssh -o PasswordAuthentication=no "
if args.ssh_port is not None:
ssh_check_cmd += f"-p {args.ssh_port} "
ssh_check_cmd += f"{first_host} hostname"
subprocess.check_call(ssh_check_cmd, stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL, shell=True)
except subprocess.CalledProcessError:
raise RuntimeError(
f"Using hostfile at {args.hostfile} but host={first_host} was not reachable via ssh. If you are running with a single node please remove {args.hostfile} or setup passwordless ssh."
Expand Down Expand Up @@ -560,7 +563,7 @@ def main(args=None):
runner.add_export(key, val)

if args.launcher == PDSH_LAUNCHER:
cmd, kill_cmd = runner.get_cmd(env, active_resources)
cmd, kill_cmd, env = runner.get_cmd(env, active_resources)
else:
cmd = runner.get_cmd(env, active_resources)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/launcher/test_multinode_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def runner_info():
def test_pdsh_runner(runner_info):
env, resource_pool, world_info, args = runner_info
runner = mnrunner.PDSHRunner(args, world_info)
cmd, kill_cmd = runner.get_cmd(env, resource_pool)
cmd, kill_cmd, env = runner.get_cmd(env, resource_pool)
assert cmd[0] == 'pdsh'
assert env['PDSH_RCMD_TYPE'] == 'ssh'

Expand Down