Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,14 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import torch
|
3 |
|
4 |
-
|
5 |
-
zero
|
6 |
-
print(f"Outside function: {zero.device}") # Should print 'cuda:0'
|
7 |
|
8 |
-
|
9 |
-
@spaces.GPU
|
10 |
def greet(n):
|
11 |
-
|
12 |
-
return f"Hello
|
13 |
|
14 |
-
|
15 |
-
demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
|
16 |
-
|
17 |
-
# Launch the Gradio demo
|
18 |
demo.launch()
|
|
|
1 |
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 |
+
print(zero.device) # <-- 'cuda:0' 🤗
|
11 |
+
return f"Hello {zero + n} Tensor"
|
12 |
|
13 |
+
demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
|
|
|
|
|
|
|
14 |
demo.launch()
|