Spaces:
Running on Zero
Running on Zero
Upload 109 files
Browse filesFiles changed (2)
- app.py+6-45
- core/pipelines/base_pipeline.py+1-22
39 unmodified lines40414243444546474849505152535455565743446061626364654546474849666768697071727350515220 unmodified lines73747510010110210310410576777811 unmodified lines9091921231249312512612712812913013113294959639 unmodified lines print(msg)
return msg
def is_fatal_gpu_error(e: BaseException) -> bool:
err_type = type(e).__name__
err_str = f"{err_type}: {str(e)} | {repr(e)}".lower()
fatal_keywords = [
"ecc",
"uncorrectable",
"cudaerror",
"acceleratorerror",
"cuda error",
"cuda_error",
"device-side assertion",
"cuda_launch_blocking",
]
return any(kw in err_str for kw in fatal_keywords)
@spaces.GPU
def dummy_gpu_for_startup():
try:
print("--- [GPU Startup] Dummy function for startup check initiated. ---")
patch_result = apply_sage_attention_patch()
print(f"--- [GPU Startup] {patch_result} ---")
print("--- [GPU Startup] Startup check passed. ---")
return "Startup check passed."
print("--- [GPU Startup] Dummy function for startup check initiated. ---")
patch_result = apply_sage_attention_patch()
print(f"--- [GPU Startup] {patch_result} ---")
print("--- [GPU Startup] Startup check passed. ---")
return "Startup check passed."
except BaseException as e:
if is_fatal_gpu_error(e):
print("\n" + "="*80)
print(f"🚨 [Fatal GPU Error] Captured fatal GPU error during startup check: {e}")
print("🚨 Terminating process to trigger an automatic container restart...")
print("="*80 + "\n")
os._exit(1)
raise e
def main():20 unmodified lines except BaseException as e:
err_msg = f"{type(e).__name__}: {str(e)}"
print(f"--- [GPU Startup] ⚠️ Warning: Startup check failed: {err_msg} ---")
if is_fatal_gpu_error(e):
print("\n" + "="*80)
print(f"🚨 [Fatal GPU Error] Captured fatal GPU error during startup check: {err_msg}")
print("🚨 Terminating process to trigger an automatic container restart...")
print("="*80 + "\n")
os._exit(1)
print("--- Starting Application Setup ---")
11 unmodified lines demo = build_ui(attach_event_handlers)
print("--- Launching Gradio Interface ---")
try:
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
except ValueError as e:
if "localhost is not accessible" in str(e):
print("\n" + "="*80)
print(f"🚨 [Gradio Launch Error] Localhost accessibility check failed: {e}")
print("🚨 Terminating process to trigger an automatic container restart...")
print("="*80 + "\n")
sys.exit(1)
raise e
if __name__ == "__main__":37 unmodified lines383940414241434445464748495051525354555657585960616242434437 unmodified lines print(f"Requesting ZeroGPU for {task_name} with duration: {final_duration} seconds.")
gpu_runner = spaces.GPU(duration=final_duration)(gpu_function)
try:
return gpu_runner(*args, **kwargs)
return gpu_runner(*args, **kwargs)
except BaseException as e:
err_type = type(e).__name__
err_str = f"{err_type}: {str(e)} | {repr(e)}".lower()
fatal_keywords = [
"ecc",
"uncorrectable",
"cudaerror",
"acceleratorerror",
"cuda error",
"cuda_error",
"device-side assertion",
"cuda_launch_blocking",
]
if any(kw in err_str for kw in fatal_keywords):
print("\n" + "="*80)
print(f"🚨 [Fatal GPU Error] Captured fatal GPU error during inference: {e}")
print("🚨 Terminating process to trigger an automatic container restart...")
print("="*80 + "\n")
os._exit(1)
raise e
def _encode_video_from_frames(self, frames_tensor_cpu: 'torch.Tensor', fps: int, progress: gr.Progress) -> str:
progress(0.9, desc="Encoding video on CPU...")app.py+6-45
core/pipelines/base_pipeline.py+1-22