- Published on
How to run ComfyUI on Google Colab
- Authors
- Name
- F4AI
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.
Table of Contents
- What is ComfyUI?
- Using ComfyUI on Google Colab
- Alternatives
- Running ComfyUI on Colab
- Faster connection with ngrok (Optional)
- Input and Output folders
- Speeding up image generation
- When you are done
- Computing resources and compute units
- Models available
- ControlNet models
- Installing models
- Notebook secrets
- Custom nodes
- Extra arguments to ComfyUI
- Frequently asked questions
- Next Step
What is ComfyUI?
This is a detailed guide for ComfyUI on Google Colab. You can access the notebook by getting the Quick Start Guide.
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.
Faster connection with ngrok (Optional)
If you run into connection issues with ComfyUI, you can try using ngrok instead of local tunnel to establish the public connection. It is a more stable alternative.
You will need to set up a free account and get an authoken.
- Go to https://ngrok.com/
- Create an account
- Verify email
- Copy the authoken from https://dashboard.ngrok.com/get-started/your-authtoken and paste it into the NGROK field in the notebook.
Input and Output folders
The default input folder is AI_PICS > inputs in your Google Drive.
The default output folder is AI_PICS > outputs in your Google Drive.
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
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 |
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. |
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
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.
- SD_1_5_ControlNet_models: SD 1.5 ControlNet models.
- SDXL_ControlNet_models: SDXL ControlNet models.
- IP_Adapter_models: IP adapter models.
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.
- Use ComfyUI Manager.
- 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.
Notebook secrets
This notebook supports storing API keys in addition to Secrets. If the keys were defined in secrets, the notebook would always use them. The notebook currently supports these two API keys (All upper cases):
NGROK
: Ngrok API key.
You will need to enable Notebook access for each key like above.
Custom nodes
Installing a custom node
You can use ComfyUI Manager to install custom nodes. Click Manager > Install custom nodes.
Search and select a custom node to install.
Click the Restart button AND refresh the ComfyUI page after installation.
The custom nodes are stored in your Google Drive: AI_PICS > ComfyUI > custom_nodes.
Removing a custom node
Delete the custom node’s folder in AI_PICS > ComfyUI > custom_nodes to remove a custom node.
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.
How do I use the Flux.1 Dev model?
- Select the Flux1_dev under models.
- Use the workflow JSON File in the tutorial: Flux1 Dev FP8 workflow.
How long does it take to generate a Flux image?
It depends on the runtime type. Using the Flux1 Dev FP8 model:
- T4: 2 mins.
- L4: 50 secs.
Select Runtime > Change runtime type to change.
Next Step
- Absolute Beginner’s Guide: Read this if you have no idea about Stable Diffusion or Flux AI.
- ComfyUI Beginner’s Guide
- Stable Diffusion Courses