How to run ComfyUI on Google Colab

Published Categorized as Tutorial Tagged , , 1 Comment on How to run ComfyUI on Google Colab

ComfyUI is a popular way to run local Stable Diffusion and Flux AI image models. It is a great complement to AUTOMATIC1111 and Forge. Some workflows may require a good GPU to run.

In this article, you will find instructions on how to run ComfyUI on Google Colab using the notebook I maintain.

What is ComfyUI?

This is a detailed guide for ComfyUI on Google Colab. You can access the notebook by getting the Quick Start Guide.

If you are a site member, log in and access the notebook below.

Become a member of this site to see this content

Already a member? Log in here.

This notebook shares models with the following notebooks in Google Drive.

Using ComfyUI on Google Colab

Google Colab (Google Colaboratory) is an interactive computing service offered by Google. It is a Jupyter Notebook environment that allows you to execute code.

Due to the computing resources required (High RAM), you need a Google Pro and Pro+ to run ComfyUI on Colab.

I recommend using the Colab Pro plan. It gives you 100 compute units per month on T4, which are about 50 hours on a standard GPU. (It’s a steal)

Alternatives

Think Diffusion provides fully managedComfyUI/AUTOMATIC1111/Forge online service. They cost a bit more than Colab but provide a better user experience by installing models and extensions. They offer 20% extra credit to our readers. (Affiliate link)

Running ComfyUI on Colab

Step 0: Sign up

Sign up a Google Colab Pro or Pro+ plans. (I use Pro.)

Step 1: Open the ComfyUI Colab notebook

Open the ComfyUI Colab notebook in the Quick Start Guide. You should see the notebook with the second cell below.

Note: For quick start, you can skip the following steps and run the notebook with the default settings.

Step 2: Select models

Review which models you want to use.

The more you select, the longer it takes to download. They will be downloaded to the Colab drive, not your Google Drive.

Step 3: Run the notebook

Click the Play button on the left of the cell to start.

The notebook will ask for permission to access your Google Drive. Grant permission as it is necessary to save the images and access the models in your Google Drive.

The start-up should be completed within a few minutes. The time depends on how many models you include. When it is done, you should see the message below.

Step 4: Start ComfyUI

Visit the URL to access ComfyUI. You will need the Tunnel Password listed above the link.

Step 5: Generate an image

Select the DreamShaper_8 model.

Click Queue Prompt on the right sidebar.

Speeding up image generation

You can pick a faster runtime type to speed up the generation, which costs more per hour.

Click downward caret on the top right and then select Change runtime type.

When you are done

When you finish using the notebook, don’t forget to click “Disconnect and delete runtime” in the top right drop-down menu. Otherwise, you will continue to consume compute credits.

Computing resources and compute units

Computing units and usage rate.

To view computing resources and credits, click the downward caret next to the runtime type (E.g. T4, High RAM) on the top right. You will see the remaining compute units and usage rate.

Models available

For your convenience, the notebook has options to load some popular models. You will find a brief description of them in this section.

Flux models

Flux AI is a state-of-the-art AI model that produces stunning images.

v1.5 models

Stable Diffusion 1.5

The Stable Diffusion 1.5 model is the officially released model which is trained with diverse styles.

Realistic Vision

Realistic Vision v2 is suitable for generating anything realistic, whether they are people, objects, or scenes.

Dreamshaper

Dreamshaper

Model Page

Dreamshaper is easy to use and good at generating a popular photorealistic illustration style. It is an easy way to “cheat” and get good images without a good prompt!

Anything v3

Anything v3 model.

Model Page

Anything V3 is a special-purpose model trained to produce high-quality anime-style images. You can use danbooru tags (like 1girl, white hair) in the text prompt.

It’s useful for casting celebrities to amine style, which can then be blended seamlessly with illustrative elements.

SDXL 1.0 model

SDXL

This Coalb notebook supports the SDXL 1.0 base model.

Select SDXL_1 to load the SDXL 1.0 model.

Check out some SDXL prompts to get started.

JuggernautXL

The Juggernaut XL model is all-rounded for diverse styles. It is especially good at realistic images.

Pony Diffusion XL

The Pony Diffusion XL model excels in creative artistic images. See also the prompt tags for Pony XL.

ControlNet models

You need the ControlNet models to use the ControlNet custom node.

Alternatively, you can put the ControlNet models in the Google Drive folder AI_PICS > models > ControlNet.

Installing models

There are two ways to install models not on the model selection list.

  1. Use ComfyUI Manager.
  2. Put model files in your Google Drive.

Install models using ComfyUI Manager

Click the Manager button > Model Manager.

Use the filter to narrow down the model type.

Installing models in Google Drive

After running the notebook for the first time, you should see the folder AI_PICS > models created in your Google Drive. The folder structure inside this folder mirrors AUTOMATIC1111‘s and is designed to share models with:

Put your model files in the corresponding folder. For example,

  • Put checkpoint model files in AI_PICS > models > Stable-diffusion.
  • Put LoRA model files in AI_PICS > models > Lora.

You will need to restart the notebook to see the new models.

Extra arguments to ComfyUI

You can add any extra command line arguments to the Extra_arguments field.

Frequently asked questions

Do I need a paid account to use the notebook?

Yes, you need a paid Google Colab account to use this notebook. Google has blocked the free usage of Stable Diffusion.

Is there any alternative to Google Colab?

Think Diffusion provides fully-managed Forge/AUTOMATIC1111/ComfyUI WebUI web service. They offer 20% extra credit to our readers. (Affiliate link)

How do you resolve an out-of-memory error?

The T4 runtime type has 15 GB of VRAM. You can select a runtime type of higher memory, such as L4 or A100. (They cost more.)

Can I use the checkpoint and LoRA models I trained?

Yes, put the model file in the corresponding folder in Google Drive.

  • Checkpoint models: AI_PICS > models > Stable-diffusion.
  • LoRA models: AI_PICS > models > Lora.

Next Step

Avatar

By Andrew

Andrew is an experienced engineer with a specialization in Machine Learning and Artificial Intelligence. He is passionate about programming, art, photography, and education. He has a Ph.D. in engineering.

1 comment

  1. I’m having trouble getting this to work! 🙂 It did run fine for me the first time I tried, but now, not so much.
    The code in the notebook runs fine, no errors that I can find. When I click on the link for the local tunnel I get the login page, then I get either a blank white screen, or I get the ComfyUI page but the potion where the graph goes just spins and spins. Also, the ComfyUI manager does not get loaded (though it did the first time I ran everything). If I try to reload the page I get “Error loading workflows: Error getting user data list ‘workflows’: 502”

    I’m running it on Google Collab with this notebook: and using all the defaults set in the notebook.

Leave a comment

Your email address will not be published. Required fields are marked *