server (#208 follow-up): a request stamps last_request_at in load() (the idle thread cannot unload between load and run); unload() sends QUIT before terminate; the VRAM guard checks the first GPU (docs); #163's test engine answers poll()
This commit is contained in:
1 parent
376430c7db
commit
379d7d84b2
3 files changed
+11
-4
No files matched your search
+1
-1
@@ -304,7 +304,7 @@ server, three server options (all off by default; also as keys in `strata-<model
|
||||
| Option | Config key | What it does |
|
||||
| --- | --- | --- |
|
||||
| `--idle-unload 600` | `"idle_unload_s": 600` | unload the model after 600 s without requests; the next request loads it again |
|
||||
| `--min-free-vram-mib 11000` | `"min_free_vram_mib": 11000` | load an unloaded model only when that much VRAM is free (it waits up to 15 s for memory being given back), else answer **503** "the GPU is in use by another program" instead of starting into what a game left |
|
||||
| `--min-free-vram-mib 11000` | `"min_free_vram_mib": 11000` | load an unloaded model only when that much VRAM is free (it waits up to 15 s for memory being given back), else answer **503** "the GPU is in use by another program" instead of starting into what a game left (with several GPUs it checks the first one) |
|
||||
| `--before-load "cmd"` | `"before_load": "cmd"` or `["cmd", "arg"]` | a command run before the model is loaded again, e.g. one that unloads another server's model |
|
||||
|
||||
`POST /unload` unloads it now (`409` while a request is running) and `POST /load` loads it ahead of a request;
|
||||
|
||||
+9
-2
@@ -249,8 +249,13 @@ class StrataEngine:
|
||||
"""Stop the engine process so its VRAM and RAM go back to the system (idle unload, POST /unload); the next
|
||||
request starts it again with restart(). Only between requests: the caller holds the service's fifo."""
|
||||
try:
|
||||
self.proc.terminate()
|
||||
self.proc.wait(timeout=20)
|
||||
try: # QUIT first, as close() does: the engine frees its memory
|
||||
self.proc.stdin.write("QUIT\n")
|
||||
self.proc.stdin.flush()
|
||||
self.proc.wait(timeout=20)
|
||||
except (OSError, ValueError, subprocess.TimeoutExpired):
|
||||
self.proc.terminate()
|
||||
self.proc.wait(timeout=20)
|
||||
except subprocess.TimeoutExpired:
|
||||
self.proc.kill()
|
||||
self.proc.wait(timeout=20)
|
||||
@@ -695,6 +700,8 @@ class Service:
|
||||
|
||||
def load(self):
|
||||
"""POST /load and every generation request: start the engine now if it is unloaded (raises GpuBusy)."""
|
||||
# a request is on its way: the idle thread must not unload between this and the request's own start
|
||||
self.last_request_at = time.time()
|
||||
if self.loaded() and not self._vision_down():
|
||||
return
|
||||
with self.fifo:
|
||||
|
||||
@@ -486,7 +486,7 @@ class LiveRate(unittest.TestCase):
|
||||
import queue
|
||||
from types import SimpleNamespace
|
||||
engine = StrataEngine.__new__(StrataEngine)
|
||||
engine.proc = SimpleNamespace(stdin=io.StringIO())
|
||||
engine.proc = SimpleNamespace(stdin=io.StringIO(), poll=lambda: None) # alive() asks it (#208)
|
||||
engine.lines = queue.Queue()
|
||||
engine.can_stop = False
|
||||
engine.max_context = 262144
|
||||
|
||||
Reference in new issue
Block a user