Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,14 @@ from huggingface_hub import login
|
|
5 |
import os
|
6 |
import gradio as gr
|
7 |
|
8 |
-
#
|
9 |
-
|
|
|
|
|
|
|
10 |
|
11 |
# Check and print if the selected device is GPU or CPU
|
12 |
-
if
|
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()
|
|