mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 06:53:19 -10:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdcb8dacbd | ||
|
|
349a934eb9 | ||
|
|
3a22cede8e |
No files matched your search
@@ -76,6 +76,9 @@ BLENDER = os.environ.get("RAEA_FARM_BLENDER", "5.3.0")
|
||||
RAEA_GPUS = os.environ.get("RAEA_FARM_RAEA_GPUS", "T4,A10,L4").split(",")
|
||||
BLENDER_GPUS = os.environ.get("RAEA_FARM_BLENDER_GPUS", "L40S,RTX-PRO-6000,L4").split(",")
|
||||
GPUS = int(os.environ.get("RAEA_FARM_GPUS", "10")) # Modal Starter's GPU limit; Team's is 50
|
||||
# one job's GPUs unless it asks for more: a 1,150-frame cut took all 10 (each drawing 10-20 s), so every other render in
|
||||
# the workspace queued behind it with nothing said (11-30, StreetTalk's three agents); 4 lets two or three render at once
|
||||
JOB_GPUS = int(os.environ.get("RAEA_FARM_JOB_GPUS", "4"))
|
||||
ROOT = "/farm"
|
||||
JOBS = f"{ROOT}/jobs"
|
||||
|
||||
@@ -125,7 +128,11 @@ image = (
|
||||
# the job at once instead of installing it on a GPU's clock
|
||||
"RAEA_TOKENSYNTH": "/models/tokensynth", "RAEA_TOKENSYNTH_DEVICE": "cuda", "RAEA_AUDIO_AUTOSETUP": "0",
|
||||
# Stable Audio Open small on ONNX Runtime with CUDA, as deploy/modal/sao.py installs it (CR25)
|
||||
"RAEA_SAO": "/models/sao"})
|
||||
"RAEA_SAO": "/models/sao",
|
||||
# a video's runs encoded by the ffmpeg CLI's libx264 at the quality's CRF (master 11), not openh264 at a
|
||||
# bitrate: openh264's near-blacks stepped into blocks even at master's 37.7 Mbps, raea check's blotching
|
||||
# failed every Dutch cut, and its agent re-encoded each one with x264 after the render (11-30)
|
||||
"RAEA_MEDIA": "ffmpeg"})
|
||||
.add_local_python_source("farm_plan", "farm_media", "prices", "farm_scene")
|
||||
)
|
||||
|
||||
@@ -573,7 +580,7 @@ def api():
|
||||
if not isinstance(args, list) or not all(isinstance(a, str) for a in args):
|
||||
raise HTTPException(400, "args must be a JSON array of strings: raea's own arguments")
|
||||
q = req.query_params
|
||||
opts = {"gpus": min(int(q.get("gpus", GPUS)), GPUS), "gpu": q.get("gpu"), "max_usd": float(q["max_usd"]) if "max_usd" in q else None, "media": q.get("media") == "1"}
|
||||
opts = {"gpus": min(int(q.get("gpus", JOB_GPUS)), GPUS), "gpu": q.get("gpu"), "max_usd": float(q["max_usd"]) if "max_usd" in q else None, "media": q.get("media") == "1"}
|
||||
id = str(uuid.uuid4())
|
||||
work = f"{JOBS}/{id}/work"
|
||||
async with gate.use():
|
||||
|
||||
@@ -44,6 +44,34 @@ def splittable(args):
|
||||
return out is not None and (out.endswith(VIDEO) or not os.path.splitext(out)[1]) and any(COMPOSITION.search(a) for a in rest[1:])
|
||||
|
||||
|
||||
# how often a job's log says it's still waiting on a GPU run: from outside, a run queued behind the workspace's GPU
|
||||
# limit and one still drawing look the same, and a silent wait read as a stall (11-30: StreetTalk's agents said "stalled
|
||||
# before frame 0" while another app held all 10 of the workspace's GPUs)
|
||||
WAIT_SAY_S = 30
|
||||
|
||||
|
||||
def waited(fn, log, *a, **kw):
|
||||
"""fn.remote(*a, **kw), saying in the log every WAIT_SAY_S that it has no answer yet."""
|
||||
if not hasattr(fn, "spawn"):
|
||||
return fn.remote(*a, **kw)
|
||||
try:
|
||||
import modal.exception as me
|
||||
timeouts = (TimeoutError, me.TimeoutError)
|
||||
except Exception:
|
||||
timeouts = (TimeoutError,)
|
||||
call = fn.spawn(*a, **kw)
|
||||
t = time.time()
|
||||
while True:
|
||||
try:
|
||||
return call.get(timeout=WAIT_SAY_S)
|
||||
except timeouts as e:
|
||||
# Modal's FunctionTimeoutError is a TimeoutError too: the run itself ran out of time, so it goes up as
|
||||
# .remote() raised it, not waited on again (it would answer the same at once, forever)
|
||||
if type(e).__name__ == "FunctionTimeoutError":
|
||||
raise
|
||||
log(f"raea farm: waiting {time.time() - t:.0f} s for a GPU run to answer (queued while the workspace's GPUs are busy, or still drawing)")
|
||||
|
||||
|
||||
def gpus_for(frames, frame_s, start_s, most):
|
||||
"""The GPUs worth starting for `frames` frames of `frame_s` each, when each one first spends `start_s`: the most that
|
||||
keep each one's start at most SHARE of its time, never more than `most`."""
|
||||
@@ -190,7 +218,7 @@ def raea_render(args, opts, work, log, render, cpu_env, run, reload=lambda: None
|
||||
if out.endswith(VIDEO):
|
||||
t = threading.Thread(target=lambda: run(["raea", *rest, "-o", sound], cwd=work, env=cpu_env))
|
||||
t.start()
|
||||
p = bill.add(render.remote(id, rest, probe=True))
|
||||
p = bill.add(waited(render, log, id, rest, probe=True))
|
||||
if p["code"] or not p["length"]:
|
||||
log(p["out"], err=True)
|
||||
if not p["code"]:
|
||||
@@ -200,7 +228,7 @@ def raea_render(args, opts, work, log, render, cpu_env, run, reload=lambda: None
|
||||
log(f"raea farm: {length} frames at {p['w']}x{p['h']}, {fps} fps; frame 0 on a {kind} in {p['s']:.1f} s")
|
||||
video = out.endswith(VIDEO)
|
||||
n0 = min(length, FIRST)
|
||||
r0 = bill.add(render.remote(id, rest, list(range(n0)), 0, video=video))
|
||||
r0 = bill.add(waited(render, log, id, rest, list(range(n0)), 0, video=video))
|
||||
if r0["code"]:
|
||||
log(r0["out"], err=True)
|
||||
return r0["code"]
|
||||
@@ -321,7 +349,7 @@ def blender(args, opts, work, log, render, run, reload=lambda: None, bill=None):
|
||||
if video:
|
||||
o |= {"video": True, "fps": info["fps"]}
|
||||
log(f"raea farm: {blend}, frames {first}-{last} ({info['engine']}), at {info['fps']:g} fps")
|
||||
r0 = bill.add(render.remote(id, blend, first, first, o))
|
||||
r0 = bill.add(waited(render, log, id, blend, first, first, o))
|
||||
if r0["code"]:
|
||||
log(r0["out"], err=True)
|
||||
return r0["code"]
|
||||
@@ -366,7 +394,7 @@ def dispatch(args, opts, work, log, render, blender_render, cpu_env, run, reload
|
||||
if splittable(args):
|
||||
code = raea_render(args, opts, work, log, render, cpu_env, run, reload, bill)
|
||||
else:
|
||||
r = bill.add(render.remote(opts["id"], args))
|
||||
r = bill.add(waited(render, log, opts["id"], args))
|
||||
log(r["out"], err=bool(r["code"]))
|
||||
code = r["code"]
|
||||
log(bill.line())
|
||||
|
||||
@@ -158,4 +158,35 @@ b.add({"code": 1, "out": "no task id"})
|
||||
assert "2 GPU containers up 35 s" in b.line(), b.line()
|
||||
ok("the bill: each container from its boot or the job's start to its last run, plus its boot and idle seconds")
|
||||
|
||||
# a GPU run with no answer yet is said in the log, not waited on in silence; its answer still comes back
|
||||
class SlowCall:
|
||||
def __init__(self, waits): self.waits = waits
|
||||
def get(self, timeout=None):
|
||||
if self.waits:
|
||||
self.waits -= 1
|
||||
raise TimeoutError
|
||||
return {"code": 0, "out": "drawn"}
|
||||
class SlowGpu:
|
||||
def spawn(self, *a, **kw): return SlowCall(2)
|
||||
lines.clear()
|
||||
fp.WAIT_SAY_S = 0.01
|
||||
assert fp.waited(SlowGpu(), log, "j4", ["render"]) == {"code": 0, "out": "drawn"}
|
||||
assert sum("waiting" in l and "GPU run" in l for l in lines) == 2, lines
|
||||
ok("a GPU run that hasn't answered is said in the log every WAIT_SAY_S until it does")
|
||||
|
||||
# a GPU run that ran out of its own time fails the job, as .remote() did, instead of being waited on forever
|
||||
class FunctionTimeoutError(TimeoutError): pass
|
||||
class TimedOutCall:
|
||||
def get(self, timeout=None): raise FunctionTimeoutError("Function timeout")
|
||||
class TimedOutGpu:
|
||||
def spawn(self, *a, **kw): return TimedOutCall()
|
||||
lines.clear()
|
||||
try:
|
||||
fp.waited(TimedOutGpu(), log, "j5", ["render"])
|
||||
raise AssertionError("waited() swallowed a function timeout")
|
||||
except FunctionTimeoutError:
|
||||
pass
|
||||
assert not any("waiting" in l for l in lines), lines
|
||||
ok("a GPU run that timed out fails the job instead of being waited on forever")
|
||||
|
||||
shutil.rmtree(root)
|
||||
Reference in new issue
Block a user