Leszek Bukowski commited on
Commit ·
d66b345
1
Parent(s): 8c544ef
Report an expected evaluation restart separately from setup errors
Browse files21 unmodified lines22232425262741 unmodified lines697071727374757628 unmodified lines1051061071081091101111121131141151161171181191201211226 unmodified lines12913013113213313413513613713813914014114214321 unmodified linesimport threadingimport time@contextmanagerdef visible_progress(label):"""Show elapsed time while a long load/download is active."""41 unmodified linesraise RuntimeError("Could not read GPU memory from nvidia-smi. Check the output above before installing.") from excif not math.isfinite(memory_gib) or memory_gib <= 0:raise RuntimeError("Could not read a valid GPU memory capacity. Inspect nvidia-smi output.")print("No memory-size cutoff; native BF16 support will be verified after setup.", flush=True)print("You may try a 24 GB GPU; setup success does not establish that the full evaluation fits.", flush=True)def download_wheel():28 unmodified linesexcept PackageNotFoundError:previous = {}previous_sha = previous.get("hashes", {}).get("sha256") or previous.get("hash", "").removeprefix("sha256=")subprocess.run([sys.executable, "-m", "pip", "install", "--force-reinstall", "--no-deps", str(wheel)], check=True)if loaded_runtime and previous_sha != BOOTSTRAP["sha256"]:raise RuntimeError("The runtime wheel changed while its code was loaded. Restart the kernel, then Run all again.")print("Verified and installed the pinned TheSystem runtime wheel.")def install_runtime():setup = subprocess.run([sys.executable, "-m", "thesystem._vendor.lora.setup_runtime"])if setup.returncode == 10:raise RuntimeError("RESTART REQUIRED: Setup is saved. Restart the Colab session or VS Code kernel, then rerun Prepare runtime.")if setup.returncode != 0:raise RuntimeError(f"Runtime setup failed with exit code {setup.returncode}; inspect the setup output above.")from thesystem._vendor.lora.setup_runtime import verify_runtimeverify_runtime()from thesystem.evaluation.runtime import check_gpu6 unmodified lineswith visible_progress("[1/4] Check Python and the GPU"):check_preflight()with visible_progress("[2/4] Install the pinned download client"):subprocess.run([sys.executable, "-m", "pip", "install", "huggingface-hub==1.31.0"], check=True)with visible_progress("[3/4] Download and verify the evaluation wheel"):download_wheel()with visible_progress("[4/4] Prepare and verify the reference GPU software"):install_runtime()except BaseException:print("NOT READY — resolve the message above, then rerun Prepare runtime.", flush=True)raiseprint("READY — continue to Choose run and save location. Model loading has not started.", flush=True)def prepare_output(RUN_NAME, USE_DRIVE=False):21 unmodified lines222324252627282930313241 unmodified lines7475767778798028 unmodified lines1091101111121131141151161171181191201211221231241251261271281291301311321331346 unmodified lines14114214314414514614714814915015115215315415521 unmodified linesimport threadingimport timeclass RestartRequired(RuntimeError):"""The installed packages need a fresh kernel before evaluation."""@contextmanagerdef visible_progress(label):"""Show elapsed time while a long load/download is active."""41 unmodified linesraise RuntimeError("Could not read GPU memory from nvidia-smi. Check the output above before installing.") from excif not math.isfinite(memory_gib) or memory_gib <= 0:raise RuntimeError("Could not read a valid GPU memory capacity. Inspect nvidia-smi output.")print("No memory-size cutoff. Setup will check native BF16 support.", flush=True)def download_wheel():28 unmodified linesexcept PackageNotFoundError:previous = {}previous_sha = previous.get("hashes", {}).get("sha256") or previous.get("hash", "").removeprefix("sha256=")subprocess.run([sys.executable, "-m", "pip", "install", "--quiet", "--force-reinstall", "--no-deps", str(wheel)], check=True)if loaded_runtime and previous_sha != BOOTSTRAP["sha256"]:raise RestartRequired("Restart the kernel to load the installed evaluation wheel.")print("Verified and installed the pinned TheSystem runtime wheel.")def install_runtime():setup = subprocess.run([sys.executable, "-m", "thesystem._vendor.lora.setup_runtime"],stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)if setup.returncode == 10:raise RestartRequired("Restart the kernel to load the installed GPU packages.")if setup.returncode != 0:print(setup.stdout, flush=True)raise RuntimeError(f"Runtime setup failed with exit code {setup.returncode}; inspect the setup output above.")# The installer just verified a fresh process. Colab may still hold older imports.from importlib.metadata import versionfor name in ("torch", "transformers"):loaded = sys.modules.get(name)if loaded is not None and loaded.__version__ != version(name):raise RestartRequired(f"Restart the kernel to load the installed {name}.")from thesystem._vendor.lora.setup_runtime import verify_runtimeverify_runtime()from thesystem.evaluation.runtime import check_gpu6 unmodified lineswith visible_progress("[1/4] Check Python and the GPU"):check_preflight()with visible_progress("[2/4] Install the pinned download client"):subprocess.run([sys.executable, "-m", "pip", "install", "--quiet", "huggingface-hub==1.31.0"], check=True)with visible_progress("[3/4] Download and verify the evaluation wheel"):download_wheel()with visible_progress("[4/4] Prepare and verify the reference GPU software"):install_runtime()except RestartRequired:return Falseprint("READY — continue to step 2.", flush=True)return Truedef prepare_output(RUN_NAME, USE_DRIVE=False):
prepare_evaluation.py+23-11