cbensimon HF Staff commited on
Commit
e11fc76
·
1 Parent(s): f5fabeb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 n
12
+
13
+ counter = gr.State(value=0)
14
+
15
+ gr.Interface(
16
+ fn=greet,
17
+ inputs=[counter],
18
+ outputs=[counter],
19
+ ).launch()