openfree commited on
Commit
862b58a
·
verified ·
1 Parent(s): 5bd1a65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -10,6 +10,9 @@ import numpy as np
10
  from diffusers import DiffusionPipeline
11
  from transformers import pipeline as hf_pipeline
12
 
 
 
 
13
  ##############################################################################
14
  # 1) ZeroGPU 환경 처리 + device, dtype 설정
15
  ##############################################################################
@@ -17,17 +20,19 @@ from transformers import pipeline as hf_pipeline
17
  try:
18
  import zerogpu
19
  zerogpu.init()
 
20
  device = "cuda" if torch.cuda.is_available() else "cpu"
21
  except ImportError:
22
  # ZeroGPU가 설치되지 않은 경우
 
23
  if os.getenv("ZERO_GPU"):
24
  print("ZeroGPU environment variable is set but zerogpu package is not installed.")
25
- device = "cpu"
26
- else:
27
- device = "cuda" if torch.cuda.is_available() else "cpu"
28
  except Exception as e:
 
29
  print(f"Error initializing ZeroGPU: {e}")
30
- device = "cpu"
 
31
 
32
  # GPU일 때만 bfloat16, 그 외에는 float32
33
  dtype = torch.bfloat16 if device == "cuda" else torch.float32
 
10
  from diffusers import DiffusionPipeline
11
  from transformers import pipeline as hf_pipeline
12
 
13
+ ##############################################################################
14
+ # 1) ZeroGPU 환경 처리 + device, dtype 설정
15
+ ##############################################################################
16
  ##############################################################################
17
  # 1) ZeroGPU 환경 처리 + device, dtype 설정
18
  ##############################################################################
 
20
  try:
21
  import zerogpu
22
  zerogpu.init()
23
+ print("ZeroGPU initialized successfully")
24
  device = "cuda" if torch.cuda.is_available() else "cpu"
25
  except ImportError:
26
  # ZeroGPU가 설치되지 않은 경우
27
+ print("ZeroGPU package not installed, continuing without it")
28
  if os.getenv("ZERO_GPU"):
29
  print("ZeroGPU environment variable is set but zerogpu package is not installed.")
30
+ device = "cuda" if torch.cuda.is_available() else "cpu"
 
 
31
  except Exception as e:
32
+ # ZeroGPU 초기화 중 다른 오류가 발생한 경우
33
  print(f"Error initializing ZeroGPU: {e}")
34
+ print("Continuing without ZeroGPU")
35
+ device = "cuda" if torch.cuda.is_available() else "cpu"
36
 
37
  # GPU일 때만 bfloat16, 그 외에는 float32
38
  dtype = torch.bfloat16 if device == "cuda" else torch.float32