Download DEPLOY.md from build-small-hackathon/one-red-paperclip: direct link, hf CLI and curl.
- Browser
- Download file 2.76 kB
-
https://huggingface.co/spaces/build-small-hackathon/one-red-paperclip/resolve/main/DEPLOY.md
- Command line
-
hf download hf://spaces/build-small-hackathon/one-red-paperclip/DEPLOY.md
-
curl -L -o DEPLOY.md https://huggingface.co/spaces/build-small-hackathon/one-red-paperclip/resolve/main/DEPLOY.md
A newer version of the Gradio SDK is available: 6.32.0
Deploying to Hugging Face Spaces
The app is a standard Gradio app.py, so it deploys to Spaces as-is. Pick a model
in config.yaml (repo_id + filename) and it's downloaded on startup.
Local dev uses uv (
uv sync, CPUllama-cpp-python, no torch/spaces). HF Spaces builds fromrequirements.txt, which ships the ZeroGPU CUDA stack by default. The app auto-selects the runtime: ZeroGPU when HF setsSPACES_ZERO_GPU, otherwise the plainLlamaRuntime. No code change needed to move between the options below.
Option A — ZeroGPU (default; keeps the llama.cpp / Llama Champion badge)
requirements.txt is already set up for this (the llama-cpp-python maintainer's recipe):
prebuilt CUDA llama-cpp-python from the cu124 index, torch==2.8.0 (ships the CUDA libs
llama.cpp links against), hf_transfer, and spaces.
- Create a Gradio Space and select ZeroGPU hardware in Settings (needs a PRO or Team/Enterprise plan). ZeroGPU is Gradio-only — we comply.
- Keep
python_version: "3.12"in theREADME.mdfrontmatter (already set) — the prebuilt CUDA wheels target 3.12. - Set
model.repo_id/filenameinconfig.yamlto the GGUF to test (e.g. Nemotron Nano 9B v2 or MiniCPM4-8B).flash_attnandgpu_durationthere tune the GPU path. - Push. The model downloads on the Space CPU at startup; on each message the GPU is
attached inside
@spaces.GPU, where theLlamamodel is built with all layers offloaded (ZeroGpuLlamaRuntimeinengine/runtime.py).
Tradeoff: ZeroGPU releases the GPU after every call, so the model reloads each turn
(a few seconds on the Blackwell card + generation). Fine for A/B testing. If turns feel
slow, use a smaller model / lower n_ctx / max_tokens, or Option B.
Option B — Plain paid GPU Space (snappiest for a public demo)
A persistent GPU (e.g. Nvidia L4/T4) loads the model once and keeps it warm — no per-turn
reload. The app picks LlamaRuntime automatically here (no SPACES_ZERO_GPU).
- Upgrade the Space to a GPU; keep the CUDA
llama-cpp-pythonfromrequirements.txt. - Set
model.n_gpu_layers: -1inconfig.yamlto offload all layers at startup.
Option C — CPU Space (free, small models only)
Swap requirements.txt to the CPU stack (drop torch, spaces, and the two
--extra-index-url lines; plain llama-cpp-python). Slower; best for ≤4B models.
Local
uv sync # one-time setup
uv run python app.py # uses config.yaml model
SECOND_DEGREE_FAKE=1 uv run python app.py # no model, heuristic NPC (UI dev)
SECOND_DEGREE_ZEROGPU=1 uv run python app.py # force the ZeroGPU path (needs spaces + CUDA wheel)