Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,21 +1,14 @@
|
|
| 1 |
import spaces
|
| 2 |
import torch
|
| 3 |
import gradio as gr
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
import transformers # noqa
|
| 7 |
-
import torch_geometric # noqa
|
| 8 |
-
print("transformers", transformers.__version__, "pyg", torch_geometric.__version__)
|
| 9 |
-
print("cuda initialized in parent?", torch.cuda.is_initialized())
|
| 10 |
|
| 11 |
@spaces.GPU(duration=30)
|
| 12 |
def probe():
|
| 13 |
x = torch.randn(4, 4, device="cuda")
|
| 14 |
-
return f"OK: {(x @ x).sum().item():.3f}
|
| 15 |
|
| 16 |
with gr.Blocks() as demo:
|
| 17 |
-
|
| 18 |
-
btn = gr.Button("probe")
|
| 19 |
-
btn.click(probe, outputs=out, api_name="probe")
|
| 20 |
-
|
| 21 |
demo.launch()
|
|
|
|
| 1 |
import spaces
|
| 2 |
import torch
|
| 3 |
import gradio as gr
|
| 4 |
+
import transformers # noqa -- test transformers alone
|
| 5 |
+
print("PROBE_MARK transformers", transformers.__version__, "cuda_init_parent=", torch.cuda.is_initialized(), flush=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
@spaces.GPU(duration=30)
|
| 8 |
def probe():
|
| 9 |
x = torch.randn(4, 4, device="cuda")
|
| 10 |
+
return f"OK: {(x @ x).sum().item():.3f}"
|
| 11 |
|
| 12 |
with gr.Blocks() as demo:
|
| 13 |
+
gr.Button("probe").click(probe, outputs=gr.Textbox(), api_name="probe")
|
|
|
|
|
|
|
|
|
|
| 14 |
demo.launch()
|