DEV Community

gladevise
gladevise

Posted on

Building a Stable Diffusion WebUI environment with RunPod

As Google Colab has restricted the execution of Stable Diffusion in the free tier, we introduce RunPod as an alternative cloud resource.

What you need:

  • $10
  • RunPod account
  • Backblaze account

First, visit RunPod and Backblaze to create accounts.

Paying the fee

RunPod requires a prepayment, so you will need to pay a minimum of $10 upfront.

SetCreditAmount

You will be redirected to the Stripe page, where you can enter your credit card information.

SetCreditCardInfo

If your payment is successful, the following screen will be displayed.

SuccessPayment

Building a Stable Diffusion environment

We will build a Stable Diffusion environment with RunPod.

Go to the Secure Cloud and select the resources you want to use. In this case, we will choose the cheapest option, the RTX A4000.

SelectResource

From the existing templates, select RunPod Fast Stable Diffusion.

SelectFastStableDiffusion

Once the confirmation screen is displayed, click Deploy.

ConfirmDeploy

Click My Pods and check the deployed Pod.

GoToMyPods

After confirming that the CPU usage has decreased, click Connect and then Connect to Jupyter Lab.

ConnectToJupyterLab

Open the RNPD-A1111.ipynb file.

OpenRNPD-A1111.ipynb

Once the notebook is open, execute the cells in order from Dependencies, Install/Update AUTOMATIC1111 repo, Model Download/Load, ControlNet, to Start Stable-Diffusion.

When you run Start Stable-Diffusion, a URL like Running on local URL: https://foobar-3000.proxy.runpod.net will be displayed, so access it.

StableDiffusionOnRunPod

Enjoy generating images within the limits of your credit with the familiar interface.

To stop, click Stop in My Pods.

StopPod

A confirmation screen will appear, so click Stop Pod.

ConfirmStopPod

As mentioned on the confirmation screen, RunPod will continue to charge you until the storage you are using is released, even after stopping the Pod. In the example above, $0.014 will be deducted per hour.

The only way to stop this is to click Terminate to completely delete the Pod.

TerminatePod

Saving RunPod data with Backblaze

As it stands, the generated images will be lost, so we will save them to Backblaze.

Go to Backblaze and click Create a Bucket from Buckets.

CreateBucket

Enter the Bucket Unique Name and click Create a Bucket.

SetBucketProperties

Next, go to Application Keys.

GoToApplicationKeys

Click Add a New Application Key to issue a new key.

AddNewApplicationKey

Enter the key name and specify the bucket you set earlier.

SetApplicationKeyProperties

Take note of the keyID and keyName displayed here.

Return to RunPod and click CloudSync.

ClickCloudSync

When the cloud storage selection screen appears, click Backblaze B2.

SelectBackblazeB2

Click Copy to Backblaze B2.

CopyToBackblazeB2

Enter the keyID and keyName you noted earlier as follows:

Account ID: keyID displayed when generating the key in Backblaze
Application Key: keyName displayed when generating the key in Backblaze
Bucket Path: {bucket} is the bucketName, {folder} is an appropriate name. ex: RunPodCloudSyncSDWebUI/fast-stable-diffusion
Pod Path: /workspace
Enter fullscreen mode Exit fullscreen mode

SetCloudSyncPropertiesTo

This will save the output results and properties of Stable Diffusion to Backblaze B2.

Once the upload is complete, you can check the specified folder in Backblaze's Browse Files to see that the files have been saved.

BrowseFiles

Now, even if you terminate the Pod, the generated images will not be lost. When launching the next Pod, click Copy from Backblaze B2 to copy files from Backblaze B2, allowing you to continue generating images from where you left off.

Conclusion

  • If you frequently generate images with Stable Diffusion, Google Colab Pro is more cost-effective.
  • If you only generate images occasionally with Stable Diffusion, RunPod's pay-as-you-go flexibility may be better.
  • If you temporarily need more specs than those provided by Google Colab, such as for model training, RunPod is more suitable.

Top comments (0)