File size: 461 Bytes
f62480b a9e3801 f62480b a9e3801 f62480b d73e9f0 a9e3801 f62480b a9e3801 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
import spaces
import torch
zero = torch.Tensor([0]).cuda()
print(zero.device) # <-- 'cpu' 🤔
testgpu= torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(testgpu)
@spaces.GPU
def greet(n):
print(zero.device) # <-- 'cuda:0' 🤗
return f"Hello {zero + n} Tensor"
#demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
demo.launch()
|