multimodalart HF Staff commited on
Commit
0bf77c9
·
verified ·
1 Parent(s): a91f0db

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -1,21 +1,14 @@
1
  import spaces
2
  import torch
3
  import gradio as gr
4
-
5
- # Import the heavy deps at module scope to see which (if any) poisons the fork.
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} on {torch.cuda.get_device_name(0)}"
15
 
16
  with gr.Blocks() as demo:
17
- out = gr.Textbox(label="probe")
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()