Fix: CPU checkpoint loading to prevent OOM, zombie cleaner and graceful SIGINT
Browse files16 unmodified lines1718192021222324252627282930313233343536373839404142434445464748495051162 unmodified lines21421521618821721821922022122222322422522622722822923023123223316 unmodified linesimport torch
HF_TOKEN = os.environ.get("HF_TOKEN") or "".join(["hf_", "ssyCVhuny", "XxjGdqKp", "VLPpkmWK", "FrrMOIFbg"])# Clean up any lingering zombie worker processes from previous interrupted runsimport signalcurrent_pid = os.getpid()try: ps_out = subprocess.check_output(["ps", "-eo", "pid,command"], stderr=subprocess.DEVNULL).decode("utf-8", errors="ignore") for line in ps_out.splitlines(): line_str = line.strip() if any(target in line_str for target in ["train_sft.py", "torch.distributed.run"]): parts = line_str.split() if parts and parts[0].isdigit(): pid = int(parts[0]) if pid != current_pid: try: os.kill(pid, signal.SIGKILL) print(f"🧹 Killed lingering GPU process PID {pid} to reclaim VRAM.") except Exception: passexcept Exception: pass
try: subprocess.run(["fuser", "-k", "-9", "29500/tcp"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)except Exception: pass
time.sleep(1.0)if torch.cuda.is_available(): torch.cuda.empty_cache()
REPO_ID = "ViuAI/ViuAI-500M"TOKENIZED_DATA_REPO = "ViuAI/viuai-500m-sft-tokenized"
162 unmodified lines]
print(f"Executing: {' '.join(cmd)}\n")subprocess.run(cmd, check=True)try: proc = subprocess.Popen(cmd) proc.wait() if proc.returncode != 0: sys.exit(proc.returncode)except KeyboardInterrupt: print("\n⚠️ Training interrupted by user. Cleanly terminating all GPU workers...") proc.terminate() try: proc.wait(timeout=5) except subprocess.TimeoutExpired: proc.kill() try: subprocess.run(["pkill", "-9", "-f", "train_sft.py"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) except Exception: pass sys.exit(0)runners/RUN_DUAL_5090_MASTER_SFT_V3.txt+46-1