diff --git a/tools/win-ci/gvr.ps1 b/tools/win-ci/gvr.ps1 index 08c42ef..30dbad5 100644 --- a/tools/win-ci/gvr.ps1 +++ b/tools/win-ci/gvr.ps1 @@ -69,6 +69,19 @@ try { Log "gvr rev $(& git rev-parse --short HEAD)" $py = Join-Path $Repo 'worker\.venv\Scripts\python.exe' + if ($Phase -eq 'debug') { + # 원인 조사용: worker/scripts/win_debug.py 만 돌린다 (venv 는 이전 실행 것을 그대로 씀) + $r['debug'] = Step 'debug' { + & $py -X faulthandler worker\scripts\win_debug.py + "exit $LASTEXITCODE" + } + $sum = Join-Path $OutDir 'summary.log' + Set-Content -Path $sum -Value @("phase=debug", "debug $($r['debug'])") -Encoding UTF8 + Send-Artifact 'gvr-summary.log' $sum + Pop-Location + Log "=== gvr 끝 ===" + exit 0 + } $r['worker_setup'] = Step 'worker_setup' { Push-Location (Join-Path $Repo 'worker') if (-not (Test-Path $py)) { & python -m venv .venv } diff --git a/worker/scripts/win_debug.py b/worker/scripts/win_debug.py new file mode 100644 index 0000000..10bc5d0 --- /dev/null +++ b/worker/scripts/win_debug.py @@ -0,0 +1,48 @@ +"""Windows 에서 워커가 모델 적재 중 조용히 죽는 원인 조사.""" +import os +import subprocess +import sys + +CODE = r''' +import faulthandler, sys, os +faulthandler.enable() +print("python", sys.version, flush=True) +import ctranslate2 +print("ct2", ctranslate2.__version__, "cuda devices", ctranslate2.get_cuda_device_count(), flush=True) +print("cpu compute types", ctranslate2.get_supported_compute_types("cpu"), flush=True) +from faster_whisper import WhisperModel +m = WhisperModel(os.environ["M"], device="cpu", compute_type=os.environ.get("CT", "int8"), cpu_threads=2) +print("LOAD OK", flush=True) +segs, info = m.transcribe(os.environ["A"], language="ko") +print("TEXT", "".join(s.text for s in segs), flush=True) +''' +root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +audio = os.path.join(root, "app", "resources", "diag", "speech_ko.ogg") +model = None +for base in [os.environ.get("TEMP", ""), os.path.expanduser("~")]: + for dp, dn, fn in os.walk(base): + if "model.bin" in fn and dp.rstrip("\\/").endswith("tiny"): + model = dp + break + if dp.count(os.sep) - base.count(os.sep) > 4: + dn[:] = [] + if model: + break +print("model dir", model, flush=True) +# onnxruntime 단독 / 다른 패키지 뒤 import, MSVC 런타임 버전 +for code in ["import onnxruntime; print('ort', onnxruntime.__version__)", + "import av, ctranslate2; import onnxruntime; print('ort after av+ct2 ok')", + "import onnxruntime, av, ctranslate2; print('ort first ok')"]: + p = subprocess.run([sys.executable, "-X", "faulthandler", "-c", code], capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=300) + print(f"--- {code} -> exit {p.returncode} (0x{p.returncode & 0xffffffff:08X})", p.stdout.strip()[-300:], p.stderr.strip()[-800:], flush=True) +ps = "foreach ($f in 'msvcp140.dll','vcruntime140.dll','vcruntime140_1.dll') { $p = Join-Path $env:WINDIR ('System32\\' + $f); if (Test-Path $p) { $f + ' ' + (Get-Item $p).VersionInfo.FileVersion } else { $f + ' 없음' } }" +print(subprocess.run(["powershell", "-NoProfile", "-Command", ps], capture_output=True, text=True).stdout, flush=True) +import glob +for f in glob.glob(os.path.join(sys.prefix, "Lib", "site-packages", "**", "msvcp140*.dll"), recursive=True): + print("bundled", f, flush=True) +for env in [{}, {"KMP_DUPLICATE_LIB_OK": "TRUE"}, {"CT": "float32"}, {"OMP_NUM_THREADS": "1", "CT": "float32"}]: + e = {**os.environ, "M": model or "tiny", "A": audio, **env} + p = subprocess.run([sys.executable, "-X", "faulthandler", "-c", CODE], env=e, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=600) + print(f"=== env={env} exit={p.returncode} (0x{p.returncode & 0xffffffff:08X})", flush=True) + print(p.stdout[-1500:], flush=True) + print("stderr:", p.stderr[-2500:], flush=True)