Upload 109 files
Browse files- app.py +6 -45
- core/pipelines/base_pipeline.py +1 -22
app.py
CHANGED
|
@@ -40,37 +40,13 @@ def apply_sage_attention_patch():
|
|
| 40 |
print(msg)
|
| 41 |
return msg
|
| 42 |
|
| 43 |
-
def is_fatal_gpu_error(e: BaseException) -> bool:
|
| 44 |
-
err_type = type(e).__name__
|
| 45 |
-
err_str = f"{err_type}: {str(e)} | {repr(e)}".lower()
|
| 46 |
-
fatal_keywords = [
|
| 47 |
-
"ecc",
|
| 48 |
-
"uncorrectable",
|
| 49 |
-
"cudaerror",
|
| 50 |
-
"acceleratorerror",
|
| 51 |
-
"cuda error",
|
| 52 |
-
"cuda_error",
|
| 53 |
-
"device-side assertion",
|
| 54 |
-
"cuda_launch_blocking",
|
| 55 |
-
]
|
| 56 |
-
return any(kw in err_str for kw in fatal_keywords)
|
| 57 |
-
|
| 58 |
@spaces.GPU
|
| 59 |
def dummy_gpu_for_startup():
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
return "Startup check passed."
|
| 66 |
-
except BaseException as e:
|
| 67 |
-
if is_fatal_gpu_error(e):
|
| 68 |
-
print("\n" + "="*80)
|
| 69 |
-
print(f"🚨 [Fatal GPU Error] Captured fatal GPU error during startup check: {e}")
|
| 70 |
-
print("🚨 Terminating process to trigger an automatic container restart...")
|
| 71 |
-
print("="*80 + "\n")
|
| 72 |
-
os._exit(1)
|
| 73 |
-
raise e
|
| 74 |
|
| 75 |
|
| 76 |
def main():
|
|
@@ -97,12 +73,6 @@ def main():
|
|
| 97 |
except BaseException as e:
|
| 98 |
err_msg = f"{type(e).__name__}: {str(e)}"
|
| 99 |
print(f"--- [GPU Startup] ⚠️ Warning: Startup check failed: {err_msg} ---")
|
| 100 |
-
if is_fatal_gpu_error(e):
|
| 101 |
-
print("\n" + "="*80)
|
| 102 |
-
print(f"🚨 [Fatal GPU Error] Captured fatal GPU error during startup check: {err_msg}")
|
| 103 |
-
print("🚨 Terminating process to trigger an automatic container restart...")
|
| 104 |
-
print("="*80 + "\n")
|
| 105 |
-
os._exit(1)
|
| 106 |
|
| 107 |
print("--- Starting Application Setup ---")
|
| 108 |
|
|
@@ -120,16 +90,7 @@ def main():
|
|
| 120 |
demo = build_ui(attach_event_handlers)
|
| 121 |
|
| 122 |
print("--- Launching Gradio Interface ---")
|
| 123 |
-
|
| 124 |
-
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
|
| 125 |
-
except ValueError as e:
|
| 126 |
-
if "localhost is not accessible" in str(e):
|
| 127 |
-
print("\n" + "="*80)
|
| 128 |
-
print(f"🚨 [Gradio Launch Error] Localhost accessibility check failed: {e}")
|
| 129 |
-
print("🚨 Terminating process to trigger an automatic container restart...")
|
| 130 |
-
print("="*80 + "\n")
|
| 131 |
-
sys.exit(1)
|
| 132 |
-
raise e
|
| 133 |
|
| 134 |
|
| 135 |
if __name__ == "__main__":
|
|
|
|
| 40 |
print(msg)
|
| 41 |
return msg
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
@spaces.GPU
|
| 44 |
def dummy_gpu_for_startup():
|
| 45 |
+
print("--- [GPU Startup] Dummy function for startup check initiated. ---")
|
| 46 |
+
patch_result = apply_sage_attention_patch()
|
| 47 |
+
print(f"--- [GPU Startup] {patch_result} ---")
|
| 48 |
+
print("--- [GPU Startup] Startup check passed. ---")
|
| 49 |
+
return "Startup check passed."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
def main():
|
|
|
|
| 73 |
except BaseException as e:
|
| 74 |
err_msg = f"{type(e).__name__}: {str(e)}"
|
| 75 |
print(f"--- [GPU Startup] ⚠️ Warning: Startup check failed: {err_msg} ---")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
print("--- Starting Application Setup ---")
|
| 78 |
|
|
|
|
| 90 |
demo = build_ui(attach_event_handlers)
|
| 91 |
|
| 92 |
print("--- Launching Gradio Interface ---")
|
| 93 |
+
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
|
| 96 |
if __name__ == "__main__":
|
core/pipelines/base_pipeline.py
CHANGED
|
@@ -38,28 +38,7 @@ class BasePipeline(ABC):
|
|
| 38 |
print(f"Requesting ZeroGPU for {task_name} with duration: {final_duration} seconds.")
|
| 39 |
gpu_runner = spaces.GPU(duration=final_duration)(gpu_function)
|
| 40 |
|
| 41 |
-
|
| 42 |
-
return gpu_runner(*args, **kwargs)
|
| 43 |
-
except BaseException as e:
|
| 44 |
-
err_type = type(e).__name__
|
| 45 |
-
err_str = f"{err_type}: {str(e)} | {repr(e)}".lower()
|
| 46 |
-
fatal_keywords = [
|
| 47 |
-
"ecc",
|
| 48 |
-
"uncorrectable",
|
| 49 |
-
"cudaerror",
|
| 50 |
-
"acceleratorerror",
|
| 51 |
-
"cuda error",
|
| 52 |
-
"cuda_error",
|
| 53 |
-
"device-side assertion",
|
| 54 |
-
"cuda_launch_blocking",
|
| 55 |
-
]
|
| 56 |
-
if any(kw in err_str for kw in fatal_keywords):
|
| 57 |
-
print("\n" + "="*80)
|
| 58 |
-
print(f"🚨 [Fatal GPU Error] Captured fatal GPU error during inference: {e}")
|
| 59 |
-
print("🚨 Terminating process to trigger an automatic container restart...")
|
| 60 |
-
print("="*80 + "\n")
|
| 61 |
-
os._exit(1)
|
| 62 |
-
raise e
|
| 63 |
|
| 64 |
def _encode_video_from_frames(self, frames_tensor_cpu: 'torch.Tensor', fps: int, progress: gr.Progress) -> str:
|
| 65 |
progress(0.9, desc="Encoding video on CPU...")
|
|
|
|
| 38 |
print(f"Requesting ZeroGPU for {task_name} with duration: {final_duration} seconds.")
|
| 39 |
gpu_runner = spaces.GPU(duration=final_duration)(gpu_function)
|
| 40 |
|
| 41 |
+
return gpu_runner(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
def _encode_video_from_frames(self, frames_tensor_cpu: 'torch.Tensor', fps: int, progress: gr.Progress) -> str:
|
| 44 |
progress(0.9, desc="Encoding video on CPU...")
|