Commit
·
d206e43
1
Parent(s):
9f62d70
CUDAメモリ管理を強化し、トランスクリプション前にキャッシュをクリア。デバッグ用にメモリ状況をログ出力。キューサイズと同時実行数を制限してタイムアウト対策を実施。
Browse files
app.py
CHANGED
|
@@ -152,8 +152,18 @@ def transcribe_audio(transcribe_path, model, duration_sec, device):
|
|
| 152 |
"""
|
| 153 |
long_audio_settings_applied = False
|
| 154 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
model.to(device)
|
| 156 |
model.to(torch.float32)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
gr.Info(f"Transcribing on {device}...", duration=2)
|
| 158 |
|
| 159 |
if duration_sec > 480:
|
|
@@ -622,5 +632,9 @@ with gr.Blocks(theme=nvidia_theme) as demo:
|
|
| 622 |
|
| 623 |
if __name__ == "__main__":
|
| 624 |
print("Launching Gradio Demo...")
|
| 625 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 626 |
demo.launch()
|
|
|
|
| 152 |
"""
|
| 153 |
long_audio_settings_applied = False
|
| 154 |
try:
|
| 155 |
+
# CUDA 使用前にメモリをクリアし、断片化を低減
|
| 156 |
+
if device == 'cuda':
|
| 157 |
+
torch.cuda.empty_cache()
|
| 158 |
+
gc.collect()
|
| 159 |
+
|
| 160 |
model.to(device)
|
| 161 |
model.to(torch.float32)
|
| 162 |
+
|
| 163 |
+
# メモリ状況をログ出力(デバッグ用)
|
| 164 |
+
if device == 'cuda':
|
| 165 |
+
print(f"CUDA Memory before transcription: {torch.cuda.memory_allocated() / 1024**2:.2f} MB")
|
| 166 |
+
|
| 167 |
gr.Info(f"Transcribing on {device}...", duration=2)
|
| 168 |
|
| 169 |
if duration_sec > 480:
|
|
|
|
| 632 |
|
| 633 |
if __name__ == "__main__":
|
| 634 |
print("Launching Gradio Demo...")
|
| 635 |
+
# タイムアウト対策としてキューサイズと同時実行数を抑制
|
| 636 |
+
demo.queue(
|
| 637 |
+
max_size=5,
|
| 638 |
+
default_concurrency_limit=1
|
| 639 |
+
)
|
| 640 |
demo.launch()
|