Civitai: The Home of Open-Source Generative AI
“Our mission is rooted in the belief that AI resources should be accessible to all, not monopolized by a few” – Justin Maier, Founder & CEO of Civitai.
With an average of 26 million visits per month, 10 million users & more than 200,000 open-source models & embeddings, Civitai is definitely fulfilling their mission of making AI accessible to all.
Launched in November 2022, Civitai is one of the largest generative AI communities in the world today, helping users discover, create & share open-source, AI-generated media content easily. In Sep 2023, Civitai launched their Image Generator, a web-based interface for Stable Diffusion & one of the most used products on the platform today. This product allows users to input text prompts and receive image outputs. All the processing is handled by Civitai, requiring hundreds of Stable Diffusion appropriate GPUs on the cloud.
Civitai’s challenge: Growing compute at scale without breaking the bank
Civitai’s explosive growth, focus on GPU-hungry AI-generated media & the new image generator brought about big infrastructure challenges:
- How can you access hundreds of GPUs in the middle of a global GPU shortage?
- How do we manage hundreds of GPUs to account for the fluctuations in demand?
- How to cost-effectively handle millions of unique model combinations & users?
Continuing with their current infrastructure provider and high-end GPUs would mean an exorbitant cloud bill, not to mention the scarcity of high-end GPUs.
Democratized AI-media creation meets democratized computing on SaladCloud
To solve these challenges, Civitai partnered with Salad, a distributed cloud for AI/ML inference at scale.
Like Civitai, Salad’s mission also lies in democratization – of cloud computing. SaladCloud is a fully people-powered cloud with 1 Million+ contributors on the network and 10K+ GPUs at any time. With over 100 Million consumer GPUs in the world lying unused for 18-22 hrs a day, Salad is on a mission to activate the largest pool of compute in the world for the lowest cost. Every day, thousands of voluntary contributors securely share compute resources with businesses like Civitai in exchange for rewards & gift cards.
“For the past few months, Civitai has been at the forefront of Salad’s ambitious project, utilizing Salad’s distributed network of GPUs to power our on-site image generator. This partnership is more than just a technical alliance; it’s a testament to what we can achieve when we harness the power of community, democratization, and shared goals”, says Chris Adler, Head of Partnerships at Civitai. Civitai’s partnership with Salad helped manage the scale & cost of their inference while supporting millions of users and model combinations on Salad’s unique distributed infrastructure.
Scaling to hundreds of affordable GPUs on SaladCloud
Running stable diffusion at scale requires access to and effective management of hundreds of GPUs, especially in the midst of a GPU shortage. Also important is understanding the desired throughput to determine capacity needs and estimated operating costs for any infrastructure provider.
As discussed in this blog, expensive, high-end GPUs like the A100 & H100 are perfect for training but when serving AI inference at scale for use cases like text-to-image, the cost-economics break down. You get better cost-performance on consumer-grade GPUs, generating 4X-8X more images per dollar compared to AI-focused GPUs. With SaladCloud’s network of thousands of Stable Diffusion compatible consumer GPUs, Civitai had access to the most cost-effective GPUs, ready to keep up with the demands of its growing user base.
Managing Hundreds of GPUs
As Civitai’s Stable Diffusion deployment scaled, manually managing each individual instance wasn’t an option. Salad’s Solutions Team worked with Civitai to design an automated approach that can respond to changes in GPU demand and reduce the risk of human error.
By leveraging our fully-managed container service, Civitai ensures that each and every instance of their application will run and perform consistently, providing a reliable, repeatable, and scalable environment for their production workloads. When demand changes, Civitai can simply scale up or down the number of replicas using the portal or our public API, further automating the deployment.
Using SaladCloud’s public API, Civitai monitors model usage and analyzes the queues, customizing their auto scaling rules to optimize both performance and cost.
Supporting Millions of unique model combinations on SaladCloud at low cost
Civitai’s image generation product supports millions of unique combinations of checkpoints, Low-Rank Adaptations (LoRAs), Variational Autoencoders (VAEs), and Textual Inversions. Users often combine these into a single image generation request.
In order to efficiently manage these models on SaladCloud, Civitai combines a robust set of APIs and business logic with a custom container designed to respond dynamically to the image generation demands of their community.
At its core, the Civitai image generation product is built around connecting queues with a custom Stable Diffusion container on SaladCloud. This allows the system to gracefully handle surges in image generation requests and millions of unique combinations of models.
Each container includes a Python Worker that communicates with Civitai’s Orchestrator. The Worker application is responsible for downloading models, automating image generation with a sequence of calls to a custom image generation pipeline, and uploading resulting images back to Civitai.
By building a generic application that is controlled by the Civitai Orchestrator, the overall system automatically responds to the latest trending models and eliminates the need to manually deploy individual models.
If an image generation request is received for a combination of models that are already loaded on one or more nodes, the worker will process that request as soon as the GPU is available. If the request is for a combination of models that are not currently loaded into a worker, the job is queued up until the models are downloaded and loaded, then the job is processed.
Civitai & Salad – A perfect match for democratizing AI
With this specific workflow built on SaladCloud, Civitai is able to always leverage the best GPU combinations and lowest prices while ensuring their infrastructure scales up/down with incoming requests. Being able to serve these requests on low-cost consumer GPUs on SaladCloud helps Civitai continue making AI-generated media accessible to all.
Reinforcing this partnership, Civitai users can now sign up on www.salad.com to share their unused GPU compute to power Civitai. In exchange, users get compensated in Buzz, Civitai’s on-site currency. This also opens up access to Civitai for Salad’s current users, offering an exchange of Salad balance to Buzz.
You can read more about Civitai’s Buzz on Salad’s storefront here.
With 4 Million+ registered users on Civitai and 1 Million+ on Salad signing up to share compute, both Civitai and Salad owe their very existence to our respective communities. Adding Buzz to Salad is our way of ensuring that your contributions are recognized and rewarded.