[Perf][CI] Use Whisper on GPU when memory permits (#5675)

Signed-off-by: akshatvishu <akshatnayak197@gmail.com>
Signed-off-by: andyluo7 <andy.luo@amd.com>
Co-authored-by: andyluo7 <andy.luo@amd.com>
This commit is contained in:
akshatvishuandandyluo7 authored and GitHub committed 2026-09-04 16:35:48 -07:00
1 parent b6b992ac7b
commit ae57e406fd
4 files changed
+64 -12

No files matched your search

+12 -6
View File
@@ -31,6 +31,8 @@ from PIL import Image
logger = logging.getLogger(__name__)
_MIN_FREE_VRAM = 16 * 1024**3
_synthetic_media_fallback_dir: Path | None = None
@@ -711,12 +713,16 @@ def _select_whisper_device() -> str:
if current_omni_platform.is_available():
n = current_omni_platform.get_device_count()
# Single-GPU runners (e.g. the L4 nightly): the model server already
# occupies device 0, and a Whisper model resident there competes with
# it for VRAM and OOMs. Only borrow an accelerator when a spare device
# exists; otherwise validate on CPU.
if n > 1:
device_index = n - 1
# Prefer the highest-index device with enough room for Whisper. The
# 16 GiB floor protects low-memory single-GPU runners such as the L4
# nightly, where the model server already occupies device 0, from the
# server-plus-Whisper OOM fixed in #3822. Keep the CPU fallback when no
# device has enough room.
for candidate_index in range(n - 1, -1, -1):
candidate_device = current_omni_platform.get_torch_device(candidate_index)
if current_omni_platform.get_free_memory(candidate_device) >= _MIN_FREE_VRAM:
device_index = candidate_index
break
if device_index is None:
return "cpu"