MCPcopy Create free account
hub / github.com/ai4ce/RAP / worker_process

Function worker_process

eval_all.py:47–79  ·  view source on GitHub ↗
(gpu_id, task_queue)

Source from the content-addressed store, hash-verified

45
46
47def worker_process(gpu_id, task_queue):
48 env = os.environ.copy()
49 env["CUDA_VISIBLE_DEVICES"] = str(gpu_id)
50
51 while True:
52 task = task_queue.get()
53 if task is None:
54 print(f"[GPU {gpu_id}] No more tasks. Exiting.")
55 break
56
57 name, data_dir, tag, ckpt_path, gs_dir, extra_args = task
58 print(f"[GPU {gpu_id}] Starting: {name}")
59
60 cmd = [
61 sys.executable, "eval.py",
62 "-n", name,
63 "-d", data_dir,
64 "-t", tag,
65 "-p", ckpt_path,
66 "-m", gs_dir
67 ]
68 if extra_args:
69 cmd.extend(extra_args.split())
70
71 log_file = os.path.join(LOG_DIR, f"{name}.log")
72
73 with open(log_file, "w") as lf:
74 process = subprocess.run(cmd, env=env, stdout=lf, stderr=lf)
75
76 if process.returncode != 0:
77 print(f"[GPU {gpu_id}] Task {name} FAILED (Return Code: {process.returncode})")
78 else:
79 print(f"[GPU {gpu_id}] Finished: {name}")
80
81
82def main():

Callers

nothing calls this directly

Calls 2

printFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected