Spaces:
Sleeping
Sleeping
File size: 750 Bytes
e9d7853 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import gradio as gr
import spaces
import torch
@spaces.GPU
def check_gpu():
"""Runs on ZeroGPU — proves the GPU is actually allocated to this call."""
available = torch.cuda.is_available()
name = torch.cuda.get_device_name(0) if available else "none"
x = torch.tensor([1.0]).cuda() # forces a real GPU op
return {
"cuda_available": available,
"device": str(x.device), # should be 'cuda:0'
"gpu_name": name,
}
with gr.Blocks() as demo:
gr.Markdown("# knowledge-pipeline — GPU + API smoke test")
out = gr.JSON(label="result")
gr.Button("Check GPU").click(fn=check_gpu, inputs=None, outputs=out,
api_name="check_gpu")
demo.launch() |