| 31 | |
| 32 | |
| 33 | def worker_process(gpu_id, task_queue): |
| 34 | env = os.environ.copy() |
| 35 | env["CUDA_VISIBLE_DEVICES"] = str(gpu_id) |
| 36 | |
| 37 | while True: |
| 38 | task = task_queue.get() |
| 39 | if task is None: |
| 40 | print(f"[GPU {gpu_id}] No more tasks. Exiting.") |
| 41 | break |
| 42 | |
| 43 | name, config_path, gs_dir, extra_args = task |
| 44 | print(f"[GPU {gpu_id}] Starting: {name}") |
| 45 | |
| 46 | cmd = [ |
| 47 | sys.executable, "rap.py", |
| 48 | "-c", config_path, |
| 49 | "-m", gs_dir, |
| 50 | ] |
| 51 | if extra_args: |
| 52 | cmd.extend(extra_args.split()) |
| 53 | |
| 54 | log_file = os.path.join(LOG_DIR, f"{name}.log") |
| 55 | |
| 56 | with open(log_file, "w") as lf: |
| 57 | process = subprocess.run(cmd, env=env, stdout=lf, stderr=lf) |
| 58 | |
| 59 | if process.returncode != 0: |
| 60 | print(f"[GPU {gpu_id}] Task {name} FAILED (Return Code: {process.returncode})") |
| 61 | else: |
| 62 | print(f"[GPU {gpu_id}] Finished: {name}") |
| 63 | |
| 64 | |
| 65 | def main(): |