GPU-Kern turn_fabrik: Nachweis im Wartezustand (je Pause: Dauer, eigene CPU-Zeit, hoechste Kartenlast laut NVML), lokal im Protokoll
Probe am Mac mit Schein-Sperre: 90 s Pause, 0,0 s CPU in der Pause, danach von selbst weiter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -77,6 +77,19 @@ def karte_frei_gb():
|
||||
_NVML = None
|
||||
|
||||
|
||||
def gpu_last_prozent():
|
||||
"""Kartenlast in Prozent ueber NVML (ctypes), None ohne NVML."""
|
||||
import ctypes
|
||||
if _NVML is None and karte_frei_gb() is None:
|
||||
return None
|
||||
lib, h = _NVML
|
||||
|
||||
class Last(ctypes.Structure):
|
||||
_fields_ = [("gpu", ctypes.c_uint), ("memory", ctypes.c_uint)]
|
||||
l = Last()
|
||||
return int(l.gpu) if lib.nvmlDeviceGetUtilizationRates(h, ctypes.byref(l)) == 0 else None
|
||||
|
||||
|
||||
def live_river_ms(port):
|
||||
"""Eine River-Probe (Menue welt, Ziel 0,5 %) gegen den Live-Dienst: Millisekunden bis zur Antwort, None bei Fehler oder Zeitueberschreitung."""
|
||||
try:
|
||||
@@ -172,6 +185,20 @@ def main():
|
||||
frei = karte_frei_gb()
|
||||
return frei is not None and frei < a.karte_frei_gb
|
||||
|
||||
def warte_pause():
|
||||
"""Wartet in 30-s-Schritten, solange Platte, Laeufer, Farm-Pause, Live-Dienst oder Karte es verlangen. Fuer jede Pause eine Zeile:
|
||||
Dauer, eigene CPU-Zeit in der Pause (Nachweis: kein drehender Faden) und hoechste Kartenlast laut NVML (Nachweis: 0 %)."""
|
||||
t0, c0, last_max, n = time.time(), time.process_time(), 0, 0
|
||||
while (shutil.disk_usage(a.ausgabe).free < a.frei_gb * 1e9 or karte_knapp()) and not os.path.exists(halt):
|
||||
n += 1
|
||||
time.sleep(30)
|
||||
g = gpu_last_prozent()
|
||||
if g is not None:
|
||||
last_max = max(last_max, g)
|
||||
if n:
|
||||
print(json.dumps(dict(pause_ende=time.strftime("%Y-%m-%d %H:%M:%S"), pause_s=round(time.time() - t0, 1),
|
||||
cpu_s_in_pause=round(time.process_time() - c0, 2), karte_last_max_prozent=last_max, pruefungen=n)), flush=True)
|
||||
|
||||
def rechne(stapel):
|
||||
nonlocal nr, zahl
|
||||
# je (Flop, Groessenklasse) ein Aufruf: blattwert loest die Blaetter in einem Strom, dessen Plaetze nach dem groessten Baum
|
||||
@@ -233,8 +260,7 @@ def main():
|
||||
genommen += 1
|
||||
stapel.append(z)
|
||||
if len(stapel) >= a.stapel:
|
||||
while (shutil.disk_usage(a.ausgabe).free < a.frei_gb * 1e9 or karte_knapp()) and not os.path.exists(halt):
|
||||
time.sleep(30)
|
||||
warte_pause()
|
||||
rechne(stapel)
|
||||
fertig.update(str(x["id"]) for x in stapel)
|
||||
stapel = []
|
||||
|
||||
Reference in New Issue
Block a user