From dc07ce7279566bcab32eaa6672a70d273e42692f Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Thu, 3 Dec 2026 02:39:55 +0100 Subject: [PATCH] GPU-Kern turn_fabrik: mehrere Eingaben, --folgen (wachsende Dateien neu lesen), fabrik_start.ps1 fuer den Spielrechner Eigener Prozess pokerbench-gpukern-turnfabrik.exe aus dem Messordner, nie ueber den Dienst; unfertige letzte Zeilen werden beim naechsten Lesen genommen. Probe Metal: fehlende Datei uebersprungen, 3 Blaetter, Ende per HALT. Co-Authored-By: Claude Opus 5.5 --- messung/gpu/kern/turn/turn_fabrik.py | 54 ++++++++++++++--------- messung/gpu/kern/windows/fabrik_start.ps1 | 19 ++++++++ 2 files changed, 52 insertions(+), 21 deletions(-) create mode 100644 messung/gpu/kern/windows/fabrik_start.ps1 diff --git a/messung/gpu/kern/turn/turn_fabrik.py b/messung/gpu/kern/turn/turn_fabrik.py index 6b3360a4..939f226f 100644 --- a/messung/gpu/kern/turn/turn_fabrik.py +++ b/messung/gpu/kern/turn/turn_fabrik.py @@ -73,7 +73,8 @@ def schreibe_teil(ordner, zeilen, cfv, nr): def main(): ap = argparse.ArgumentParser() - ap.add_argument("--eingabe", required=True) + ap.add_argument("--eingabe", required=True, nargs="+", help="eine oder mehrere JSONL-Dateien (fehlende werden uebersprungen)") + ap.add_argument("--folgen", type=float, default=0, help="nach dem Ende der Dateien so viele Sekunden warten und neu lesen (0 = enden)") ap.add_argument("--ausgabe", required=True) ap.add_argument("--geraet", default="cuda") ap.add_argument("--ziel", type=float, default=0.5, help="Ziel je Teilspiel in Prozent des Topfs") @@ -117,27 +118,38 @@ def main(): std = (time.time() - t0) / 3600 print(json.dumps(dict(teil=name, blaetter=len(stapel), teilspiele=len(zeilen), gesamt=zahl, je_stunde=round(zahl / max(std, 1e-9)))), flush=True) - with open(a.eingabe) as f: - for zeile in f: - if os.path.exists(halt): - break - if not zeile.strip(): + while True: + for pfad in a.eingabe: + if not os.path.exists(pfad) or os.path.exists(halt): continue - z = json.loads(zeile) - if str(z["id"]) in fertig: - continue - if a.max_blaetter and genommen >= a.max_blaetter: - break - genommen += 1 - stapel.append(z) - if len(stapel) >= a.stapel: - while shutil.disk_usage(a.ausgabe).free < a.frei_gb * 1e9 and not os.path.exists(halt): - time.sleep(30) - rechne(stapel) - stapel = [] - if stapel and not os.path.exists(halt): - rechne(stapel) - + with open(pfad) as f: + for zeile in f: + if os.path.exists(halt): + break + if not zeile.strip() or not zeile.endswith("\n"): + continue # unfertige letzte Zeile (Datei waechst): beim naechsten Lesen + z = json.loads(zeile) + if str(z["id"]) in fertig or any(str(z["id"]) == str(x["id"]) for x in stapel): + continue + if a.max_blaetter and genommen >= a.max_blaetter: + break + genommen += 1 + stapel.append(z) + if len(stapel) >= a.stapel: + while shutil.disk_usage(a.ausgabe).free < a.frei_gb * 1e9 and not os.path.exists(halt): + time.sleep(30) + rechne(stapel) + fertig.update(str(x["id"]) for x in stapel) + stapel = [] + if stapel and not os.path.exists(halt): + rechne(stapel) + fertig.update(str(x["id"]) for x in stapel) + stapel = [] + if not a.folgen or os.path.exists(halt) or (a.max_blaetter and genommen >= a.max_blaetter): + break + ende = time.time() + a.folgen + while time.time() < ende and not os.path.exists(halt): + time.sleep(5) if __name__ == "__main__": main() diff --git a/messung/gpu/kern/windows/fabrik_start.ps1 b/messung/gpu/kern/windows/fabrik_start.ps1 new file mode 100644 index 00000000..cfa80768 --- /dev/null +++ b/messung/gpu/kern/windows/fabrik_start.ps1 @@ -0,0 +1,19 @@ +# Startet die Turn-Fabrik (turn/turn_fabrik.py) auf dem Spielrechner abgekoppelt: eigener Prozess (NICHT der GPU-Dienst), ohne Fenster, +# Prioritaet BelowNormal, Prozessname pokerbench-gpukern-turnfabrik.exe, Code aus dem Messordner D:\Projects\pf-gpu-kern-mess. +# Halt: Datei \HALT anlegen. Ausgabe nur auf D: (echte Lagen, nie ins Git); Protokoll \fabrik.log (nur anhaengen). +# powershell -NoProfile -ExecutionPolicy Bypass -File fabrik_start.ps1 [-SpeicherGB 3] [-Ziel 0.5] +param([double]$SpeicherGB = 3.0, [double]$Ziel = 0.5, [string]$Ausgabe = 'D:\Projects\pokerfreak-daten\gpu\turnwurzel') +$wurzel = 'D:\Projects\pf-gpu-kern-mess' +New-Item -ItemType Directory -Force -Path $Ausgabe | Out-Null +if (Get-Process -Name 'pokerbench-gpukern-turnfabrik' -ErrorAction SilentlyContinue) { "laeuft schon"; exit 1 } +$halt = Join-Path $Ausgabe 'HALT' +if (Test-Path $halt) { Remove-Item $halt } +$exe = 'D:\Projects\venv-gpu\Scripts\pokerbench-gpukern-turnfabrik.exe' +if (-not (Test-Path $exe)) { Copy-Item 'D:\Projects\venv-gpu\Scripts\python.exe' $exe } +$skript = Join-Path $wurzel 'messung\gpu\kern\turn\turn_fabrik.py' +$log = Join-Path $Ausgabe 'fabrik.log' +$ein = 'D:\Projects\pokerfreak-daten\gpu\flopblaetter.jsonl D:\Projects\pokerfreak-daten\gpu\flopblaetter-mac.jsonl' +$kommando = "cmd /c `"set GPU_KERN_CUDA_SCHED=block&& `"$exe`" -u `"$skript`" --eingabe $ein --ausgabe `"$Ausgabe`" --geraet cuda --ziel $Ziel --stapel 8 --speicher-gb $SpeicherGB --folgen 300 >> `"$log`" 2>&1`"" +$start = New-CimInstance -ClassName Win32_ProcessStartup -ClientOnly -Property @{ ShowWindow = [uint16]0; PriorityClass = [uint32]16384 } +$r = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{ CommandLine = $kommando; CurrentDirectory = $wurzel; ProcessStartupInformation = $start } +"Rueckgabe $($r.ReturnValue), cmd-PID $($r.ProcessId); Protokoll $log; Halt: $halt"