การสร้าง Runpod Template สำหรับ ComfUI - gordon123/learn2ComfyUI GitHub Wiki
Component | Recommended Version(s) | Notes |
---|---|---|
Python | 3.12 (3.8–3.13 supported) | 3.13 works, but 3.12 is safest for all nodes |
PyTorch | 2.x (latest stable) | See above for CUDA/ROCm/Intel/Apple/DirectML options |
CUDA | 12.1/12.2 (NVIDIA) | Match to your driver and PyTorch install |
ROCm | 6.3/6.4 (AMD Linux) | Only for AMD GPUs on Linux |
torchvision | Match PyTorch version | |
OS | Modern Linux (Ubuntu 20.04+, etc.) | Also works on Windows/macOS with correct dependencies |
pip | Latest | Use pip install --upgrade pip |
สิ่งที่ต้องรู้ก่อนสร้าง
เราต้องรู้ก่อนว่า ComfyUI Support อะไร หรือเราจะสร้าง เพื่อ Custom node อะไรเฉพาะ บาง เครื่องมือรองรับ แค่ Python, Cuda, PyTorch, GPU version ect เก่า หรือใหม่ อันนี้ต้องทดลองดูก่อน
เขียน ณ วันที่ ComfyUI version v3.40 โดยทดลอง ไป Deploy Pod จาก Official template ที่เขามีอยู่แล้ว
ตัวอย่างการ เลือก Runpod server เพื่อ Install ComfyUI https://youtu.be/d9LAdOzJ_2o
https://github.com/copilot)
เวอร์ชันที่แนะนำ 👍 (อาจจะมีการเปลี่ยนแปลงในอนาคต แนะนำถามเวอชั่น รองรับ ComfyUI และ Custom node ส่วนใหญ่ Python: 3.10 - 3.12
Python 3.10 เป็นเวอร์ชันที่เสถียรและเข้ากันได้กับ Custom Node ส่วนใหญ่มาอย่างยาวนาน ถือเป็นตัวเลือกที่ปลอดภัยที่สุด Python 3.11 เป็นเวอร์ชันที่ใหม่กว่าและมักจะให้ประสิทธิภาพที่ดีขึ้นเล็กน้อย ปัจจุบัน Custom Node ส่วนใหญ่ก็รองรับเวอร์ชันนี้แล้ว
CUDA: 12.1 เวอร์ชันนี้เข้ากันได้ดีกับ PyTorch เวอร์ชันล่าสุดที่ ComfyUI แนะนำ และรองรับการ์ดจอ NVIDIA ซีรีส์ 30xx และ 40xx หากคุณใช้การ์ดจอที่เก่ากว่า (ซีรีส์ 20xx หรือเก่ากว่า) CUDA 11.8 ก็ยังเป็นตัวเลือกที่ดีและเข้ากันได้กับ Custom Node จำนวนมากเช่นกัน
สรุปและคำแนะนำ
เพื่อให้รองรับ Custom Node ได้อย่างกว้างขวางและมีปัญหาน้อยที่สุดในปัจจุบัน ชุดที่แนะนำคือ: Python 3.10 + CUDA 12.1
https://runpod.io
Step 1: ตัวอย่างการสร้างสำหรับเว๊ปไซด์ GPU cloud service- เลือก Base Image ที่มี Python 3.11 และ CUDA 12+ หรือที่เราต้องการ จาก dockerHub ของ Runpod https://hub.docker.com/r/runpod/pytorch/tags runpod/pytorch:2.3.0-py3.11-cuda12.1-devel-ubuntu22.04
- สร้าง Template ใหม่ ใน RunPod
- กำหนดค่าต่างๆ เช่น ขนาด Disk, Port ที่จะใช้
- เขียนสคริปต์ใน Container Start Command เพื่อ:
- Clone ComfyUI และ ComfyUI-Manager (ถ้ายังไม่มี ดูได้จาก Folder Scripts ตัวอย่าง)
Step 2: สร้าง Template สำหรับ ComfyUI ทีละขั้นตอน
ไปที่หน้า Templates ใน RunPod กด New Template จากนั้นกรอกข้อมูล ประมาณนี้
Name: My Test ComfyUI Python version ... PyTorch version ... <<< ชื่อไรก็ได้ ที่เราจำได้
Type: เลือก Pod
Visibility: เลือก Private (ใช่ส่วนตัว)
Container Image: ใส่ชื่อ Image ที่เราเลือกไว้ใน Step 1: เช่น runpod/pytorch:2.2.1-py3.10-cuda12.1.1-devel-ubuntu22.04
Registry Credentials: ปล่อยว่างไว้ (เลือก No Credentials) เพราะเราใช้ Image สาธารณะของ RunPod
Container Start Command: ตัวอย่าง Script บอก ChatGPT, Gemini, Git copilot ว่าเราต้องการสร้าง สำหรับ เวอชั่นอะไร ได้ตัวอย่างประมาณนี้ จะติดตั้ง Jupyter ใน Global env, Comfyui ใน virtual env
bash -c '
# Set the script to exit immediately if any command fails
set -e
# Navigate to the persistent workspace directory
cd /workspace
# --- 1. Create Virtual Environment ---
echo "Creating Python virtual environment at /workspace/comfyui-venv..."
if [ ! -d "comfyui-venv" ]; then
python -m venv comfyui-venv
fi
# Activate the venv for all subsequent commands in this block
source /workspace/comfyui-venv/bin/activate
# --- 2. Install everything INSIDE the venv ---
echo "Cloning/updating ComfyUI..."
if [ ! -d "ComfyUI" ]; then
git clone https://github.com/comfyanonymous/ComfyUI.git
fi
cd /workspace/ComfyUI
git pull
# Install dependencies using the venvs pip
echo "Installing ComfyUI requirements into the venv..."
pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu121
# Install JupyterLab and kernel into the venv
echo "Installing JupyterLab and Python Kernel into the venv..."
pip install jupyterlab ipykernel
# --- Install ComfyUI-Manager ---
echo "Cloning/updating ComfyUI-Manager..."
if [ ! -d "custom_nodes/ComfyUI-Manager" ]; then
git clone https://github.com/Comfy-Org/ComfyUI-Manager.git custom_nodes/ComfyUI-Manager
else
(cd custom_nodes/ComfyUI-Manager && git pull)
fi
# --- 3. Start services FROM the venv ---
echo "Launching ComfyUI from venv in the background..."
python main.py --listen --port 8188 &
echo "Launching JupyterLab from venv in the foreground with corrected flags..."
cd /workspace
# Use the venvs jupyter to run JupyterLab with the CORRECTED flags
jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root \
--ServerApp.token="" \
--ServerApp.password="" \
--ServerApp.allow_origin="*" \
--ServerApp.allow_credentials=True \
--ServerApp.terminals_enabled=True
'
Container Disk: นี่คือพื้นที่ชั่วคราวสำหรับระบบและไลบรารี แนะนำ 50 GB หรือมากกว่า
Volume Disk: ส่วนตัวผมตั้งเป็น 0 เพราะจะไม่เก็บ ไฟล์ไดๆ หลังทำงานเสร็จ แต่ถ้าใครอยากเก็บ ตั้งไว้ซัก 100 GB รายจ่ายโดยประมาณ 10USD/เดือน
Volume Mount Path: ตั้งค่าเป็น /workspace
HTTP ports: กด + Add port แล้วใส่ 8188 (นี่คือพอร์ตที่เราจะใช้เข้า ComfyUI) 8188 สำหรับ ComfyUI พอทอื่นๆ 7860 F5-TTS webUI 5678 สำหรับ n8n 8080: FileBrowser interface 8048: Zasper file access
TCP ports (แนะนำ): สำหรับ Dev SSH + vsCode กด + Add port แล้วใส่ 22 เพื่อให้คุณสามารถเชื่อมต่อผ่าน SSH
เมื่อกรอกครบแล้ว กด Save Template
ทดลอง Run Template
Check Container Log รอจน To see the GUI go to: http://0.0.0.0:8188 To see the GUI go to: http://[::]:8188 ถ้าเจอปัญหาได ๆ ก๊อปปี้ error ให้ ChatGPT!
ผมไม่รับแก้ปัญหาเด้อ 55555
Reference
https://github.com/runpod/containers?ref=blog.runpod.io https://hub.docker.com/r/runpod/pytorch/tags https://discord.com/channels/912829806415085598/1039196180103569569 https://blog.runpod.io/diy-deep-learning-docker-container/