Spaces:
Running on Zero
Running on Zero
Keep the model on the CPU at start-up (Scrolls-private 1a9b8870)
Browse files
app.py
CHANGED
|
@@ -47,7 +47,9 @@ def log(message):
|
|
| 47 |
def _load():
|
| 48 |
global ENGINE, ENGINE_ERROR
|
| 49 |
try:
|
| 50 |
-
|
|
|
|
|
|
|
| 51 |
log(f"{READER} ready in {ENGINE.startup_s} s")
|
| 52 |
except Exception as exc: # noqa: BLE001
|
| 53 |
ENGINE_ERROR = f"{type(exc).__name__}: {exc}"
|
|
|
|
| 47 |
def _load():
|
| 48 |
global ENGINE, ENGINE_ERROR
|
| 49 |
try:
|
| 50 |
+
# On ZeroGPU the GPU exists only inside gpu_run; a .to("cuda") in this thread is not intercepted and
|
| 51 |
+
# kills start-up, so the model stays on the CPU here and Engine.run moves it to the call's device.
|
| 52 |
+
ENGINE = engine.Engine(readers=(READER,), place_on_cuda=False)
|
| 53 |
log(f"{READER} ready in {ENGINE.startup_s} s")
|
| 54 |
except Exception as exc: # noqa: BLE001
|
| 55 |
ENGINE_ERROR = f"{type(exc).__name__}: {exc}"
|