hiyouga commited on
Commit
bed1c6d
1 Parent(s): 95eb79b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
9
+ @spaces.GPU
10
+ def greet(n):
11
+ print(zero.device) # <-- 'cuda:0' 🤗
12
+ return f"Hello {zero + n} Tensor"
13
+
14
+
15
+ demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
16
+ demo.launch()