llava / start.py
C98yhou079's picture
Update start.py
d5685a6 verified
raw
history blame contribute delete
652 Bytes
# start.py - ensure torch is installed at runtime then run app.py
import os, sys, subprocess
def ensure_torch():
try:
import torch
print("torch present:", torch.__version__)
return
except Exception:
print("Installing CPU torch...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "--no-cache-dir",
"torch==2.2.0+cpu", "--extra-index-url", "https://download.pytorch.org/whl/cpu"])
import torch
print("Installed torch", torch.__version__)
if __name__ == "__main__":
ensure_torch()
os.execv(sys.executable, [sys.executable, "app.py"])