Skip to content

Commit b6a862d

Browse files
authored
[ZeroGPU] Dynamic duration + compilation + updates (#1896)
1 parent fd73397 commit b6a862d

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

docs/hub/spaces-zerogpu.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,24 @@ ZeroGPU Spaces are designed to be compatible with most PyTorch-based GPU Spaces.
3333

3434
### Supported Versions
3535

36-
- Gradio: 4+
37-
- PyTorch: 2.1.2, 2.2.2, 2.4.0, 2.5.1 (Note: 2.3.x is not supported due to a [PyTorch bug](https://github.com/pytorch/pytorch/issues/122085))
38-
- Python: 3.10.13
36+
- **Gradio**: 4+
37+
- **PyTorch**: Almost all versions from **2.1.0** to **latest** are supported
38+
<details>
39+
<summary>See full list</summary>
40+
41+
- 2.1.0
42+
- 2.1.1
43+
- 2.1.2
44+
- 2.2.0
45+
- 2.2.2
46+
- 2.4.0
47+
- 2.5.1
48+
- 2.6.0
49+
- 2.7.1
50+
- 2.8.0
51+
52+
</details>
53+
- **Python**: 3.10.13
3954

4055
## Getting started with ZeroGPU
4156

@@ -81,6 +96,29 @@ def generate(prompt):
8196

8297
This sets the maximum function runtime to 120 seconds. Specifying shorter durations for quicker functions will improve queue priority for Space visitors.
8398

99+
### Dynamic duration
100+
101+
`@spaces.GPU` also supports dynamic durations.
102+
103+
Instead of directly passing a duration, simply pass a callable that takes the same inputs as your decorated function and returns a duration value:
104+
105+
```python
106+
def get_duration(prompt, steps):
107+
step_duration = 3.75
108+
return steps * step_duration
109+
110+
@spaces.GPU(duration=get_duration)
111+
def generate(prompt, steps):
112+
return pipe(prompt, num_inference_steps=steps).images
113+
```
114+
115+
116+
## Compilation
117+
118+
ZeroGPU does not support `torch.compile`, but you can use PyTorch **ahead-of-time** compilation (requires torch `2.8+`)
119+
120+
Check out this [blogpost](https://huggingface.co/blog/zerogpu-aoti) for a complete guide on ahead-of-time compilation on ZeroGPU.
121+
84122
## Hosting Limitations
85123

86124
- **Personal accounts ([PRO subscribers](https://huggingface.co/subscribe/pro))**: Maximum of 10 ZeroGPU Spaces.

0 commit comments

Comments
 (0)