Run ComfyUI in Google Colab with optional Google Drive persistence, one-click model downloads, and public access via Cloudflare Tunnel or Localtunnel.
- Mount or unmount Google Drive to persist your ComfyUI workspace
- Clone and optionally update the upstream ComfyUI repository
- Download models from Civitai or Hugging Face with fast aria2
- Optional custom nodes installation (examples included, commented)
- Start ComfyUI and expose it publicly via:
- Cloudflare Tunnel (trycloudflare)
- Localtunnel (fallback)
- Click the Colab badge above to open
ComfyUIonColab.ipynb. - In the first cell, set
MODEtoMOUNTand run to mount Google Drive (recommended for persistence). - (Optional) Set
DRIVE_PATHin the Setup cell, e.g./content/drive/MyDrive. If set, the workspace will be created at<DRIVE_PATH>/ComfyUIand will persist across sessions. If left empty, the workspace is/content/ComfyUI(ephemeral). - Run the Setup cell to clone/update ComfyUI and install dependencies.
- Use the Models section to download checkpoints and VAEs into
./models/checkpointsand./models/vae. - Start ComfyUI:
- Cloudflare Tunnel cell prints a public URL ending with
trycloudflare.comonce port 8188 is ready - Or use the Localtunnel cell as an alternative
- Cloudflare Tunnel cell prints a public URL ending with
- Mount/Unmount Google Drive
MODE = "MOUNT" | "UNMOUNT"mounts to/content/driveand cleans up when unmounting
- Setup and Update ComfyUI
DRIVE_PATH(string, optional). When provided, workspace is set to<DRIVE_PATH>/ComfyUI- Clones
https://github.com/comfyanonymous/ComfyUIif not present - If
UPDATE_COMFY_UI = True, runsgit pull - Installs dependencies with
pip install xformers!=0.0.18 -r requirements.txtand CUDA wheels extra-indexes
- Models download helpers
- Installs
aria2for fast, segmented downloads downloadModel(url, filename=None)supports Civitai and Hugging Face- Civitai API token is read from Colab user secrets via:
Add a secret named
from google.colab import userdata CIVITAI_API_TOKEN = userdata.get('CIVITAI_API_TOKEN')
CIVITAI_API_TOKENin Colab (Manage user secrets) if you download private/protected links. - Example targets used in the notebook:
- Checkpoints:
./models/checkpoints - VAEs:
./models/vae
- Checkpoints:
- Installs
- Custom nodes (optional)
- Helper:
install_custom_node(url)clones into/content/ComfyUI/custom_nodes - Example lines for ComfyUI Manager/Impact Pack are included but commented out—uncomment to enable
- Helper:
- Start and expose ComfyUI
- Cloudflare: downloads
cloudflared.deb, starts tunnel, and prints atrycloudflare.comURL when port 8188 is ready - Localtunnel: global
ltinstall and public URL; also prints your endpoint IP for password prompt if required
- Cloudflare: downloads
- Recommended
DRIVE_PATH:/content/drive/MyDrive - With Drive mounted and
DRIVE_PATHset, your ComfyUI install, models, and custom nodes live in Drive and survive runtime restarts - Without Drive, everything under
/contentis temporary and will be lost when the Colab session ends
- Cloudflared hangs or prints no URL:
- Re-run the cell after ComfyUI fully starts, or use the Localtunnel cell as fallback
- Civitai 403 or auth errors:
- Ensure
CIVITAI_API_TOKENis set in Colab user secrets and the link is valid
- Ensure
- Hugging Face gated models:
- Accept the model license on the model page and ensure the direct URL is accessible
- Out-of-memory or slow starts:
- Use a smaller checkpoint, avoid heavy custom nodes, or try a Colab runtime with more VRAM
./models/checkpoints– base models (e.g., SD1.5, XL, etc.)./models/vae– VAE files./custom_nodes– optional custom node repos
This repository is licensed under the AGPL-3.0. See LICENSE.
The underlying ComfyUI project is developed by the ComfyUI authors; please refer to their repository and license for details.
- ComfyUI by comfyanonymous
- Community model authors on Civitai and Hugging Face