Disable Gradio hot-reload to prevent CUDA init race (commit 593d9e9)
Browse files- kimodo/demo/app.py +8 -3
kimodo/demo/app.py
CHANGED
|
@@ -1,18 +1,23 @@
|
|
| 1 |
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
| 2 |
# SPDX-License-Identifier: Apache-2.0
|
| 3 |
|
|
|
|
|
|
|
| 4 |
# ============================================================================
|
| 5 |
# CRITICAL: Import spaces FIRST, before any CUDA-related packages.
|
| 6 |
-
#
|
|
|
|
| 7 |
# ============================================================================
|
|
|
|
| 8 |
try:
|
| 9 |
import spaces # noqa: F401 - imported early for ZeroGPU compatibility
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
pass # Not running on HF Spaces with ZeroGPU
|
| 12 |
|
| 13 |
import base64
|
| 14 |
import logging
|
| 15 |
-
import os
|
| 16 |
import shutil
|
| 17 |
import threading
|
| 18 |
import time
|
|
|
|
| 1 |
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
| 2 |
# SPDX-License-Identifier: Apache-2.0
|
| 3 |
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
# ============================================================================
|
| 7 |
# CRITICAL: Import spaces FIRST, before any CUDA-related packages.
|
| 8 |
+
# Disable Gradio's hot-reload watcher in HF Spaces to avoid CUDA initialization
|
| 9 |
+
# errors when `spaces` package is imported in a separate thread.
|
| 10 |
# ============================================================================
|
| 11 |
+
|
| 12 |
try:
|
| 13 |
import spaces # noqa: F401 - imported early for ZeroGPU compatibility
|
| 14 |
+
# Disable Gradio hot-reload in Spaces (prevents thread race conditions)
|
| 15 |
+
os.environ["GRADIO_HOT_RELOAD"] = "False"
|
| 16 |
+
except (ImportError, RuntimeError):
|
| 17 |
pass # Not running on HF Spaces with ZeroGPU
|
| 18 |
|
| 19 |
import base64
|
| 20 |
import logging
|
|
|
|
| 21 |
import shutil
|
| 22 |
import threading
|
| 23 |
import time
|