Hugging Face Spaces make it easy for you to create and deploy ML-powered demos in minutes. Watch the following video for a quick introduction to Spaces:
In the following sections, you’ll learn the basics of creating a Space, configuring it, and deploying your code to it.
To make a new Space, visit the Spaces main page and click on Create new Space. Along with choosing a name for your Space, selecting an optional license, and setting your Space’s visibility, you’ll be prompted to choose the SDK for your Space. The Hub offers four SDK options: Gradio, Streamlit, Docker and static HTML. If you select “Gradio” as your SDK, you’ll be navigated to a new repo showing the following page:
Under the hood, Spaces stores your code inside a git repository, just like the model and dataset repositories. Thanks to this, the same tools we use for all the other repositories on the Hub (git
and git-lfs
) also work for Spaces. Follow the same flow as in Getting Started with Repositories to add files to your Space. Each time a new commit is pushed, the Space will automatically rebuild and restart.
For step-by-step tutorials to creating your first Space, see the guides below:
Each Spaces environment is limited to 16GB RAM, 2 CPU cores and 50Gb of (not persistent) disk space by default, which you can use free of charge. You can upgrade to better hardware, including a variety of GPU accelerators, for a competitive price. To request an upgrade, please click the Settings button in your Space and select your preferred hardware environment.
Hardware | CPU | Memory | Disk | Hourly Price |
---|---|---|---|---|
CPU Basic | 2 vCPU | 16 GB | 50 GB | Free! |
CPU Upgrade | 8 vCPU | 32 GB | 50 GB | $0.03 |
Nvidia T4 - small | 4 vCPU | 15 GB | 50 GB | $0.06 |
Nvidia T4 - medium | 8 vCPU | 30 GB | 100 GB | $0.09 |
Nvidia A10G - small | 4 vCPU | 15 GB | 110 GB | $1.05 |
Nvidia A10G - large | 12 vCPU | 46 GB | 200 GB | $3.15 |
Nvidia A100 - large | 12 vCPU | 142 GB | 1000 GB | $4.13 |
You can also request a community GPU grant if you are building something cool as a side project. Drop us a note using the link in the Settings tab of your Space!
Read more in Spaces GPU Upgrades.
If your app requires secret keys or tokens, don’t hard-code them inside your app! Instead, go to the Settings page of your Space repository and enter your secrets there. The secrets will be exposed to your app with Streamlit Secrets Management if you use Streamlit, and as environment variables in other cases. For Docker Spaces, please check out secret management with Docker.
If your Space needs to make any network requests, you can make requests through the standard HTTP and HTTPS ports (80 and 443) along with port 8080. Any requests going to other ports will be blocked.
In some cases, you might be interested in having programmatic access to the Space author or repository name. This feature is particularly useful when you expect users to duplicate your Space. To help with this, Spaces exposes different environment variables at runtime. Given a Space osanseviero/i-like-flan
:
SPACE_AUTHOR_NAME
: osansevieroSPACE_REPO_NAME
: i-like-flanSPACE_TITLE
: I Like Flan (specified in the README file)SPACE_ID
: osanseviero/i-like-flan