Allow memory-checked GPU sharing between LLM and TTS
This commit is contained in:
1 parent
5fae33066f
commit
df6b342288
7 files changed
+166
-24
No files matched your search
@@ -0,0 +1,54 @@
|
||||
"""Measure a separate TTS worker without stopping existing GPU processes."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import threading
|
||||
import time
|
||||
import sys
|
||||
import tts_test
|
||||
from tts_runtime import TTSRuntime
|
||||
from tts_test import TTSTests
|
||||
from image_test import probe
|
||||
|
||||
root = Path('/var/lib/deck/tts-sharing-probe')
|
||||
runtime = TTSRuntime('/var/lib/deck/tts-runtime')
|
||||
tts = TTSTests(root, None, runtime)
|
||||
if len(sys.argv)>1:
|
||||
tts_test.WORKER=Path(sys.argv[1])
|
||||
gpu = next(g for g in probe() if 'RTX 3060' in g['name'])
|
||||
baseline = gpu['free_mib']
|
||||
minimum = [baseline]
|
||||
stop = threading.Event()
|
||||
|
||||
|
||||
def monitor():
|
||||
while not stop.wait(.5):
|
||||
try:
|
||||
minimum[0] = min(minimum[0], next(g['free_mib'] for g in probe() if g['uuid'] == gpu['uuid']))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
thread = threading.Thread(target=monitor, daemon=True)
|
||||
thread.start()
|
||||
try:
|
||||
process = tts._ensure(gpu)
|
||||
result = root / 'sample'
|
||||
result.mkdir(exist_ok=True)
|
||||
(result / 'result.json').unlink(missing_ok=True)
|
||||
text='Dies ist ein Sprachtest. Das Sprachmodell und die Sprachausgabe nutzen gleichzeitig dieselbe Grafikkarte. Andere laufende Modelle bleiben dabei unverändert.'
|
||||
if len(sys.argv)>2:
|
||||
text=(text.replace('.','')+' ')*8
|
||||
text=text[:1000]
|
||||
process.stdin.write(json.dumps(dict(output=str(result), text=text, speaker='Ryan', language='German', speed=1)) + '\n')
|
||||
process.stdin.flush()
|
||||
end = time.monotonic() + 180
|
||||
while not (result / 'result.json').exists():
|
||||
if process.poll() is not None or time.monotonic() > end:
|
||||
raise RuntimeError('TTS probe stopped or timed out')
|
||||
time.sleep(.5)
|
||||
outcome = json.loads((result / 'result.json').read_text())
|
||||
print(json.dumps(dict(result=outcome, baseline_free_mib=baseline, peak_increment_mib=baseline-minimum[0], minimum_free_mib=minimum[0], weight_mib=runtime.paths()[1].joinpath('model.safetensors').stat().st_size/1024**2)))
|
||||
finally:
|
||||
stop.set()
|
||||
thread.join(timeout=10)
|
||||
tts.unload_idle()
|
||||
Reference in new issue
Block a user