ZeroGPU worker fails with No CUDA GPUs after successful model packing

#179
by spkc83 - opened

Summary

An authenticated Gradio Space consistently fails during ZeroGPU worker initialization
before the decorated inference function begins.

Space: https://huggingface.co/spaces/spkc83/retail-bank-customer-service-poc

Runtime

  • Hardware: zero-a10g
  • GPU request: @spaces.GPU(size="large", duration=90)
  • Python: 3.12
  • PyTorch: 2.9.1
  • Gradio: 5.49.1
  • spaces: 0.51.1
  • Model: BF16 Qwen2MoeForCausalLM, 17.9 GB checkpoint

The checkpoint downloads, loads, and completes the ZeroGPU tensor-packing stage.
The Space then starts successfully and remains in the RUNNING state.

Failure

Every invocation of the decorated function fails before entering application code:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/spaces/zero/wrappers.py", line 148, in worker_init
    torch.init(nvidia_uuid)
  File "/usr/local/lib/python3.12/site-packages/spaces/zero/torch/patching.py", line 417, in init
    torch.Tensor([0]).cuda()
  File "/usr/local/lib/python3.12/site-packages/torch/cuda/__init__.py", line 410, in _lazy_init
    torch._C._cuda_init()
RuntimeError: No CUDA GPUs are available

Reproduction

  1. Open the Space and authenticate with its static Gradio authentication.
  2. Submit any supported banking request, such as Show my account balances.
  3. The CPU router accepts the request.
  4. ZeroGPU worker initialization fails with the traceback above.

The same failure occurs through the Gradio client with a valid Hugging Face bearer token,
so it is not limited to the anonymous quota pool.

Troubleshooting already completed

  • Selected ZeroGPU in the Space settings.
  • Performed a Factory rebuild.
  • Imported spaces at the application entry point before Gradio, the CPU router, or
    anything else that imports PyTorch.
  • Loaded the model at module scope and used the documented model.to("cuda") placement.
  • Confirmed the PyTorch and Python versions are in the currently documented support range.
  • Tested both large and xlarge; both fail at the same worker_init line.
  • Rebuilt the Space several times and retried with authenticated and anonymous callers.

The application catches the failure and does not execute its synthetic backend action.

Could you check whether the ZeroGPU worker is receiving or exposing the allocated NVIDIA
device for this Space?

Sign up or log in to comment