Skip to main content
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.

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:
1

Create a Hugging Face account

Sign up for free at huggingface.co
2

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
3

Access your app

Your app will be live at:

Deployment methods

The fastest way to deploy:
You’ll be prompted for:
  • Space name
  • Whether to set up GitHub Actions (for auto-updates)
  • Hardware tier (CPU or GPU)

Update an existing Space

Simply run gradio deploy again in the same directory:

Enable GitHub Actions

Automate deployments on every git push:
This creates a GitHub Actions workflow that deploys to Spaces automatically.

Method 2: Web interface

Deploy via drag-and-drop:
1

Create a new Space

2

Choose settings

  • Pick a name
  • Select “Gradio” as the SDK
  • Choose hardware (CPU or GPU)
3

Upload files

Drag and drop your app folder, or clone via Git

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:

Change hardware via UI

  1. Go to your Space settings
  2. Click “Hardware”
  3. Select new tier
  4. Click “Update hardware”

Change hardware via CLI

Sleep timeout

GPU Spaces automatically sleep after inactivity:

Environment variables and secrets

Add secrets via UI

  1. Go to Space settings
  2. Click “Variables and secrets”
  3. Add name and value
  4. Click “Save”

Add secrets via CLI

Use secrets in code

Never commit secrets to your repository! Always use environment variables.

Duplicate Spaces programmatically

Create private copies of Spaces for unlimited API usage:
Benefits:
  • No rate limits
  • Guaranteed availability
  • Custom hardware
  • Private usage

Custom domains

Pro users can add custom domains:
  1. Go to Space settings
  2. Click “Domains”
  3. Add your domain (e.g., demo.mycompany.com)
  4. Update DNS records as shown
  5. 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:
  1. Click “Logs” tab
  2. See real-time output
  3. Filter by level (info, error, etc.)

Access logs programmatically

Add custom logging

Private Spaces

Restrict access to your Space:

Make Space private

  1. Go to Space settings
  2. Click “Visibility”
  3. Select “Private”
  4. Save

Access private Spaces

Best practices

1

Use .gitignore

Don’t upload unnecessary files:
2

Pin dependencies

Specify exact versions in requirements.txt:
3

Add examples

Help users get started:
4

Set up error handling

Gracefully handle failures:
5

Optimize for cold starts

Load models outside the function:

Troubleshooting

Space won’t start

  • Check logs for errors
  • Verify requirements.txt dependencies
  • Ensure app.py runs 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