Image Generation
This guide walks you through setting up and running image generation workloads on Vast.ai, a marketplace for renting GPU compute power. Whether you're using Stable Diffusion or other image generation models, this guide will help you get started efficiently.
- A Vast.ai account
- Basic familiarity with image generation models
- (Optional) Basic understanding of model management
Navigate to the Templates tab to view available templates. For image generation, we recommend searching for "SD Web UI Forge" among the recommended templates.
- Stable Diffusion Web UI Forge Template
- Pre-installed with:
- Latest SD Web UI version
- Popular extensions
- Common models
- Optimized settings for vast.ai
Choose this template if:
- You want a ready-to-use environment for image generation
- You need a user-friendly web interface
- You want access to multiple models and extensions
- You're looking for an optimized setup
Edit the template and add/update key environment variables if needed:
Important: Never save your template as public if you've included tokens in Docker Options or added your docker login password.
When selecting a GPU for image generation, consider:
- GPU Memory:
- Minimum 8GB for basic models
- 12GB+ recommended for larger models
- 24GB+ for advanced techniques (img2img, inpainting, etc.)
- GPU Type:
- RTX 3090, 4090 for best performance
- RTX 3080, 3080 Ti for good balance
- A4000, A5000 for stability
- Disk Space:
- Minimum 50GB for base models
- 100GB+ recommended for multiple models
- Consider SSD speed for model loading
The Forge template provides multiple ways to access your instance:
- AI-Dock Landing Page (Recommended):
- Click the "Open" button in Instances tab once the blue button says "Open" on your instance
- You'll be automatically logged in to the AI-Dock landing page
- Access Forge and other management tools from there
- Direct Access:
- Basic authentication is enabled by default
- Username: vastai
- Password: Check OPEN_BUTTON_TOKEN value
- To find token: echo $OPEN_BUTTON_TOKEN in terminal
- API Access:
- Security Setup:
- HTTPS and token authentication enabled by default
- Install TLS certificate to avoid browser warnings
- Configure via WEB_ENABLE_HTTPS and WEB_ENABLE_AUTH variables
- Jupyter Access for Uploading/Downloading:
- You can access jupyter clicking on the jupyter button on the instance card to easily upload and download files
The template includes a default provisioning script that downloads:
- Base Stable Diffusion XL models
- Popular extensions
- Common configurations
Create your own setup by:
- Copy the default provisioning script by editing the SD Web UI Forge template and grabbing the value of PROVISIONING_SCRIPT environment variable and downloading it
- Modify it to download your preferred:
- Models
- Extensions
- Configurations
- Upload to Gist/Pastebin
- Edit the template and set PROVISIONING_SCRIPT environment variable to the raw URL
Example for adding more models:
Keep your models organized:
You can access jupyter clicking on the jupyter button on the instance card to easily upload and download files.
Access Settings > Performance in Web UI:
- Enable xformers memory efficient attention
- Use float16 precision when possible
- Optimize VRAM usage based on your GPU
For multiple images:
- Use batch count for variations
- Use batch size for parallel processing
- Monitor GPU memory usage
Place custom scripts in:
Popular extensions are pre-installed. Add more via Web UI:
- Extensions tab
- Install from URL
- Restart UI to apply
Enable API in settings:
- Out of Memory (OOM)
- Reduce batch size
- Lower resolution
- Enable optimization settings
- Slow Generation
- Check GPU utilization
- Verify model loading
- Consider switching to half precision
- Connection Issues
- Use --listen flag for network access
- Check instance status
- Verify network settings
- Save prompts for reuse
- Use version control for custom scripts
- Document model combinations
- Monitor costs in Billing tab
- Use appropriate batch sizes
- Clean up unused models
- Maintain prompt libraries
- Document successful settings
- Track model performance
- Compare GPU prices
- Consider spot instances
- Monitor usage patterns
- Remove unused models
- Archive generated images
- Use efficient formats
Running image generation workloads on Vast.ai provides a cost-effective way to access powerful GPUs. By following this guide and best practices, you can efficiently set up and manage your image generation pipeline while optimizing costs and performance.