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

port and shell #74

Merged
merged 5 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
port and shell
  • Loading branch information
shh2000 committed May 17, 2023
commit cd3fa344549922adede46c517b5188695fb760ae
3 changes: 3 additions & 0 deletions training/run_benchmarks/config/cluster_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
# Hosts port to run the tensorflow distribution_strategy = 'multi_worker_mirrored'
HOSTS_PORTS = ["2222"]

# Master port to connect
MASTER_PORT = "29501"

# ssh connection port
SSH_PORT = "22"
22 changes: 17 additions & 5 deletions training/run_benchmarks/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,27 @@ def stop_monitors_in_cluster(dp_path, nnodes):


def start_tasks_in_cluster(dp_path, container_name, case_config, base_args,
count, stdout, nullout):
count, stdout, nullout, curr_log_path):
'''Start tasks in cluster, and NOT wait.'''
framework = case_config["framework"]
nnodes = case_config["nnodes"]
env_file = os.path.join(
tc.FLAGPERF_PATH, tc.VENDOR,
case_config["model"] + "-" + case_config["framework"],
"config/environment_variables.sh")
start_cmd = "cd " + dp_path + " && " + sys.executable \
if (os.path.isfile(env_file)):
start_cmd = "cd " + dp_path + " && " + sys.executable \
+ " utils/container_manager.py -o runcmdin -c " \
+ container_name + " -d -r \"source " + env_file \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start_task_cmd 里也包含了 source env_file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对的。这些环境变量尚未在进入容器前被配置好,因此在start_task_cmd(手动)中需要先source env,然后python3 startxx.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已更新dev.py,对后面的start_task_cmd也做了如此处理。但start_task_cmd中存在envfile时,不需要重定向,只需要把;改成&&。因为这条命令是在容器内手动输入的,可以直接看到报错并停止运行
另外,run.py无更新内容。start_task_cmd是dev.py特有的,用于输出手动命令的。run.py中无相关逻辑

+ " > " + curr_log_path + "/source_env.log.txt " \
+ "2>&1 && " \
+ "python3 " + tc.FLAGPERF_PATH + "/run_benchmarks/" \
+ framework + "/start_" + framework + "_task.py " \
+ base_args + " --round " + str(count)
else:
start_cmd = "cd " + dp_path + " && " + sys.executable \
+ " utils/container_manager.py -o runcmdin -c " \
+ container_name + " -d -r \"source " + env_file + "; " \
+ container_name + " -d -r \"" \
+ "python3 " + tc.FLAGPERF_PATH + "/run_benchmarks/" \
+ framework + "/start_" + framework + "_task.py " \
+ base_args + " --round " + str(count)
Expand Down Expand Up @@ -626,7 +636,8 @@ def main(stdout, nullout):
+ " --log_dir " + log_dir_container \
+ " --log_level " + tc.FLAGPERF_LOG_LEVEL \
+ " --extern_config_file " + case_config["config"] \
+ ".py" + " --enable_extern_config "
+ ".py" + " --enable_extern_config " \
+ " --master_port " + cc.MASTER_PORT
RUN_LOGGER.info("=== 2.2 Prepare case config in cluster. ===")
if not prepare_case_config_cluster(dp_path, case_config, case):
RUN_LOGGER.warning("Prepare case config in cluster...[FAILED]. " +
Expand All @@ -648,7 +659,8 @@ def main(stdout, nullout):
continue
RUN_LOGGER.info("2) Start tasks in the cluster...")
start_tasks_in_cluster(dp_path, container_name, case_config,
base_args, count, stdout, nullout)
base_args, count, stdout, nullout,
curr_log_path)

# Wait until start_xxx_task.py finished.
RUN_LOGGER.info("3) Waiting for tasks end in the cluster...")
Expand Down
21 changes: 16 additions & 5 deletions training/run_benchmarks/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,27 @@ def stop_monitors_in_cluster(dp_path, nnodes):


def start_tasks_in_cluster(dp_path, container_name, case_config, base_args,
count):
count, curr_log_path):
'''Start tasks in cluster, and NOT wait.'''
framework = case_config["framework"]
nnodes = case_config["nnodes"]
env_file = os.path.join(
tc.FLAGPERF_PATH, tc.VENDOR,
case_config["model"] + "-" + case_config["framework"],
"config/environment_variables.sh")
start_cmd = "cd " + dp_path + " && " + sys.executable \
if (os.path.isfile(env_file)):
start_cmd = "cd " + dp_path + " && " + sys.executable \
+ " utils/container_manager.py -o runcmdin -c " \
+ container_name + " -d -r \"source " + env_file \
+ " > " + curr_log_path + "/source_env.log.txt " \
+ "2>&1 && " \
+ "python3 " + tc.FLAGPERF_PATH + "/run_benchmarks/" \
+ framework + "/start_" + framework + "_task.py " \
+ base_args + " --round " + str(count)
else:
start_cmd = "cd " + dp_path + " && " + sys.executable \
+ " utils/container_manager.py -o runcmdin -c " \
+ container_name + " -d -r \"source " + env_file + "; " \
+ container_name + " -d -r \"" \
+ "python3 " + tc.FLAGPERF_PATH + "/run_benchmarks/" \
+ framework + "/start_" + framework + "_task.py " \
+ base_args + " --round " + str(count)
Expand Down Expand Up @@ -582,7 +592,8 @@ def main():
+ " --log_dir " + log_dir_container \
+ " --log_level " + tc.FLAGPERF_LOG_LEVEL \
+ " --extern_config_file " + case_config["config"] \
+ ".py" + " --enable_extern_config "
+ ".py" + " --enable_extern_config " \
+ " --master_port " + cc.MASTER_PORT
RUN_LOGGER.info("=== 2.2 Prepare case config in cluster. ===")
if not prepare_case_config_cluster(dp_path, case_config, case):
RUN_LOGGER.warning("Prepare case config in cluster...[FAILED]. " +
Expand All @@ -604,7 +615,7 @@ def main():
continue
RUN_LOGGER.info("2) Start tasks in the cluster...")
start_tasks_in_cluster(dp_path, container_name, case_config,
base_args, count)
base_args, count, curr_log_path)

# Wait until start_xxx_task.py finished.
RUN_LOGGER.info("3) Waiting for tasks end in the cluster...")
Expand Down