From f6b62f00707baf582bc168c15886732ac5218524 Mon Sep 17 00:00:00 2001 From: faddddeout <39449491+injet-zhou@users.noreply.github.com> Date: Thu, 27 Jun 2024 09:58:00 +0000 Subject: [PATCH] Exit the process with the subprocess's return code when utilizing the CLI --- src/llamafactory/cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/llamafactory/cli.py b/src/llamafactory/cli.py index e4846780..c92f556b 100644 --- a/src/llamafactory/cli.py +++ b/src/llamafactory/cli.py @@ -91,7 +91,7 @@ def main(): master_addr = os.environ.get("MASTER_ADDR", "127.0.0.1") master_port = os.environ.get("MASTER_PORT", str(random.randint(20001, 29999))) logger.info("Initializing distributed tasks at: {}:{}".format(master_addr, master_port)) - subprocess.run( + subproc = subprocess.run( ( "torchrun --nnodes {nnodes} --node_rank {node_rank} --nproc_per_node {nproc_per_node} " "--master_addr {master_addr} --master_port {master_port} {file_name} {args}" @@ -106,6 +106,7 @@ def main(): ), shell=True, ) + sys.exit(subproc.returncode) else: run_exp() elif command == Command.WEBDEMO: