@@ -50,29 +50,39 @@ def launch(root: Path) -> int:
5050 "cwd" : root ,
5151 "env" : environment ,
5252 "check" : False ,
53+ "stdout" : subprocess .PIPE ,
54+ "stderr" : subprocess .STDOUT ,
55+ "text" : True ,
5356 }
54- if platform .system () == "Windows" :
55- setup_kwargs ["creationflags" ] = subprocess .CREATE_NEW_CONSOLE
5657 setup_result = subprocess .run (
5758 [str (interpreter ), str (setup_script ), "--ensure" ],
5859 ** setup_kwargs ,
5960 )
60- if setup_result .returncode != 0 :
61- verification = subprocess .run (
62- [str (interpreter ), "-c" , "import torch; print(torch.__version__)" ],
63- cwd = root ,
64- env = environment ,
65- capture_output = True ,
66- text = True ,
67- check = False ,
61+ with log_path .open ("a" , encoding = "utf-8" ) as log :
62+ if setup_result .stdout :
63+ log .write ("\n [Launcher] Runtime setup output:\n " )
64+ log .write (setup_result .stdout )
65+ log .flush ()
66+ verification = subprocess .run (
67+ [str (interpreter ), "-c" , "import torch; print(torch.__version__)" ],
68+ cwd = root ,
69+ env = environment ,
70+ capture_output = True ,
71+ text = True ,
72+ check = False ,
73+ )
74+ with log_path .open ("a" , encoding = "utf-8" ) as log :
75+ log .write (
76+ "\n [Launcher] Torch verification: "
77+ f"exit={ verification .returncode } "
78+ f"stdout={ verification .stdout .strip ()!r} "
79+ f"stderr={ verification .stderr .strip ()!r} \n "
6880 )
69- if verification .returncode == 0 :
70- return subprocess .call ([str (interpreter ), str (script )], cwd = root , env = environment )
71- details = ""
72- if log_path .exists ():
73- details = "\n " .join (log_path .read_text (encoding = "utf-8" , errors = "replace" ).splitlines ()[- 12 :])
81+ if setup_result .returncode != 0 or verification .returncode != 0 :
82+ details = "\n " .join (log_path .read_text (encoding = "utf-8" , errors = "replace" ).splitlines ()[- 30 :])
7483 raise RuntimeError (
75- f"Hardware runtime setup failed (exit code { setup_result .returncode } ).\n "
84+ f"Hardware runtime setup failed (setup exit code { setup_result .returncode } , "
85+ f"verification exit code { verification .returncode } ).\n "
7686 f"Detailed log: { log_path } \n { details } "
7787 )
7888 return subprocess .call ([str (interpreter ), str (script )], cwd = root , env = environment )
0 commit comments