Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,21 +2,12 @@ import gradio as gr
|
|
2 |
import spaces
|
3 |
import torch
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
if torch.cuda.is_available():
|
12 |
-
info.append(f"GPU Name: {torch.cuda.get_device_name(0)}")
|
13 |
-
info.append(f"VRAM: {torch.cuda.get_device_properties(0).total_memory // (1024**2)} MB")
|
14 |
-
else:
|
15 |
-
info.append("No GPU detected.")
|
16 |
-
|
17 |
-
return "\n".join(info)
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
iface.launch()
|
|
|
2 |
import spaces
|
3 |
import torch
|
4 |
|
5 |
+
@spaces.GPU
|
6 |
+
def greet(n):
|
7 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
8 |
+
zero = torch.tensor([0], device=device)
|
9 |
+
print(zero.device) # This should print 'cuda:0' if GPU is available
|
10 |
+
return f"Hello {zero + n} Tensor"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
|
13 |
+
demo.launch()
|
|
|
|