Skip to content

Hugging Face ZeroGPU

Write correct Gradio code for Hugging Face ZeroGPU Spaces, including @spaces.GPU, durations and quotas.

Stars
11,253
Licence
Apache-2.0
Files
5 files

What it does

This skill gives an AI coding agent the rules for building machine-learning demos on Hugging Face Spaces that use ZeroGPU, a shared pool of GPUs that is attached only while a GPU-marked function runs. Once installed, the agent knows how to structure model loading, pick a sensible GPU duration so users do not hit quota errors, avoid unsupported features like torch.compile, and handle CUDA build constraints and concurrency safety. It is guidance for writing and reviewing code rather than a tool that runs anything itself.

Great for

  • Developers building Gradio demos on ZeroGPU Spaces who hit errors like illegal duration or PicklingError
  • Teams reviewing existing Spaces code that uses @spaces.GPU or the spaces Python package
  • Developers installing CUDA-dependent packages such as flash-attn on ZeroGPU

Skip it if

  • Docker or Static Spaces, which cannot run on ZeroGPU (the skill itself says so)
  • General Gradio layout or component work, which the skill points to a separate huggingface-gradio skill for
  • Anyone expecting it to provision hardware or change quota settings; it only changes how code is written

Try asking

  • “Add @spaces.GPU to my Gradio image generation function and pick a sensible duration”
  • “My Space throws PicklingError across the worker boundary, how do I fix it?”
  • “Review my app.py for ZeroGPU constraints like torch.compile and module-scope model loading”
  • “Help me add flash-attn to requirements.txt for a ZeroGPU Space without wheel build failures”
Step-by-step guide: how to use Hugging Face ZeroGPUInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 5 original files, the Apache-2.0 licence and an attribution note.

    huggingface-zerogpu.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip huggingface-zerogpu.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip huggingface-zerogpu.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Set duration to the realistic worst-case runtime rather than relying on the 60s default, since quota is checked against the requested duration.
  • Ask the agent to check the official ZeroGPU docs for current backing GPU and VRAM figures, because the skill notes these change over time.
  • Keep model loading at module scope and GPU computation inside @spaces.GPU functions, and read the concurrency reference when handlers share state.

What's inside

  • references/concurrency.md
  • references/cuda-and-deps.md
  • references/how-quota-works.md
  • references/how-zerogpu-works.md
  • SKILL.md

Redistributed unmodified from huggingface/skills under the Apache-2.0 licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.