M4: Windows 에서 첫 변환이 멈추던 문제 수정 (scipy 를 주 스레드에서 먼저 적재)

- 원인: 요청 스레드에서 scipy.linalg.blas(OpenBLAS DLL)를 처음 불러오면 Windows 에서 영원히 멈춤
  (faulthandler 스택: transcribe → audio.measure_lufs → pyloudnorm → scipy.signal → scipy.linalg.blas)
- 주 스레드에서 미리 불러오면 정상인 것을 win-ci 에서 확인 → preload_native_runtimes 에 추가

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-15 03:36:42 +09:00
parent c1b0d2a5c9
commit e6723a49ea
2 changed files with 12 additions and 1 deletions

View File

@@ -98,3 +98,10 @@ CPU 스모크 테스트(openai/whisper-tiny, 합성 30개, `--max-steps 3`)는
`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`).
## Windows 주의: scipy 는 주 스레드에서 먼저 불러온다
요청 처리 스레드에서 scipy 를 처음 import 하면 `scipy.linalg.blas`(OpenBLAS DLL) 적재 중에 프로세스가 멈춘다
(win-ci 에서 확인: 첫 `transcribe` 의 음량 측정 `pyloudnorm` → `scipy.signal` 에서 응답 없음, faulthandler 스택으로 위치 확인).
같은 import 를 시작할 때 주 스레드에서 먼저 하면 정상이라, `preload_native_runtimes` 가 `scipy.linalg/signal/ndimage`, `pyloudnorm` 도 미리 불러온다.
`worker/scripts/win_debug.py protocol` 로 다시 확인할 수 있다.

View File

@@ -182,10 +182,14 @@ def preload_native_runtimes() -> None:
pywinrt(winrt 패키지)는 오래된 msvcp140.dll(14.29)을 자체 폴더에 넣어 두는데, 이게 먼저 메모리에 올라가면
나중에 onnxruntime(Silero VAD)이 0xC0000005 로 프로세스째 죽는다 (Windows 에서 확인: OCR 을 한 번 쓴 뒤
첫 변환에서 워커가 조용히 종료). 새 런타임을 쓰는 쪽을 먼저 올리면 같은 이름의 DLL 은 그것을 재사용한다.
scipy(OpenBLAS DLL)는 주 스레드에서 미리 올린다. 요청 처리 스레드에서 처음 import 하면 Windows 에서
scipy.linalg.blas 적재 중에 영원히 멈춘다 (win-ci 에서 확인: 첫 변환의 음량 측정 pyloudnorm → scipy.signal 에서 멈춤,
같은 import 를 주 스레드에서 먼저 하면 정상).
"""
if sys.platform != "win32":
return
for mod in ("onnxruntime", "ctranslate2"):
for mod in ("onnxruntime", "ctranslate2", "scipy.linalg", "scipy.signal", "scipy.ndimage", "pyloudnorm"):
try:
__import__(mod)
except Exception as e: # noqa: BLE001