Error while initializing ZeroGPU

We met a problem when restarting this space.

=== Application stopped (exit code: 1) at 2025-06-09 09:46:03.094740285 UTC ===
/usr/local/lib/python3.10/site-packages/torch_geometric/typing.py:101: UserWarning: An issue occurred while importing ‘torch-sparse’. Disabling its usage. Stacktrace:
Class _DeviceStringOnly does not have an init function defined:
File “/usr/local/lib/python3.10/site-packages/torch_sparse/tensor.py”, line 482
def cpu(self):
return self.to_device(device=torch.device(‘cpu’), non_blocking=False)


warnings.warn(f"An issue occurred while importing 'torch-sparse'. "

ZeroGPU tensors packing: 0.00B [00:00, ?B/s]
ZeroGPU tensors packing: 0.00B [00:00, ?B/s]
2025-06-09 11:46:32,981 INFO [_client.py:1025 _send_single_request] HTTP Request: POST http://device-api.zero/startup-report?cgroupPath=%2Fkubepods.slice%2Fkubepods-burstable.slice%2Fkubepods-burstable-podcd3b3b52_f5bd_4b51_be47_798a988dd534.slice%2Fcri-containerd-7f113b02cd8cb5a7aeed15939ef5beac08a3b0ae76db8297943910dad9a6fa49.scope&gpuSize=large "HTTP/1.1 409 Conflict"
Traceback (most recent call last):
File "/home/user/app/app.py", line 512, in
demo.launch(share=True)
File "/usr/local/lib/python3.10/site-packages/spaces/zero/gradio.py", line 162, in launch
task(*task_args, **task_kwargs)
File "/usr/local/lib/python3.10/site-packages/spaces/zero/**init**.py", line 30, in startup
client.startup_report(utils.self_cgroup_device_path(), gpu_size)
File "/usr/local/lib/python3.10/site-packages/spaces/zero/client.py", line 57, in startup_report
raise RuntimeError("Error while initializing ZeroGPU: Unknown")
RuntimeError: Error while initializing ZeroGPU: Unknown
2025-06-09 11:46:33,72 INFO [_client.py:1025 _send_single_request] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
=== Application stopped (exit code: 1) at 2025-06-09 09:46:34.369466631 UTC ===

Here is the Space URL: https://huggingface.co/spaces/Zaixi/Pocket-Gen. You can find the app.py file there.
How to fix this error?
Thanks.
1 Like

A 500 error with :hugs: icon usually means that the space is overloaded and has crashed, or there is a temporary problem with the site. I heard that it happened last night as well. Let’s try restarting the space.

In any case, the necessary requirements.txt file is missing, so it won’t work…

Thank you for your reply. Actually, the dependencies have already been installed in dev mode, and the project runs fine initially. However, after some time, the above error appears again, and I have tried many times with the same result.
I have now uploaded the necessary files to the Space. In dev mode, run the following commands:

text

pip install -r requirements.txt
pip install AutoDockTools_py3-master.zip
python g.py
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.5.0+cu124.html

After these, the project should run successfully.

1 Like

I see. It was in Dev mode.:sweat_smile:
Dev mode is convenient, but it has bugs, such as the latest commit not being reflected. Also, in the case of Zero GPU Spaces, if something other than the spaces library touches CUDA first, it almost always crashes.

If there are .to("cuda") or .cuda() in the library, it’s pretty much a no-go.

Also, Zero GPU Spaces are CPU spaces except for those within the @spaces.GPU decorator, so installers that assume a CUDA environment will not work. Prebuilt binaries will probably work, though…
As a result, there are quite a few libraries that are effectively unusable. For details: zero-gpu-explorers/README · Discussions

1 Like

Thanks for reporting! We’re taking a look.

1 Like

1. Check GPU Availability in Space Settings

  • Many Hugging Face Spaces (especially on free/shared tiers) do not provide GPU access by default.
  • Go to Space Settings → Hardware and confirm if GPU is enabled. If not, enable GPU or switch to a paid tier that allows GPU usage.

2. Fix torch-sparse Version Issues

  • The error indicates a compatibility problem with torch-sparse.
  • Try upgrading (or downgrading) torch-sparse to a version matching your PyTorch version:
    pip install --upgrade torch-sparse
    
    or, if using PyTorch 2.x:
    pip install torch-sparse==latest_compatible_version
    
  • Also, ensure all dependencies are compatible in your requirements.txt.

3. Force CPU if GPU Unavailable

  • If your Space will not be allocated a GPU, ensure your code has a fallback to CPU. Example:
    import torch
    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    tensor = tensor.to(device)
    
  • Remove any code that hard-requires a GPU if running on a CPU-only environment.

4. Restart and Rebuild the Space

  • After making changes, use the “Restart” and “Rebuild” options in your Space’s management panel.

Solution provided by Triskel Data Deterministic Ai.

1 Like