File size: 1,190 Bytes
ed552fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
独立 launcher — 运行后关闭父进程,子进程继续运行。
在远程执行: F:\f\pyopenfoam-gpu\python.exe Code\scripts\detached_train.py
"""
import subprocess
import os
import sys

os.chdir(r"F:\agent-workspace\paper2")
os.environ["PYTHONUNBUFFERED"] = "1"

log_path = r"Exp\results\R1\train_log.txt"

# 用 CREATE_NEW_PROCESS_GROUP + DETACHED_PROCESS 脱离父进程
flags = 0x00000200 | 0x00000008  # DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP

with open(log_path, "w") as log:
    proc = subprocess.Popen(
        [
            r"F:\f\pyopenfoam-gpu\python.exe", "-u",
            r"Code\scripts\resolution_generalization.py",
            "--checkpoint_root", "checkpoints",
            "--output_dir", r"Exp\results\R1",
            "--train_resolutions", "64", "256",
            "--skip_generalization",
            "--n_rollout_steps", "50",
            "--epochs_s1", "50",
            "--epochs_s2", "30",
            "--seed", "42",
            "--device", "cuda",
        ],
        stdout=log,
        stderr=subprocess.STDOUT,
        creationflags=flags,
    )

    print(f"PID={proc.pid}", flush=True)
    # 不等待 — 父进程退出后子进程继续