From 827e9d822ceab5b8fd06af822ccc1498f867994b Mon Sep 17 00:00:00 2001 From: EJClaw Date: Thu, 15 Oct 2026 02:16:08 +0900 Subject: [PATCH] =?UTF-8?q?M4:=20Windows=20=EC=8B=A4=EA=B8=B0=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=EC=9C=BC=EB=A1=9C=20=EC=B0=BE=EC=9D=80=20=EC=9B=8C?= =?UTF-8?q?=EC=BB=A4=20=ED=81=AC=EB=9E=98=EC=8B=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 원인: pywinrt 의 오래된 msvcp140.dll(14.29)이 먼저 올라가면 onnxruntime 이 0xC0000005 로 죽음 (롤 채팅 OCR 을 한 번 쓴 뒤 첫 STT 에서 워커가 조용히 종료, PyInstaller 분석도 실패) - 워커 시작 때 onnxruntime·ctranslate2 를 먼저 적재, 빌드 전에 winrt 의 msvcp140 삭제 - 코어: 워커가 죽은 뒤 stdin 쓰기(EPIPE)로 앱 전체가 죽던 문제 Co-Authored-By: Claude Opus 5.5 --- app/src/core/stt/worker.ts | 2 ++ tools/win-ci/gvr.ps1 | 5 ++++- worker/README.md | 6 ++++++ worker/gvr_worker/main.py | 17 +++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/src/core/stt/worker.ts b/app/src/core/stt/worker.ts index 4ab66cf..a9afd8a 100644 --- a/app/src/core/stt/worker.ts +++ b/app/src/core/stt/worker.ts @@ -78,6 +78,8 @@ export class WorkerClient extends EventEmitter { } catch { /* 권한 없음 무시 */ } + // 워커가 죽은 뒤 stdin 에 쓰면 EPIPE 가 난다. 처리하지 않으면 앱 전체가 죽는다. + p.stdin!.on('error', (e) => log.warn(`워커 stdin 오류: ${e.message}`)); readline.createInterface({ input: p.stdout! }).on('line', (line) => this.onLine(line)); readline.createInterface({ input: p.stderr! }).on('line', (line) => { if (line.trim()) log.debug(line); diff --git a/tools/win-ci/gvr.ps1 b/tools/win-ci/gvr.ps1 index 30dbad5..f0e16a0 100644 --- a/tools/win-ci/gvr.ps1 +++ b/tools/win-ci/gvr.ps1 @@ -88,7 +88,10 @@ try { & $py -m pip install --upgrade pip -q & $py -m pip install -r requirements.txt -r requirements-dev.txt -q if ($LASTEXITCODE -ne 0) { Pop-Location; throw "pip exit $LASTEXITCODE" } - & $py -c "import faster_whisper, ctranslate2, winrt.windows.media.ocr as o; print('faster-whisper', faster_whisper.__version__, 'ct2', ctranslate2.__version__)" + # pywinrt 가 넣어 둔 오래된 MSVC 런타임(msvcp140 14.29)은 지운다. 남겨 두면 PyInstaller 분석과 실행 중에 + # onnxruntime 이 0xC0000005 로 죽는다 (시스템/번들의 새 런타임을 쓰게 한다) + Get-ChildItem (Join-Path $Repo 'worker\.venv\Lib\site-packages\winrt') -Filter 'msvcp140*.dll' -ErrorAction SilentlyContinue | ForEach-Object { "삭제: $($_.FullName)"; Remove-Item $_.FullName -Force } + & $py -c "import winrt.windows.media.ocr as o; import onnxruntime, faster_whisper, ctranslate2; print('faster-whisper', faster_whisper.__version__, 'ct2', ctranslate2.__version__, 'ort', onnxruntime.__version__)" Pop-Location } # 한국어 OCR 언어 기능 (롤 채팅 OCR 에 필요. 게임 PC 에서는 첫 실행 마법사가 안내) diff --git a/worker/README.md b/worker/README.md index f4efe98..71e6773 100644 --- a/worker/README.md +++ b/worker/README.md @@ -92,3 +92,9 @@ CPU 스모크 테스트(openai/whisper-tiny, 합성 30개, `--max-steps 3`)는 - 잡음 판정 기준값은 추정치다. 실제 녹음으로 `noise_sensitivity` 와 `noise.py` 임계값을 조정해야 한다. - 정규화 음량은 16kHz 로 디코딩한 신호에서 잰다(48k 원본과 소폭 차이 가능). - CUDA 경로(GPU 추론, cuDNN/cuBLAS DLL 다운로드·로딩)는 이 개발 머신에서 실행하지 않았다(M0 에서 게임 PC 로 확인). + +## Windows 주의: pywinrt 의 오래된 MSVC 런타임 + +`winrt` 패키지는 `msvcp140.dll` 14.29 를 자기 폴더에 넣어 둔다. 이게 먼저 올라가면 onnxruntime(Silero VAD)이 +`0xC0000005` 로 프로세스째 죽는다 (win-ci 에서 확인: OCR 을 한 번 쓴 뒤 첫 변환에서 워커가 조용히 종료, PyInstaller 분석도 같은 이유로 실패). +대응: ① 워커 시작 때 onnxruntime·ctranslate2 를 먼저 불러온다(`preload_native_runtimes`) ② 빌드 전에 `site-packages/winrt/msvcp140*.dll` 을 지운다(`tools/win-ci/gvr.ps1`). diff --git a/worker/gvr_worker/main.py b/worker/gvr_worker/main.py index 28db085..d7ed55a 100644 --- a/worker/gvr_worker/main.py +++ b/worker/gvr_worker/main.py @@ -176,6 +176,22 @@ def run_finetune(req: dict[str, Any], ctx: Context) -> dict[str, Any]: return result +def preload_native_runtimes() -> None: + """onnxruntime·ctranslate2 를 winrt 보다 먼저 올린다. + + pywinrt(winrt 패키지)는 오래된 msvcp140.dll(14.29)을 자체 폴더에 넣어 두는데, 이게 먼저 메모리에 올라가면 + 나중에 onnxruntime(Silero VAD)이 0xC0000005 로 프로세스째 죽는다 (Windows 에서 확인: OCR 을 한 번 쓴 뒤 + 첫 변환에서 워커가 조용히 종료). 새 런타임을 쓰는 쪽을 먼저 올리면 같은 이름의 DLL 은 그것을 재사용한다. + """ + if sys.platform != "win32": + return + for mod in ("onnxruntime", "ctranslate2"): + try: + __import__(mod) + except Exception as e: # noqa: BLE001 + log.warning("%s 미리 불러오기 실패: %s", mod, e) + + def main() -> None: level = os.environ.get("GVR_LOG_LEVEL", "INFO").upper() if level not in ("DEBUG", "INFO", "WARNING", "WARN", "ERROR", "CRITICAL"): @@ -185,6 +201,7 @@ def main() -> None: for noisy in ("httpx", "httpx2", "huggingface_hub", "faster_whisper"): logging.getLogger(noisy).setLevel(logging.WARNING) setup_cuda_dll_path() # ctranslate2 import 전에 + preload_native_runtimes() stdin, stdout = setup_stdio() writer = Writer(stdout) server = build_server(writer)