""" App """ import gradio as gr import time import os import elasticsearch import torch import torch_xla.core.xla_model as xm MB = 1024*1024 def eat_memory(): mem = [] while True: mem += ['c' * (100 * MB)] time.sleep(0.1) #bidule def greet(name): device = xm.xla_device() t1 = torch.randn(3,3,device=device) t2 = torch.randn(3,3,device=device) t3 = str(t1 + t2) return "Hello " + name + "!! Tensor: " + t3 + ", secret: " + os.environ.get("TEST_ENV_SECRET") iface = gr.Interface(fn=greet, inputs="text", outputs="text") iface.launch()