LIBE / gpu_probe.py
rocco
gpu_probe added
71753af
Raw History Blame Contribute Delete
738 Bytes
"""Temporary isolation test: set app_file: gpu_probe.py in Space README."""
import spaces
import torch
import gradio as gr
from importlib.metadata import version
print(f"Probe runtime: torch={torch.__version__}, cuda_build={torch.version.cuda}, spaces={version('spaces')}", flush=True)
@spaces.GPU(duration=10)
def test_gpu():
print("GPU probe worker entered", flush=True)
result = (torch.ones(1, device='cuda') + 1).cpu().item()
return f"GPU works: {torch.cuda.get_device_name(0)}; result={result}"
demo = gr.Interface(fn=test_gpu, inputs=[], outputs='text', title='ZeroGPU allocation test')
demo.queue(default_concurrency_limit=1).launch(
server_name="0.0.0.0",
server_port=7860,
prevent_thread_lock=False,
)