fix: GPU detection + pdfplumber + pass GPU env vars into app container
- preflight.py now writes PEREGRINE_GPU_COUNT and PEREGRINE_GPU_NAMES to .env so the app container gets GPU info without needing nvidia-smi access - compose.yml passes PEREGRINE_GPU_COUNT, PEREGRINE_GPU_NAMES, and RECOMMENDED_PROFILE as env vars to the app service - 0_Setup.py _detect_gpus() reads PEREGRINE_GPU_NAMES env var first; falls back to nvidia-smi (bare / GPU-passthrough environments) - 0_Setup.py _suggest_profile() reads RECOMMENDED_PROFILE env var first - requirements.txt: add pdfplumber (needed for resume PDF parsing)
This commit is contained in:
parent
578a4c819a
commit
30542808c7
4 changed files with 20 additions and 0 deletions
|
|
@ -40,7 +40,15 @@ def _save_yaml(updates: dict) -> None:
|
||||||
|
|
||||||
|
|
||||||
def _detect_gpus() -> list[str]:
|
def _detect_gpus() -> list[str]:
|
||||||
|
"""Detect GPUs. Prefers env vars written by preflight (works inside Docker)."""
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
# Preflight writes PEREGRINE_GPU_NAMES to .env; compose passes it to the container.
|
||||||
|
# This is the reliable path when running inside Docker without nvidia-smi access.
|
||||||
|
env_names = os.environ.get("PEREGRINE_GPU_NAMES", "").strip()
|
||||||
|
if env_names:
|
||||||
|
return [n.strip() for n in env_names.split(",") if n.strip()]
|
||||||
|
# Fallback: try nvidia-smi directly (works when running bare or with GPU passthrough)
|
||||||
try:
|
try:
|
||||||
out = subprocess.check_output(
|
out = subprocess.check_output(
|
||||||
["nvidia-smi", "--query-gpu=name", "--format=csv,noheader"],
|
["nvidia-smi", "--query-gpu=name", "--format=csv,noheader"],
|
||||||
|
|
@ -52,6 +60,11 @@ def _detect_gpus() -> list[str]:
|
||||||
|
|
||||||
|
|
||||||
def _suggest_profile(gpus: list[str]) -> str:
|
def _suggest_profile(gpus: list[str]) -> str:
|
||||||
|
import os
|
||||||
|
# If preflight already ran and wrote a profile recommendation, use it.
|
||||||
|
recommended = os.environ.get("RECOMMENDED_PROFILE", "").strip()
|
||||||
|
if recommended:
|
||||||
|
return recommended
|
||||||
if len(gpus) >= 2:
|
if len(gpus) >= 2:
|
||||||
return "dual-gpu"
|
return "dual-gpu"
|
||||||
if len(gpus) == 1:
|
if len(gpus) == 1:
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ services:
|
||||||
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
|
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
|
||||||
- OPENAI_COMPAT_URL=${OPENAI_COMPAT_URL:-}
|
- OPENAI_COMPAT_URL=${OPENAI_COMPAT_URL:-}
|
||||||
- OPENAI_COMPAT_KEY=${OPENAI_COMPAT_KEY:-}
|
- OPENAI_COMPAT_KEY=${OPENAI_COMPAT_KEY:-}
|
||||||
|
- PEREGRINE_GPU_COUNT=${PEREGRINE_GPU_COUNT:-0}
|
||||||
|
- PEREGRINE_GPU_NAMES=${PEREGRINE_GPU_NAMES:-}
|
||||||
|
- RECOMMENDED_PROFILE=${RECOMMENDED_PROFILE:-remote}
|
||||||
depends_on:
|
depends_on:
|
||||||
searxng:
|
searxng:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ notion-client>=3.0
|
||||||
# ── Document handling ─────────────────────────────────────────────────────
|
# ── Document handling ─────────────────────────────────────────────────────
|
||||||
pypdf
|
pypdf
|
||||||
pdfminer-six
|
pdfminer-six
|
||||||
|
pdfplumber
|
||||||
pyyaml>=6.0
|
pyyaml>=6.0
|
||||||
python-dotenv
|
python-dotenv
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -423,6 +423,9 @@ def main() -> None:
|
||||||
env_updates["RECOMMENDED_PROFILE"] = profile
|
env_updates["RECOMMENDED_PROFILE"] = profile
|
||||||
if offload_gb > 0:
|
if offload_gb > 0:
|
||||||
env_updates["CPU_OFFLOAD_GB"] = str(offload_gb)
|
env_updates["CPU_OFFLOAD_GB"] = str(offload_gb)
|
||||||
|
# GPU info for the app container (which lacks nvidia-smi access)
|
||||||
|
env_updates["PEREGRINE_GPU_COUNT"] = str(len(gpus))
|
||||||
|
env_updates["PEREGRINE_GPU_NAMES"] = ",".join(g["name"] for g in gpus)
|
||||||
write_env(env_updates)
|
write_env(env_updates)
|
||||||
update_llm_yaml(ports)
|
update_llm_yaml(ports)
|
||||||
write_compose_override(ports)
|
write_compose_override(ports)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue