fix MatA 2
Browse files
app.py
CHANGED
|
@@ -11,6 +11,29 @@
|
|
| 11 |
import time
|
| 12 |
import subprocess
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
import gradio as gr
|
| 15 |
|
| 16 |
# -----------------------------------------------------------------------------
|
|
@@ -42,15 +65,19 @@ def _safe_startup_diag():
|
|
| 42 |
import torch # noqa: F401
|
| 43 |
import importlib
|
| 44 |
t = importlib.import_module("torch")
|
| 45 |
-
logger.info(
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
except Exception as e:
|
| 49 |
logger.warning("Torch not available at startup: %s", e)
|
| 50 |
|
| 51 |
# nvidia-smi with short timeout (avoid indefinite block)
|
| 52 |
try:
|
| 53 |
-
out = subprocess.run(
|
|
|
|
|
|
|
| 54 |
if out.returncode == 0:
|
| 55 |
logger.info("nvidia-smi -L:\n%s", out.stdout.strip())
|
| 56 |
else:
|
|
|
|
| 11 |
import time
|
| 12 |
import subprocess
|
| 13 |
|
| 14 |
+
# --- import path fix for third_party packages (MatAnyone, SAM2) ---
|
| 15 |
+
import sys
|
| 16 |
+
for p in (
|
| 17 |
+
"/home/user/app/third_party",
|
| 18 |
+
"/home/user/app/third_party/matanyone",
|
| 19 |
+
"/home/user/app/third_party/sam2",
|
| 20 |
+
):
|
| 21 |
+
if p not in sys.path:
|
| 22 |
+
sys.path.insert(0, p)
|
| 23 |
+
|
| 24 |
+
# DEBUG: show search paths and MatAnyone package presence
|
| 25 |
+
print("[PATH-CHECK] sys.path[:8] =", sys.path[:8], flush=True)
|
| 26 |
+
print(
|
| 27 |
+
"[PATH-CHECK] exists(third_party/matanyone/matanyone) =",
|
| 28 |
+
os.path.isdir("/home/user/app/third_party/matanyone/matanyone"),
|
| 29 |
+
flush=True,
|
| 30 |
+
)
|
| 31 |
+
print(
|
| 32 |
+
"[PATH-CHECK] exists(third_party/sam2) =",
|
| 33 |
+
os.path.isdir("/home/user/app/third_party/sam2"),
|
| 34 |
+
flush=True,
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
import gradio as gr
|
| 38 |
|
| 39 |
# -----------------------------------------------------------------------------
|
|
|
|
| 65 |
import torch # noqa: F401
|
| 66 |
import importlib
|
| 67 |
t = importlib.import_module("torch")
|
| 68 |
+
logger.info(
|
| 69 |
+
"torch imported: %s | torch.version.cuda=%s",
|
| 70 |
+
getattr(t, "__version__", "?"),
|
| 71 |
+
getattr(getattr(t, "version", None), "cuda", None),
|
| 72 |
+
)
|
| 73 |
except Exception as e:
|
| 74 |
logger.warning("Torch not available at startup: %s", e)
|
| 75 |
|
| 76 |
# nvidia-smi with short timeout (avoid indefinite block)
|
| 77 |
try:
|
| 78 |
+
out = subprocess.run(
|
| 79 |
+
["nvidia-smi", "-L"], capture_output=True, text=True, timeout=2
|
| 80 |
+
)
|
| 81 |
if out.returncode == 0:
|
| 82 |
logger.info("nvidia-smi -L:\n%s", out.stdout.strip())
|
| 83 |
else:
|