Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,13 +2,12 @@ import gradio as gr
|
|
| 2 |
import spaces
|
| 3 |
import torch
|
| 4 |
|
| 5 |
-
zero = torch.Tensor([0]).cuda()
|
| 6 |
-
print(zero.device) # <-- 'cpu' 🤔
|
| 7 |
-
|
| 8 |
@spaces.GPU
|
| 9 |
def greet(n):
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
return f"Hello {zero + n} Tensor"
|
| 12 |
|
| 13 |
demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
|
| 14 |
-
demo.launch()
|
|
|
|
| 2 |
import spaces
|
| 3 |
import torch
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
@spaces.GPU
|
| 6 |
def greet(n):
|
| 7 |
+
# Create the tensor inside the GPU worker where a real GPU exists
|
| 8 |
+
zero = torch.Tensor([0]).to("cuda")
|
| 9 |
+
print(zero.device) # This will print 'cuda:0'
|
| 10 |
return f"Hello {zero + n} Tensor"
|
| 11 |
|
| 12 |
demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
|
| 13 |
+
demo.launch()
|