LogicGoInfotechSpaces commited on
Commit
8195245
·
1 Parent(s): 1641332

Import spaces before torch-related modules and set CUDA env early (ZeroGPU fix)

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -4,11 +4,15 @@ import logging
4
  from typing import Tuple, Dict
5
 
6
  import gradio as gr
 
7
  from huggingface_hub import snapshot_download
8
  from PIL import Image
9
 
 
 
 
 
10
  from runners.simple_runner import SimpleRunner
11
- from spaces import GPU
12
 
13
 
14
  # -----------------------------------------------------------------------------
@@ -21,9 +25,6 @@ logger = logging.getLogger("sfe-app")
21
  # -----------------------------------------------------------------------------
22
  # Model bootstrap (load once and reuse)
23
  # -----------------------------------------------------------------------------
24
- # Force CPU on Spaces and avoid CUDA arch auto-detection errors during JIT
25
- os.environ.setdefault("CUDA_VISIBLE_DEVICES", "")
26
- os.environ.setdefault("TORCH_CUDA_ARCH_LIST", "8.0")
27
  RUNNER: SimpleRunner | None = None
28
 
29
 
 
4
  from typing import Tuple, Dict
5
 
6
  import gradio as gr
7
+ from spaces import GPU
8
  from huggingface_hub import snapshot_download
9
  from PIL import Image
10
 
11
+ # Configure environment BEFORE importing any torch-dependent modules
12
+ os.environ.setdefault("CUDA_VISIBLE_DEVICES", "")
13
+ os.environ.setdefault("TORCH_CUDA_ARCH_LIST", "8.0")
14
+
15
  from runners.simple_runner import SimpleRunner
 
16
 
17
 
18
  # -----------------------------------------------------------------------------
 
25
  # -----------------------------------------------------------------------------
26
  # Model bootstrap (load once and reuse)
27
  # -----------------------------------------------------------------------------
 
 
 
28
  RUNNER: SimpleRunner | None = None
29
 
30