import gradio as gr | |
import spaces | |
import torch | |
def greet(n): | |
print('cuda avaliable: ' + str(torch.cuda.is_available())) | |
torch.set_default_device('cuda') | |
zero = torch.Tensor([0]).cuda() | |
one = torch.ones(2, 2, device='cuda') | |
two = torch.matmul(one, one).cuda() | |
print('zero device: ' + str(zero.device)) | |
print('one device: ' + str(one.device)) | |
print('two device: ' + str(two.device)) | |
return f"Hello {zero + n} Tensor" | |
gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text()).launch() | |