domains / devops / huggingface-spaces-deploy / huggingface-spaces

huggingface-spaces

Skill card

combined

The huggingface/skills copy is the upstream source, but the sickn33 copy is not a faithful reproduction: it changes the login procedure, the hardware gating rules, and the fallback strategy for free accounts. Because the copies disagree on material steps (how to authenticate, which hardware is free, and what to do when a user cannot pay for the required hardware), crowning one would hide a real alternative.

Repositories

RepositoryPath
huggingface/skillsskills/huggingface-spaces/SKILL.md
sickn33/agentic-awesome-skillsplugins/agentic-awesome-skills-claude/skills/huggingface-spaces/SKILL.md

Other copies

RoleRepositoryPath
peerhuggingface/skillsskills/huggingface-spaces/SKILL.md
peersickn33/agentic-awesome-skillsplugins/agentic-awesome-skills-claude/skills/huggingface-spaces/SKILL.md
adaptersickn33/agentic-awesome-skillsplugins/agentic-awesome-skills/skills/huggingface-spaces/SKILL.md
adaptersickn33/agentic-awesome-skillsskills/huggingface-spaces/SKILL.md

Combined skill

---
name: huggingface-spaces
description: Build, deploy, and maintain applications on Hugging Face Spaces — Gradio / Docker / Static SDKs, ZeroGPU and dedicated hardware, model loading, debugging, buckets, inference providers, community grants.
---

# Hugging Face Spaces

Hugging Face Spaces host machine-learning applications. Each Space is a git repo. This skill covers creating, building, debugging, and maintaining them.

## 0. Getting ready

1. Check the `hf` CLI is installed: `which hf`. If not, `pip install -U huggingface_hub`.
2. Check the user is logged in: `hf auth whoami`. If not, run `hf auth login`. 
   - **Conflicts**: The upstream `huggingface/skills` repository states this uses an OAuth flow (URL + one-time code, no token). The `sickn33/agentic-awesome-skills` repository states the user must provide a write-scoped token. Verify the current `hf` CLI behavior or ask the user for their preferred method.
3. Note `whoami`'s `canPay` and `isPro` flags — they gate hardware choices.

## 1. What a Space is

A Space is a git repo with three possible SDKs:
- **Gradio** — Python, fast iteration, supports ZeroGPU.
- **Docker** — Arbitrary container. Does not support ZeroGPU.
- **Static** — Plain HTML or built frontend. No hardware needed.

### Hardware tiers

- **Static**: Free for everyone.
- **ZeroGPU (`zero-a10g`)**: Dynamic GPU allocation. Gradio-only, PyTorch-first.
  - **Conflicts**: `huggingface/skills` states free personal accounts can host up to 2 ZeroGPU Spaces. `sickn33/agentic-awesome-skills` states ZeroGPU requires a PRO/Team/Enterprise plan. Check the current Hugging Face documentation for the latest gating rules.
- **`cpu-basic`**: 2 vCPU / 16 GB.
  - **Conflicts**: `huggingface/skills` states this requires a paid plan. `sickn33/agentic-awesome-skills` states it is free. Verify current pricing.
- **Dedicated GPU**: Billed by the hour. Requires `canPay=True`.

## 2. Look for an existing demo first

Search for prior art before building:
```bash
hf spaces search "<model name or task>" --sdk gradio --limit 10
```
Read the `app.py` and `requirements.txt` of similar Spaces to find working patterns.

## 3. Decide SDK and hardware

- **Default for public ML demo**: Gradio + ZeroGPU.
- **Non-PyTorch main model**: Dedicated GPU.
- **Tiny/CPU-bound model**: `cpu-basic` (if available for the account tier) or ZeroGPU with a no-op decorated function.
- **Browser-side ML**: Static.
- **Non-Python stack**: Docker.

### Sourcing the model

- **GitHub repo**: Clone locally. If it has a Gradio demo, adapt it to ZeroGPU.
- **HF model repo**: Read README, follow linked GitHub.
- **Paper/Blog**: Look for official implementations.

## 4. Create the Space

```bash
hf repos create <namespace>/<name> --type space --space-sdk <gradio|docker|static> \
    [--flavor zero-a10g|cpu-basic|<paid-flavor>] \
    --public|--private|--protected \
    --exist-ok
```

## 5. Fallback for hardware limits

If the user cannot pay for the required hardware:
- **Conflicts**: `huggingface/skills` recommends creating a Static Space and requesting a community grant. `sickn33/agentic-awesome-skills` recommends creating a `cpu-basic` Space, coding for ZeroGPU, and requesting a grant. Choose the path that matches the current platform capabilities.