Rajesh3338 commited on
Commit
0edfd3f
·
verified ·
1 Parent(s): 8c6bfb1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -17
app.py CHANGED
@@ -2,21 +2,12 @@ import gradio as gr
2
  import spaces
3
  import torch
4
 
5
- def gpu_info():
6
- info = []
7
- info.append(f"Torch Version: {torch.__version__}")
8
- info.append(f"CUDA Available: {torch.cuda.is_available()}")
9
- info.append(f"GPU Count: {torch.cuda.device_count()}")
10
-
11
- if torch.cuda.is_available():
12
- info.append(f"GPU Name: {torch.cuda.get_device_name(0)}")
13
- info.append(f"VRAM: {torch.cuda.get_device_properties(0).total_memory // (1024**2)} MB")
14
- else:
15
- info.append("No GPU detected.")
16
-
17
- return "\n".join(info)
18
 
19
- # Gradio Interface
20
- iface = gr.Interface(fn=gpu_info, inputs=None, outputs="text", title="GPU Information Checker")
21
-
22
- iface.launch()
 
2
  import spaces
3
  import torch
4
 
5
+ @spaces.GPU
6
+ def greet(n):
7
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
8
+ zero = torch.tensor([0], device=device)
9
+ print(zero.device) # This should print 'cuda:0' if GPU is available
10
+ return f"Hello {zero + n} Tensor"
 
 
 
 
 
 
 
11
 
12
+ demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
13
+ demo.launch()