DonImages commited on
Commit
3cd5f14
·
verified ·
1 Parent(s): c34eee5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -5,11 +5,14 @@ from huggingface_hub import login
5
  import os
6
  import gradio as gr
7
 
8
- # Automatically select the available device (GPU if available, otherwise CPU)
9
- device = zerogpu.select_device() # This will automatically choose 'cuda' or 'cpu'
 
 
 
10
 
11
  # Check and print if the selected device is GPU or CPU
12
- if torch.cuda.is_available():
13
  print(f"Using GPU: {torch.cuda.get_device_name()}")
14
  else:
15
  print("Using CPU")
@@ -72,4 +75,3 @@ iface = gr.Interface(
72
  outputs="image"
73
  )
74
  iface.launch()
75
-
 
5
  import os
6
  import gradio as gr
7
 
8
+ # Initialize ZeroGPU, which will manage device selection
9
+ zerogpu.init() # Initializes ZeroGPU
10
+
11
+ # Automatically choose GPU if available, otherwise CPU
12
+ device = "cuda" if torch.cuda.is_available() else "cpu"
13
 
14
  # Check and print if the selected device is GPU or CPU
15
+ if device == "cuda":
16
  print(f"Using GPU: {torch.cuda.get_device_name()}")
17
  else:
18
  print("Using CPU")
 
75
  outputs="image"
76
  )
77
  iface.launch()