ollama_serve / app.py
uhoui's picture
yeser
80dcbaf
import subprocess
import sys
import importlib
# List of dependencies to ensure are installed
deps = ["transformers", "torch", "fastapi", "uvicorn", "huggingface_hub", "accelerate"]
for dep in deps:
try:
importlib.import_module(dep)
except ImportError:
print(f"Installing missing dependency: {dep}")
subprocess.check_call([sys.executable, "-m", "pip", "install", dep])
# Now delay-import your app
print("Dependencies installed. Loading server...")
import main # <-- this is now safe to import AFTER accelerate exists