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)
- 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.
If you are a site member, log in and access the notebook below.
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.
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 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 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
Hey Andrew! Really loving the notebook and thank you so much for putting it together for us! I’ve run into a situation where my NGROK “account has exceeded its http requests limit” and need to upgrade to their paid plan which is very much not ideal for me.. and the local tunnel gives me such an insane amount of problems to use that it stops becoming worth it.
Are there any other alternatives other than NGROK or the local tunnel??
I will look into it but it won’t be a priority.
hi Andrew,
Why is it’s not possible to download models to a folder in google drive, so that they don’t have to be downloaded each time?
Ah sorry, already works like that.
They actually won’t be saved in google drive by design. Some models are large and saving them in google drive may cause out of space error.
You can put them in google drive manually if you want to so that you don’t need to redownload.
Ah thank you Andrew.
hi Andrew,
cannot use upscalers on comfyui colab
i understand that there should be a folder
AI_PICS>models>upscale_models
so i created one manually
but i get for example:
“Value not in list: model_name: ‘RealESRGAN_x2.pth’ not in []”
comfyui does not seem to read the content of that folder….. and the upscalers i put there….
thank you
🙂
nami
Put the upscaler models in ESRGAN folder. The models folder is shared between A1111, Forge, and comfyui.
The local tunnel is giving me an OBSCENE amount of issues…. I know you mentioned copy/pasting the authoken from ngrok in the “NGROK field in the notebook”, but the Colab Notebook I picked up from your GumRoad doesn’t have an ngrok field in it
It’s pointing to the latest notebook but you will need to follow the link in the guide to retrieve the latest one.
Hi Andrew, thank you for improving this workbook. with every update, it’s getting better and better. there are 2 things I would like to ask:
1) Loras – is there any limitation (size) on the Loras? I can select almost all Loras I uploaded to google drive, but some are not visible… for example Flux turbo lora (which has 600mb+) is not visible for selection in comfyui environment
2) xlab controlnets – is there any way to use these? normally they are stored in xlab directory in Comfyui models folder in my local installation.
thanks for great works
regards
Pavel
1. The size of loras shouldn’t matter. Do you have an example I can test?
2. Just added the xlabs folder in google drive.
Hi Andrew, it seems the lora was corrupted. uploaded it again and it works now
Hello Andrew, getting this error when I try to use FLUX. CheckpointLoaderSimple
Error while deserializing header: HeaderTooLarge
any idea how to fix it, please?
The problem should be fixed now. I also added a section in FAQ for using the flux model.
thank you Andrew. it works now. BTW is there a way to instal custom nodes? or this is just for basic workflow with built-in nodes?
You can install them through the comfyui manager. I just added a Custom nodes section in the post.
Hi Andrew, I was trying to instal impact-pack through manager, but it didn’t work due to security level. can the security level can be somehow changed when starting comfyui or could you add comyui impact pack installation into the workbook, please?
OK, I found the issue. This custom node doesn’t like to be in google drive. Please use the updated notebook (11/2) and don’t select “SAVE_CUSTOM_NODES_IN_GOOGLE_DRIVE” (default).
I earlier used your stable diffusion colab link and I could add loras by copy them to my lora folder. Now bo lora is shown, tried even to copy loras link for flux loras into the colab notebook before I run it but no luck… should I try to delete the whole folder AI_pics and try again?
I just tested the comfyui notebook. The loras in google drive is loading correctly.
Note that there’s a change in the lora folder location. The model folder structure now mirrors A1111’s. So AI_PICS > models > Lora.
You can rename the AI_PICS folder in google drive to AI_PICS_OLD. A new folder with model folder structure will be regenerated.
Ok! Thank you!
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.
it is working but the connection is unstable. I will add another connection option when I got a chance. In the meantime, it can be resolved by refreshing the page.