
原本甚至動了念頭——乾脆自組一台電腦,直上獨顯,才能真正順跑 SDXL 等大型模型。就在始研究顯卡規格時,卻意外發現Google Colab 竟然提供免費雲端 GPU可用,更方便的是,它還能整合 Google Drive。只要將模型事先上傳到雲端硬碟,執行 ComfyUI 時就能直接讀取,不必每次重傳模型檔,大幅省去時間與繁瑣步驟。讓輕薄筆電也能順暢的生成圖像,接下來梅干就來分享,如何透過 Google Colab 免費 GPU,在雲端執行 ComfyUI 生成圖片。
Google Colab!
Step1
首先在進入後,選擇上方的選單 執行階段 / 變更執行階段類型。
Step2
接著選擇T4 GPU,再按下方的儲存。
GPU顯卡一覽表
T4:相當於RTX2060~2070
L4:相當於RTX4070~4080
A100:相當於RTX ≥4090
H100:相當於RTX 4090 x2~3
L4:相當於RTX4070~4080
A100:相當於RTX ≥4090
H100:相當於RTX 4090 x2~3
Step3
接著按右邊的連線,當連線成功會看到綠色勾勾,點開來後,就會看到免費版提供15G的GPU,同時每日可免費使用四小時又30分。
Step4
接著點程式碼,並輸入下方的語法。
!git clone https://github.com/comfyanonymous/ComfyUI
%cd /content/ComfyUI
!pip install -r requirements.txt pycloudflared
!curl -L –output cloudflared.deb
https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb && dpkg -i cloudflared.deb !wget -c https://huggingface.co/Comfy-Org/flux1-redux-dev/resolve/main/flux1-redux-dev.safetensors -P models/style_models/ !wget -c https://huggingface.co/google/siglip-so400m-patch14-384/resolve/main/model.safetensors -P models/clip_vision/ -O siglip-so400m-patch14-384.safetensors import subprocess, threading, time
def run_comfyui():
subprocess.run(['python', 'main.py', '–dont-print-server', '–lowvram'])
threading.Thread(target=run_comfyui, daemon=True).start()
print("⏳ 請等候 15 秒…")
time.sleep(15)
!cloudflared tunnel –url http://127.0.0.1:8188
%cd /content/ComfyUI
!pip install -r requirements.txt pycloudflared
!curl -L –output cloudflared.deb
https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb && dpkg -i cloudflared.deb !wget -c https://huggingface.co/Comfy-Org/flux1-redux-dev/resolve/main/flux1-redux-dev.safetensors -P models/style_models/ !wget -c https://huggingface.co/google/siglip-so400m-patch14-384/resolve/main/model.safetensors -P models/clip_vision/ -O siglip-so400m-patch14-384.safetensors import subprocess, threading, time
def run_comfyui():
subprocess.run(['python', 'main.py', '–dont-print-server', '–lowvram'])
threading.Thread(target=run_comfyui, daemon=True).start()
print("⏳ 請等候 15 秒…")
time.sleep(15)
!cloudflared tunnel –url http://127.0.0.1:8188
Step5
接著再左邊的箭頭執行。
Step6
當執行完畢後,會看到xxxx.tycloudflare.com的連結。
Step7
點開來後,就可看到熟悉的ComfyUI啦!
Step8
經梅干實測T4 GPU,在生成一張1024的時間約10~15秒左右,速度比梅干的Macbook Air要來的快上許多,因此想玩ComfyUI的朋友,現在免買顯卡,可先用Google免費的GPU大玩AI啦!