mkhodary101 commited on
Commit
dbc9309
·
verified ·
1 Parent(s): d6cb9b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -1,7 +1,20 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch(share=True, debug=True)
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import torch
3
+ import spaces # Import ZeroGPU helper
4
 
5
+ # Function to check GPU availability
6
+ @spaces.GPU # This tells Hugging Face to allocate a GPU when this function is called
7
+ def check_gpu():
8
+ if torch.cuda.is_available():
9
+ return "✅ GPU is available! CUDA device: " + torch.cuda.get_device_name(0)
10
+ else:
11
+ return "❌ No GPU detected!"
12
 
13
+ # Gradio UI
14
+ iface = gr.Interface(
15
+ fn=check_gpu, # Call the GPU-checking function
16
+ inputs=[],
17
+ outputs="text",
18
+ )
19
+
20
+ iface.launch(share=True, ssr=False)