gradio-state / app.py
cbensimon's picture
cbensimon HF Staff
Create app.py
e11fc76
raw
history blame
313 Bytes
import gradio as gr
import spaces
import torch
zero = torch.Tensor([0]).cuda()
print(zero.device) # <-- 'cpu' πŸ€”
@spaces.GPU
def greet(n):
print(zero.device) # <-- 'cuda:0' πŸ€—
return n
counter = gr.State(value=0)
gr.Interface(
fn=greet,
inputs=[counter],
outputs=[counter],
).launch()