alex4cip Claude commited on
Commit
ab64ed7
·
1 Parent(s): 9171967

fix: Import spaces before CUDA-related packages

Browse files

RuntimeError: CUDA has been initialized before importing the `spaces` package

🔧 Fix:
- Move 'import spaces' to the very first import
- Must be imported before torch, transformers, or any CUDA packages
- Critical for ZeroGPU to work properly

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -3,11 +3,11 @@ ZeroGPU version: Llama-2-Ko 7B with dynamic GPU allocation
3
  Requires: PRO subscription + ZeroGPU hardware selection in Space settings
4
  """
5
 
 
6
  import os
7
  import gradio as gr
8
  from transformers import AutoModelForCausalLM, AutoTokenizer
9
  import torch
10
- import spaces # ZeroGPU decorator
11
 
12
  # Get HF token from environment
13
  HF_TOKEN = os.getenv("HF_TOKEN", None)
 
3
  Requires: PRO subscription + ZeroGPU hardware selection in Space settings
4
  """
5
 
6
+ import spaces # ZeroGPU decorator - MUST be imported first!
7
  import os
8
  import gradio as gr
9
  from transformers import AutoModelForCausalLM, AutoTokenizer
10
  import torch
 
11
 
12
  # Get HF token from environment
13
  HF_TOKEN = os.getenv("HF_TOKEN", None)