{"course":{"slug":"hugging-face","title":"Hugging Face, End to End","url":"https://addaly.com/learn/hugging-face","level":"intermediate","track":"create"},"lesson":{"slug":"hardware-sleep-and-zerogpu","title":"Hardware, sleep, and the bill that runs while you are asleep","url":"https://addaly.com/learn/hugging-face/hardware-sleep-and-zerogpu","position":33,"of":75,"minutes":9,"answer":"Paid Space hardware bills for wall-clock uptime rather than requests and does not sleep unless you set the timer first, while ZeroGPU attaches a GPU per function call.","keyIdea":"Paid Space hardware bills for wall-clock uptime rather than requests and does not sleep unless you set the timer first, while ZeroGPU attaches a GPU per function call, which is the only route to a free public demo that needs real acceleration."},"body":{"format":"markdown","text":"## The shape of the pricing\n\nFree CPU hardware is free permanently and sleeps when idle. Every upgrade past it bills **per hour of wall-clock time the Space is running**, not per request and not per unit of compute. A Space serving three visitors a day on a paid GPU costs exactly what one serving three thousand costs, because the meter is time.\n\nThis is the single most expensive misunderstanding on the platform. People upgrade to test something, close the tab, and find a bill weeks later. Approximate rates change, so check the current figures before committing, but the order of magnitude is worth carrying: a small paid CPU upgrade is a few US cents an hour, an entry-level GPU in the region of a dollar an hour, and a large-memory GPU several dollars an hour. A dollar an hour is about 720 dollars a month if nothing stops it.\n\n## Set the sleep timer before you upgrade\n\nIn Settings there is a sleep time: after this many minutes of no traffic, the Space stops and billing stops. The order matters:\n\n> Figure: What a tier costs if nothing stops it. Bars (US dollars for a month left running): Free CPU basic, which sleeps by itself 0; ZeroGPU, a GPU attached per function call 0; A small paid CPU upgrade 22; An entry-level GPU at about a dollar an hour 720. Rates move and these are orders of magnitude rather than quotes. The shape does not move: paid hardware bills wall-clock time and does not sleep unless you set the timer first, so a Space serving three visitors a day costs exactly what one serving three thousand costs.\n\n1. Set the sleep timer.\n2. Then change the hardware.\n\nDoing it the other way leaves a window, and windows become weekends. Free CPU Spaces sleep on their own schedule; **paid hardware does not sleep unless you tell it to.** That asymmetry is where the surprise bills come from.\n\nWaking from sleep costs a cold start: container start, dependency layer restore, model download if the cache was cleared, model load. Ten seconds for a small ONNX model, two or three minutes for a large one. If the wait is unacceptable, the answer is either persistent storage so the weights are already there, or paying for uptime, and those are the only two answers.\n\n## ZeroGPU: the interesting option\n\nZeroGPU allocates GPU time **per function call** rather than reserving a machine. You mark the functions that need a GPU:\n\n```python\nimport spaces\n\n@spaces.GPU(duration=60)\ndef generate(prompt):\n    return pipe(prompt).images[0]\n```\n\nBetween calls, no GPU is held. The Space itself runs on CPU; when `generate` is invoked, a slice of an A100-class GPU is attached for up to `duration` seconds, then released.\n\nWhat this buys: a free public demo that uses a GPU, which is otherwise impossible. What it costs:\n\n- **Gradio only**, and the decorator has to be applied to the right functions.\n- **A per-call ceiling.** Set `duration` honestly: asking for 120 seconds when you need 20 wastes quota, and asking for 20 when you need 60 gets your call killed mid-generation.\n- **Cold attachment.** There is overhead on each allocation, so many tiny GPU calls are worse than one batched call.\n- **A quota**, larger for paying accounts, and shared across the platform at busy times.\n\nIt is the right choice for image generation, speech and mid-sized chat demos that are used in bursts. It is the wrong choice for a Space serving steady production traffic, where a dedicated endpoint is both faster and more predictable.\n\n## Choosing, in one pass\n\n- **Embeddings, classifiers, ONNX, small Whisper** → free CPU. Permanently.\n- **Image generation, larger chat, a public demo with a GPU** → ZeroGPU.\n- **Steady traffic with a latency promise** → paid hardware with a sleep timer, or a dedicated endpoint.\n- **A private tool for yourself** → free CPU and tolerate the cold start, or run it on your own machine.\n\n## Three habits that keep the bill honest\n\n1. **Check your Spaces list monthly.** A forgotten upgraded Space is the classic way to spend money on nothing.\n2. **Set a spending limit** in billing settings if your account supports one, rather than relying on memory.\n3. **Develop locally, deploy once.** Every debugging cycle on paid hardware is a cycle billed for a bug.\n\n## The position on free\n\nHugging Face gives away a lot: unlimited public repositories, permanent free CPU Spaces, ZeroGPU quota, and a large amount of bandwidth. That generosity is real and it is also a commercial strategy, funded by enterprise customers and paid compute. It could change. Nothing in this lesson is a promise about 2028, and any project whose viability depends on a free tier staying free should be able to move, which, since everything here is git repositories and open formats, it can.\n\n## Do this now\n\nOpen the settings of any Space you own and look at the sleep time. If it says never and the hardware is not free, change one of the two right now, before finishing this lesson."},"check":{"question":"A Space upgraded to a GPU serves about twenty requests a day. The owner is surprised by the size of the monthly bill. What is the mechanism?","options":[{"text":"GPU Spaces bill a minimum per-request allocation, so low-volume traffic is charged at a much worse effective rate.","correct":false,"tempting":"Describes ZeroGPU-style per-call accounting, which is not how reserved hardware is billed."},{"text":"Billing counts wall-clock uptime, and paid hardware keeps running between requests unless a sleep timer stops it.","correct":true},{"text":"Each cold start re-downloads the model, and bandwidth on paid hardware is charged separately from compute.","correct":false,"tempting":"Invents a bandwidth charge and assumes frequent cold starts on hardware that in fact never slept."},{"text":"The Space kept a GPU reserved for the queue, which scales its reservation with the number of concurrent sessions.","correct":false,"tempting":"Imagines elastic reservation; the hardware tier is fixed once selected."}]},"prev":{"slug":"the-space-configuration","title":"The README front matter is the deployment config","url":"https://addaly.com/learn/hugging-face/the-space-configuration"},"next":{"slug":"storage-in-a-space","title":"The filesystem disappears, and what to do about it","url":"https://addaly.com/learn/hugging-face/storage-in-a-space"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Exam keys checked blind by a second model: 3,665 of 3,666 agreed. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'Hardware, sleep, and the bill that runs while you are asleep', in Hugging Face, End to End. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/hugging-face/hardware-sleep-and-zerogpu (Accessed: 13 October 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"Hardware, sleep, and the bill that runs while you are asleep","courseTitle":"Hugging Face, End to End","module":{"index":4,"slug":"spaces-and-shipping-something","title":"Spaces: putting something in front of people"},"answer":null,"keyIdea":"Paid Space hardware bills for wall-clock uptime rather than requests and does not sleep unless you set the timer first, while ZeroGPU attaches a GPU per function call, which is the only route to a free public demo that needs real acceleration.","hero":{"kind":"figure","figure":{"t":"figure","label":"Figure","figure":{"type":"bars","unit":"US dollars for a month left running","title":"What a tier costs if nothing stops it","series":[{"label":"Free CPU basic, which sleeps by itself","value":0},{"label":"ZeroGPU, a GPU attached per function call","value":0},{"label":"A small paid CPU upgrade","value":22},{"label":"An entry-level GPU at about a dollar an hour","value":720,"highlight":true}],"caption":"Rates move and these are orders of magnitude rather than quotes. The shape does not move: paid hardware bills wall-clock time and does not sleep unless you set the timer first, so a Space serving three visitors a day costs exactly what one serving three thousand costs."},"alt":"Figure: What a tier costs if nothing stops it. Bars (US dollars for a month left running): Free CPU basic, which sleeps by itself 0; ZeroGPU, a GPU attached per function call 0; A small paid CPU upgrade 22; An entry-level GPU at about a dollar an hour 720. Rates move and these are orders of magnitude rather than quotes. The shape does not move: paid hardware bills wall-clock time and does not sleep unless you set the timer first, so a Space serving three visitors a day costs exactly what one serving three thousand costs."}},"blocks":[{"t":"h2","id":"the-shape-of-the-pricing","runs":[{"text":"The shape of the pricing"}]},{"t":"p","runs":[{"text":"Free CPU hardware is free permanently and sleeps when idle. Every upgrade past it bills "},{"text":"per hour of wall-clock time the Space is running","b":true},{"text":", not per request and not per unit of compute. A Space serving three visitors a day on a paid GPU costs exactly what one serving three thousand costs, because the meter is time."}]},{"t":"p","runs":[{"text":"This is the single most expensive misunderstanding on the platform. People upgrade to test something, close the tab, and find a bill weeks later. Approximate rates change, so check the current figures before committing, but the order of magnitude is worth carrying: a small paid CPU upgrade is a few US cents an hour, an entry-level GPU in the region of a dollar an hour, and a large-memory GPU several dollars an hour. A dollar an hour is about 720 dollars a month if nothing stops it."}]},{"t":"h2","id":"set-the-sleep-timer-before-you-upgrade","runs":[{"text":"Set the sleep timer before you upgrade"}]},{"t":"p","runs":[{"text":"In Settings there is a sleep time: after this many minutes of no traffic, the Space stops and billing stops. The order matters:"}]},{"t":"ol","start":1,"items":[[{"text":"Set the sleep timer."}],[{"text":"Then change the hardware."}]]},{"t":"p","runs":[{"text":"Doing it the other way leaves a window, and windows become weekends. Free CPU Spaces sleep on their own schedule; "},{"text":"paid hardware does not sleep unless you tell it to.","b":true},{"text":" That asymmetry is where the surprise bills come from."}]},{"t":"p","runs":[{"text":"Waking from sleep costs a cold start: container start, dependency layer restore, model download if the cache was cleared, model load. Ten seconds for a small ONNX model, two or three minutes for a large one. If the wait is unacceptable, the answer is either persistent storage so the weights are already there, or paying for uptime, and those are the only two answers."}]},{"t":"h2","id":"zerogpu-the-interesting-option","runs":[{"text":"ZeroGPU: the interesting option"}]},{"t":"p","runs":[{"text":"ZeroGPU allocates GPU time "},{"text":"per function call","b":true},{"text":" rather than reserving a machine. You mark the functions that need a GPU:"}]},{"t":"code","lang":"python","label":"Python","text":"import spaces\n\n@spaces.GPU(duration=60)\ndef generate(prompt):\n    return pipe(prompt).images[0]"},{"t":"p","runs":[{"text":"Between calls, no GPU is held. The Space itself runs on CPU; when "},{"text":"generate","code":true},{"text":" is invoked, a slice of an A100-class GPU is attached for up to "},{"text":"duration","code":true},{"text":" seconds, then released."}]},{"t":"p","runs":[{"text":"What this buys: a free public demo that uses a GPU, which is otherwise impossible. What it costs:"}]},{"t":"ul","items":[[{"text":"Gradio only","b":true},{"text":", and the decorator has to be applied to the right functions."}],[{"text":"A per-call ceiling.","b":true},{"text":" Set "},{"text":"duration","code":true},{"text":" honestly: asking for 120 seconds when you need 20 wastes quota, and asking for 20 when you need 60 gets your call killed mid-generation."}],[{"text":"Cold attachment.","b":true},{"text":" There is overhead on each allocation, so many tiny GPU calls are worse than one batched call."}],[{"text":"A quota","b":true},{"text":", larger for paying accounts, and shared across the platform at busy times."}]]},{"t":"p","runs":[{"text":"It is the right choice for image generation, speech and mid-sized chat demos that are used in bursts. It is the wrong choice for a Space serving steady production traffic, where a dedicated endpoint is both faster and more predictable."}]},{"t":"h2","id":"choosing-in-one-pass","runs":[{"text":"Choosing, in one pass"}]},{"t":"ul","items":[[{"text":"Embeddings, classifiers, ONNX, small Whisper","b":true},{"text":" → free CPU. Permanently."}],[{"text":"Image generation, larger chat, a public demo with a GPU","b":true},{"text":" → ZeroGPU."}],[{"text":"Steady traffic with a latency promise","b":true},{"text":" → paid hardware with a sleep timer, or a dedicated endpoint."}],[{"text":"A private tool for yourself","b":true},{"text":" → free CPU and tolerate the cold start, or run it on your own machine."}]]},{"t":"h2","id":"three-habits-that-keep-the-bill-honest","runs":[{"text":"Three habits that keep the bill honest"}]},{"t":"ol","start":1,"items":[[{"text":"Check your Spaces list monthly.","b":true},{"text":" A forgotten upgraded Space is the classic way to spend money on nothing."}],[{"text":"Set a spending limit","b":true},{"text":" in billing settings if your account supports one, rather than relying on memory."}],[{"text":"Develop locally, deploy once.","b":true},{"text":" Every debugging cycle on paid hardware is a cycle billed for a bug."}]]},{"t":"h2","id":"the-position-on-free","runs":[{"text":"The position on free"}]},{"t":"p","runs":[{"text":"Hugging Face gives away a lot: unlimited public repositories, permanent free CPU Spaces, ZeroGPU quota, and a large amount of bandwidth. That generosity is real and it is also a commercial strategy, funded by enterprise customers and paid compute. It could change. Nothing in this lesson is a promise about 2028, and any project whose viability depends on a free tier staying free should be able to move, which, since everything here is git repositories and open formats, it can."}]},{"t":"h2","id":"do-this-now","runs":[{"text":"Do this now"}],"role":"try"},{"t":"p","runs":[{"text":"Open the settings of any Space you own and look at the sleep time. If it says never and the hardware is not free, change one of the two right now, before finishing this lesson."}]}],"check":{"question":[{"text":"A Space upgraded to a GPU serves about twenty requests a day. The owner is surprised by the size of the monthly bill. What is the mechanism?"}],"options":[{"text":[{"text":"GPU Spaces bill a minimum per-request allocation, so low-volume traffic is charged at a much worse effective rate."}],"correct":false,"tempting":[{"text":"Describes ZeroGPU-style per-call accounting, which is not how reserved hardware is billed."}]},{"text":[{"text":"Billing counts wall-clock uptime, and paid hardware keeps running between requests unless a sleep timer stops it."}],"correct":true,"tempting":null},{"text":[{"text":"Each cold start re-downloads the model, and bandwidth on paid hardware is charged separately from compute."}],"correct":false,"tempting":[{"text":"Invents a bandwidth charge and assumes frequent cold starts on hardware that in fact never slept."}]},{"text":[{"text":"The Space kept a GPU reserved for the queue, which scales its reservation with the number of concurrent sessions."}],"correct":false,"tempting":[{"text":"Imagines elastic reservation; the hardware tier is fixed once selected."}]}],"order":[3,0,1,2],"why":null},"prev":{"slug":"the-space-configuration","title":"The README front matter is the deployment config","minutes":8},"next":{"slug":"storage-in-a-space","title":"The filesystem disappears, and what to do about it","minutes":8}}}