Hugging Face Spaces provides free infrastructure to permanently host your Gradio apps. Deploy in minutes using the CLI or web interface, with support for GPU hardware, secrets management, and automatic updates.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/gradio-app/gradio/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Hugging Face Spaces offers:- Free hosting: Permanent URLs for your demos
- No cold starts: Apps stay warm and responsive
- GPU support: Access to various GPU options
- Easy deployment: CLI or web-based upload
- Automatic updates: Sync with GitHub for CI/CD
- Secrets management: Secure environment variables
- Community: Discover and share demos
Quick start
Deploy your Gradio app in under 2 minutes:Create a Hugging Face account
Sign up for free at huggingface.co
Deploy from terminal
Run this command in your app directory:The CLI will:
- Ask for your Space name
- Upload all files (respecting
.gitignore) - Launch your app on Spaces
Deployment methods
Method 1: CLI deployment (recommended)
The fastest way to deploy:- Space name
- Whether to set up GitHub Actions (for auto-updates)
- Hardware tier (CPU or GPU)
Update an existing Space
Simply rungradio deploy again in the same directory:
Enable GitHub Actions
Automate deployments on everygit push:
Method 2: Web interface
Deploy via drag-and-drop:Create a new Space
Go to huggingface.co/new-space
Method 3: Git workflow
For version control and collaboration:App structure
A typical Gradio Space contains:Example app.py
Example requirements.txt
README.md metadata
Configure your Space with YAML frontmatter:Hardware options
CPU (free)
Default tier, suitable for:- Text processing
- Simple data analysis
- Lightweight models
- Educational demos
GPU (paid)
For compute-intensive tasks:| Hardware | vCPU | RAM | GPU VRAM | Price/hour |
|---|---|---|---|---|
| T4 Small | 4 | 15 GB | 16 GB | $0.60 |
| T4 Medium | 8 | 30 GB | 16 GB | $0.90 |
| A10G Small | 4 | 15 GB | 24 GB | $1.05 |
| A10G Large | 12 | 46 GB | 24 GB | $3.15 |
| A100 Large | 12 | 142 GB | 40 GB | $4.13 |
Change hardware via UI
- Go to your Space settings
- Click “Hardware”
- Select new tier
- Click “Update hardware”
Change hardware via CLI
Sleep timeout
GPU Spaces automatically sleep after inactivity:Environment variables and secrets
Add secrets via UI
- Go to Space settings
- Click “Variables and secrets”
- Add name and value
- Click “Save”
Add secrets via CLI
Use secrets in code
Duplicate Spaces programmatically
Create private copies of Spaces for unlimited API usage:- No rate limits
- Guaranteed availability
- Custom hardware
- Private usage
Custom domains
Pro users can add custom domains:- Go to Space settings
- Click “Domains”
- Add your domain (e.g.,
demo.mycompany.com) - Update DNS records as shown
- Wait for verification
Persistent storage
Spaces are stateless by default. For persistent data:Use Hugging Face Datasets
Use Spaces persistent storage (Pro)
For Pro subscribers:Monitoring and logs
View logs
In your Space page:- Click “Logs” tab
- See real-time output
- Filter by level (info, error, etc.)
Access logs programmatically
Add custom logging
Private Spaces
Restrict access to your Space:Make Space private
- Go to Space settings
- Click “Visibility”
- Select “Private”
- Save
Access private Spaces
Best practices
Troubleshooting
Space won’t start
- Check logs for errors
- Verify
requirements.txtdependencies - Ensure
app.pyruns locally - Check Python version compatibility
Out of memory
- Upgrade to higher RAM tier
- Reduce model size
- Use model quantization
- Clear unused variables
Slow performance
- Upgrade to GPU hardware
- Cache model outputs
- Optimize data preprocessing
- Use batch processing
Next steps
Docker deployment
Deploy Gradio apps with Docker
Sharing apps
Learn about authentication and embedding