File size: 520 Bytes
7d1f745
dbc9309
 
4f7ba4c
dbc9309
 
 
 
 
 
 
7d1f745
dbc9309
 
 
 
 
 
 
8bf25c1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
import torch
import spaces  # Import ZeroGPU helper

# Function to check GPU availability
@spaces.GPU  # This tells Hugging Face to allocate a GPU when this function is called
def check_gpu():
    if torch.cuda.is_available():
        return "✅ GPU is available! CUDA device: " + torch.cuda.get_device_name(0)
    else:
        return "❌ No GPU detected!"

# Gradio UI
iface = gr.Interface(
    fn=check_gpu,  # Call the GPU-checking function
    inputs=[],
    outputs="text",
)

iface.launch()