This commit is contained in:
parent
76e7594895
commit
c6c629f376
14
app/main.py
14
app/main.py
|
|
@ -192,18 +192,12 @@ def _warm_worker(t, q):
|
|||
def warm_up():
|
||||
logger.info("Warm-up on %s", DEVICE)
|
||||
try:
|
||||
texts = ["warmup"]
|
||||
q = mp.Queue()
|
||||
p = mp.Process(target=_warm_worker, args=(texts, q))
|
||||
p.start()
|
||||
p.join(timeout=60)
|
||||
|
||||
if not q.empty() and q.get() == "ok":
|
||||
_ = model.encode([
|
||||
"This is a warmup sentence used to initialize CUDA kernels and avoid latency spikes."
|
||||
], return_dense=True)
|
||||
logger.info("Warm-up complete.")
|
||||
else:
|
||||
logger.warning("Warm-up failed or timed out.")
|
||||
except Exception as e:
|
||||
logger.warning("Warm-up exception: %s", e)
|
||||
logger.warning("Warm-up failed: %s", e)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue