Skip to content

Commit 3c38c2e

Browse files
committed
add doc
1 parent 33579c3 commit 3c38c2e

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

docs/hub/_toctree.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@
238238
title: Using Spaces for Organization Cards
239239
- local: spaces-gpus
240240
title: Spaces GPU Upgrades
241+
- local: spaces-zerogpu
242+
title: Spaces ZeroGPU
241243
- local: spaces-storage
242244
title: Spaces Persistent Storage
243245
- local: spaces-sdks-gradio

docs/hub/spaces-zerogpu.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Spaces ZeroGPU: Dynamic GPU Allocation for Spaces
2+
3+
<img src="https://cdn-uploads.huggingface.co/production/uploads/5f17f0a0925b9863e28ad517/naVZI-v41zNxmGlhEhGDJ.gif" style="max-width: 550px; width: 100%" alt="ZeroGPU schema" />
4+
5+
ZeroGPU introduces a new approach to GPU utilization in Hugging Face Spaces. This innovative hardware solution offers two primary benefits:
6+
7+
1. **Free GPU Access**: Enables cost-effective GPU usage for Spaces.
8+
2. **Multi-GPU Support**: Allows Spaces to leverage multiple GPUs concurrently on a single applications.
9+
10+
ZeroGPU achieves these goals by implementing an efficient GPU allocation system, dynamically assigning and releasing GPUs as needed. This contrasts with traditional GPU Spaces, which are limited to a single dedicated GPU.
11+
12+
## Using and hosting ZeroGPU Spaces
13+
14+
- **Using existing ZeroGPU Spaces**
15+
- ZeroGPU Spaces are available to use for free to all users. (Visit [the curated list](https://huggingface.co/spaces/enzostvs/zero-gpu-spaces)).
16+
- [PRO users](https://huggingface.co/subscribe/pro) get x5 more daily usage quota and highest priority in GPU queues when using any ZeroGPU Spaces.
17+
- **Hosting your own ZeroGPU Spaces**
18+
- Personal accounts: [Subscribe to PRO](https://huggingface.co/settings/billing/subscription) to access ZeroGPU in the hardware options when creating a new Gradio SDK Space.
19+
- Organizations: [Subscribe to the Enterprise Hub](https://huggingface.co/enterprise) to enable ZeroGPU Spaces for all organization members.
20+
21+
## Technical Specifications
22+
23+
- **GPU Type**: Nvidia A100
24+
- **Available VRAM**: 40GB per workload
25+
26+
## Compatibility
27+
28+
ZeroGPU Spaces are designed to be compatible with most PyTorch-based GPU Spaces. While compatibility is enhanced for high-level Hugging Face libraries like `transformers` and `diffusers`, users should be aware that:
29+
30+
- Currently, ZeroGPU Spaces are exclusively compatible with the **Gradio SDK**.
31+
- ZeroGPU Spaces may have limited compatibility compared to standard GPU Spaces.
32+
- Unexpected issues may arise in some scenarios.
33+
34+
### Supported Versions
35+
36+
- Gradio: 4+
37+
- PyTorch: 2.0.1, 2.1.2, 2.2.2, 2.4.0 (Note: 2.3.x is not supported due to a [PyTorch bug](https://github.com/pytorch/pytorch/issues/122085))
38+
- Python: 3.10.13
39+
40+
## Getting started with ZeroGPU
41+
42+
To utilize ZeroGPU in your Space, follow these steps:
43+
44+
1. Make sure the ZeroGPU hardware is selected in your Space settings.
45+
2. Import the `spaces` module.
46+
3. Decorate GPU-dependent functions with `@spaces.GPU`.
47+
48+
This decoration process allows the Space to request a GPU when the function is called and release it upon completion.
49+
50+
### Example Usage
51+
52+
```python
53+
import spaces
54+
from diffusers import DiffusionPipeline
55+
56+
pipe = DiffusionPipeline.from_pretrained(...)
57+
pipe.to('cuda')
58+
59+
@spaces.GPU
60+
def generate(prompt):
61+
return pipe(prompt).images
62+
63+
gr.Interface(
64+
fn=generate,
65+
inputs=gr.Text(),
66+
outputs=gr.Gallery(),
67+
).launch()
68+
```
69+
70+
Note: The `@spaces.GPU` decorator is designed to be effect-free in non-ZeroGPU environments, ensuring compatibility across different setups.
71+
72+
## Duration Management
73+
74+
For functions expected to exceed the default 60-second runtime, specify a custom duration:
75+
76+
```python
77+
@spaces.GPU(duration=120)
78+
def generate(prompt):
79+
return pipe(prompt).images
80+
```
81+
82+
This sets the maximum function runtime to 120 seconds. Specifying shorter durations for quicker functions can improve queue priority for Space visitors.
83+
84+
## Limitations
85+
86+
- **Personal accounts (PRO subscribers)**: Maximum of 10 ZeroGPU Spaces.
87+
- **Organization accounts (Enterprise Hub)**: Maximum of 50 ZeroGPU Spaces.
88+
89+
By leveraging ZeroGPU, developers can create more efficient and scalable Spaces, maximizing GPU utilization while minimizing costs.
90+
91+
## Feedback
92+
93+
You can share your feedback on Spaces ZeroGPU directly on the HF Hub: https://huggingface.co/spaces/zero-gpu-explorers/README/discussions

0 commit comments

Comments
 (0)