Spaces:
Running
on
Zero
Running
on
Zero
File size: 346 Bytes
4f39643 bc6c851 4f39643 bc6c851 4f39643 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import gradio as gr
import spaces
import torch
import os
zero = torch.Tensor([0]).cuda()
print(zero.device) # <-- 'cpu' 🤔
@spaces.GPU
def greet(n):
os.system("nvidia-smi")
print(zero.device) # <-- 'cuda:0' 🤗
return f"Hello {zero + n} Tensor"
demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
demo.launch()
|