update duration for zero gpu
Browse files190 unmodified lines1911921931941941951961971981992002013 unmodified lines2052062072042082092102114 unmodified lines21621721821922022122222322422522622722822916 unmodified lines2462472482372492502512522532542552563 unmodified lines2602612622472632642652664 unmodified lines271272273274275276277278279280281282283284190 unmodified lines
1. Import the spaces module: `import spaces`2. Decorate GPU-dependent functions with `@spaces.GPU`3. For functions that may take longer than 60 seconds, specify duration: `@spaces.GPU(duration=120)`3. Specify appropriate duration based on expected runtime: - Quick inference (< 30s): `@spaces.GPU(duration=30)` - Standard generation (30-60s): `@spaces.GPU` (default 60s) - Complex generation (60-120s): `@spaces.GPU(duration=120)` - Heavy processing (120-180s): `@spaces.GPU(duration=180)`
Example usage:```python3 unmodified linespipe = DiffusionPipeline.from_pretrained(...)pipe.to('cuda')
@spaces.GPU@spaces.GPU(duration=120)def generate(prompt): return pipe(prompt).images
4 unmodified lines).launch()```
Duration Guidelines:- Shorter durations improve queue priority for users- Text-to-image: typically 30-60 seconds- Image-to-image: typically 20-40 seconds - Video generation: typically 60-180 seconds- Audio/music generation: typically 30-90 seconds- Model loading + inference: add 10-30s buffer
Functions that typically need @spaces.GPU:- Image generation (text-to-image, image-to-image)- Video generation16 unmodified lines
1. Import the spaces module: `import spaces`2. Decorate GPU-dependent functions with `@spaces.GPU`3. For functions that may take longer than 60 seconds, specify duration: `@spaces.GPU(duration=120)`3. Specify appropriate duration based on expected runtime: - Quick inference (< 30s): `@spaces.GPU(duration=30)` - Standard generation (30-60s): `@spaces.GPU` (default 60s) - Complex generation (60-120s): `@spaces.GPU(duration=120)` - Heavy processing (120-180s): `@spaces.GPU(duration=180)`
Example usage:```python3 unmodified linespipe = DiffusionPipeline.from_pretrained(...)pipe.to('cuda')
@spaces.GPU@spaces.GPU(duration=120)def generate(prompt): return pipe(prompt).images
4 unmodified lines).launch()```
Duration Guidelines:- Shorter durations improve queue priority for users- Text-to-image: typically 30-60 seconds- Image-to-image: typically 20-40 seconds - Video generation: typically 60-180 seconds- Audio/music generation: typically 30-90 seconds- Model loading + inference: add 10-30s buffer
Functions that typically need @spaces.GPU:- Image generation (text-to-image, image-to-image)- Video generationapp.py+28-4