Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import spaces
|
3 |
+
import torch
|
4 |
+
from spaces.zero.client import _get_token
|
5 |
+
|
6 |
+
zero = torch.Tensor([0]).cuda()
|
7 |
+
print(zero.device) # <-- 'cpu' 🤔
|
8 |
+
|
9 |
+
@spaces.GPU(duration=4*60)
|
10 |
+
def inner():
|
11 |
+
return "ok"
|
12 |
+
|
13 |
+
def greet(request: gr.Request, n):
|
14 |
+
assert inner() == "ok"
|
15 |
+
return _get_token(request)
|
16 |
+
|
17 |
+
demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
|
18 |
+
demo.launch()
|