Spaces:
Running on Zero
Running on Zero
Download app.py from sofhiaazzhr/knowledge-pipeline: direct link, hf CLI and curl.
- Browser
- Download file 750 Bytes
-
https://huggingface.co/spaces/sofhiaazzhr/knowledge-pipeline/resolve/main/app.py
- Command line
-
hf download hf://spaces/sofhiaazzhr/knowledge-pipeline/app.py
-
curl -L -o app.py https://huggingface.co/spaces/sofhiaazzhr/knowledge-pipeline/resolve/main/app.py
750 Bytes
| import gradio as gr | |
| import spaces | |
| import torch | |
| 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() |