Difference between revisions of "ComfyUI: Instalasi via docker compose"
Onnowpurbo (talk | contribs) (Created page with "## Menambahkan ComfyUI ke Docker Compose yang sudah ada Cara yang relatif aman adalah **membangun image ComfyUI sendiri dari repositori resmi**, bukan memakai image komunitas...") |
Onnowpurbo (talk | contribs) |
||
| Line 1: | Line 1: | ||
| − | + | Berikut rangkuman final yang sesuai dengan instalasi yang baru dilakukan. | |
| − | + | # Instalasi ComfyUI GPU dengan Docker Compose di Ubuntu 24.04 | |
| − | + | Panduan ini mendokumentasikan instalasi ComfyUI pada server Ubuntu 24.04 dengan alamat IP `192.168.0.230`. ComfyUI ditambahkan ke dalam Docker Compose yang sebelumnya sudah menjalankan Ollama, Open-WebUI, n8n, dan WAHA. | |
| + | |||
| + | Server menggunakan GPU NVIDIA GeForce RTX 4060 Laptop GPU dengan VRAM sekitar 8 GB. | ||
| − | + | --- | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | ## 1. Lokasi instalasi | |
| − | + | Seluruh stack berada di: | |
```bash | ```bash | ||
| − | + | /opt/ai-stack | |
``` | ``` | ||
| − | + | File utama Docker Compose: | |
```bash | ```bash | ||
| − | + | /opt/ai-stack/compose.yaml | |
``` | ``` | ||
| − | + | Direktori ComfyUI: | |
```bash | ```bash | ||
| − | + | /opt/ai-stack/comfyui | |
| − | |||
| − | |||
``` | ``` | ||
| − | + | --- | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | ## 2. Memastikan GPU NVIDIA tersedia | |
| − | |||
| − | |||
| − | |||
| − | + | Periksa GPU pada host: | |
```bash | ```bash | ||
| − | + | nvidia-smi | |
| − | |||
``` | ``` | ||
| − | + | Kemudian periksa apakah Docker dapat mengakses GPU: | |
| − | |||
| − | |||
```bash | ```bash | ||
| Line 70: | Line 47: | ||
``` | ``` | ||
| − | + | Pengujian berhasil apabila container menampilkan GPU NVIDIA, driver, CUDA, dan kapasitas VRAM. | |
| + | |||
| + | Pada instalasi ini, Docker berhasil mendeteksi: | ||
| + | |||
| + | ```text | ||
| + | NVIDIA GeForce RTX 4060 Laptop GPU | ||
| + | VRAM sekitar 8188 MiB | ||
| + | NVIDIA Driver 595.71.05 | ||
| + | ``` | ||
| + | |||
| + | Artinya NVIDIA Container Toolkit dan integrasi GPU Docker sudah berjalan dengan benar. | ||
--- | --- | ||
| − | ## | + | ## 3. Membuat direktori ComfyUI |
| − | Masuk ke direktori | + | Masuk ke direktori stack: |
```bash | ```bash | ||
| − | cd | + | cd /opt/ai-stack |
``` | ``` | ||
| − | + | Buat direktori utama dan direktori data ComfyUI: | |
| − | |||
| − | Buat | ||
```bash | ```bash | ||
| − | mkdir -p comfyui/data/{input,output,custom_nodes,user,cache} | + | mkdir -p comfyui/data/{models,input,output,custom_nodes,user,cache} |
``` | ``` | ||
| + | |||
| + | Buat subdirektori model: | ||
```bash | ```bash | ||
| Line 94: | Line 81: | ||
``` | ``` | ||
| − | + | Struktur akhirnya: | |
| − | ``` | + | ```text |
| − | + | /opt/ai-stack/ | |
| + | ├── compose.yaml | ||
| + | └── comfyui/ | ||
| + | ├── Dockerfile | ||
| + | ├── .dockerignore | ||
| + | └── data/ | ||
| + | ├── models/ | ||
| + | │ ├── checkpoints/ | ||
| + | │ ├── vae/ | ||
| + | │ ├── loras/ | ||
| + | │ ├── controlnet/ | ||
| + | │ ├── clip/ | ||
| + | │ ├── clip_vision/ | ||
| + | │ ├── diffusion_models/ | ||
| + | │ ├── text_encoders/ | ||
| + | │ ├── unet/ | ||
| + | │ ├── upscale_models/ | ||
| + | │ └── embeddings/ | ||
| + | ├── input/ | ||
| + | ├── output/ | ||
| + | ├── custom_nodes/ | ||
| + | ├── user/ | ||
| + | └── cache/ | ||
``` | ``` | ||
--- | --- | ||
| − | ## | + | ## 4. Membuat Dockerfile ComfyUI |
Buat file: | Buat file: | ||
```bash | ```bash | ||
| − | + | cat > /opt/ai-stack/comfyui/Dockerfile <<'EOF' | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
FROM python:3.12-slim-bookworm | FROM python:3.12-slim-bookworm | ||
| − | ENV DEBIAN_FRONTEND=noninteractive | + | ENV DEBIAN_FRONTEND=noninteractive |
| − | + | ENV PYTHONUNBUFFERED=1 | |
| − | + | ENV PIP_NO_CACHE_DIR=1 | |
| − | |||
RUN apt-get update && apt-get install -y --no-install-recommends \ | RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
git \ | git \ | ||
| Line 133: | Line 136: | ||
WORKDIR /opt | WORKDIR /opt | ||
| − | + | RUN git clone --depth 1 \ | |
| − | RUN git clone --depth 1 https://github.com/Comfy-Org/ComfyUI.git | + | https://github.com/Comfy-Org/ComfyUI.git \ |
| + | /opt/ComfyUI | ||
WORKDIR /opt/ComfyUI | WORKDIR /opt/ComfyUI | ||
| − | + | RUN python -m pip install --upgrade pip setuptools wheel | |
| − | RUN python -m pip install --upgrade pip setuptools wheel | + | |
| − | + | RUN python -m pip install \ | |
| − | + | torch==2.11.0 \ | |
| − | + | torchvision==0.26.0 \ | |
| − | + | torchaudio==2.11.0 \ | |
| + | --index-url https://download.pytorch.org/whl/cu128 | ||
| + | |||
| + | RUN python -m pip install -r requirements.txt \ | ||
&& python -m pip install -r manager_requirements.txt | && python -m pip install -r manager_requirements.txt | ||
| Line 153: | Line 160: | ||
"--enable-manager", \ | "--enable-manager", \ | ||
"--preview-method", "auto"] | "--preview-method", "auto"] | ||
| + | EOF | ||
``` | ``` | ||
| − | + | Periksa bahwa file sudah dibuat: | |
| + | |||
| + | ```bash | ||
| + | ls -lah /opt/ai-stack/comfyui/Dockerfile | ||
| + | ``` | ||
| + | |||
| + | Hasil instalasi ini menunjukkan: | ||
| + | |||
| + | ```text | ||
| + | -rw-r--r-- 1 root root 1001 Jul 21 10:58 comfyui/Dockerfile | ||
| + | ``` | ||
--- | --- | ||
| − | ## | + | ## 5. Membuat `.dockerignore` |
| − | + | File ini mencegah direktori model dan hasil gambar ikut dimasukkan ke Docker build context. | |
```bash | ```bash | ||
| − | + | cat > /opt/ai-stack/comfyui/.dockerignore <<'EOF' | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
data/ | data/ | ||
| + | .git/ | ||
__pycache__/ | __pycache__/ | ||
*.pyc | *.pyc | ||
*.pyo | *.pyo | ||
| − | + | EOF | |
``` | ``` | ||
--- | --- | ||
| − | ## | + | ## 6. Menambahkan ComfyUI ke Docker Compose |
| + | |||
| + | Tambahkan service berikut ke dalam `/opt/ai-stack/compose.yaml`. | ||
| − | + | Letakkan bagian ini setelah service WAHA dan sebelum bagian global `volumes:`. | |
```yaml | ```yaml | ||
################################ | ################################ | ||
| − | # 5. COMFYUI ( | + | # 5. COMFYUI (GPU) |
################################ | ################################ | ||
comfyui: | comfyui: | ||
| Line 191: | Line 207: | ||
context: ./comfyui | context: ./comfyui | ||
dockerfile: Dockerfile | dockerfile: Dockerfile | ||
| + | |||
image: local/comfyui:cu128 | image: local/comfyui:cu128 | ||
container_name: comfyui | container_name: comfyui | ||
| Line 196: | Line 213: | ||
ports: | ports: | ||
| − | - " | + | - "8188:8188" |
environment: | environment: | ||
| Line 219: | Line 236: | ||
- driver: nvidia | - driver: nvidia | ||
count: all | count: all | ||
| − | capabilities: | + | capabilities: |
| + | - gpu | ||
``` | ``` | ||
| − | Bagian | + | Bagian volume utama tetap: |
```yaml | ```yaml | ||
| Line 231: | Line 249: | ||
``` | ``` | ||
| − | + | ComfyUI tidak membutuhkan named volume tambahan karena semua datanya menggunakan bind mount di: | |
| + | |||
| + | ```text | ||
| + | /opt/ai-stack/comfyui/data | ||
| + | ``` | ||
| + | |||
| + | --- | ||
| + | |||
| + | ## 7. Memvalidasi Docker Compose | ||
| + | |||
| + | Masuk ke direktori stack: | ||
| + | |||
| + | ```bash | ||
| + | cd /opt/ai-stack | ||
| + | ``` | ||
| + | |||
| + | Validasi konfigurasi: | ||
| + | |||
| + | ```bash | ||
| + | docker compose config | ||
| + | ``` | ||
| + | |||
| + | Pastikan Compose mendeteksi seluruh service: | ||
| − | + | ```bash | |
| + | docker compose config --services | ||
| + | ``` | ||
| − | + | Hasilnya harus mencakup: | |
| − | + | ```text | |
| + | ollama | ||
| + | open-webui | ||
| + | n8n | ||
| + | waha | ||
| + | comfyui | ||
| + | ``` | ||
| + | |||
| + | Pada instalasi ini, konfigurasi ComfyUI terbaca sebagai: | ||
| + | |||
| + | ```text | ||
| + | build context: /opt/ai-stack/comfyui | ||
| + | dockerfile: Dockerfile | ||
| + | image: local/comfyui:cu128 | ||
| + | port: 8188 | ||
| + | GPU driver: nvidia | ||
| + | GPU count: all | ||
| + | ``` | ||
| + | |||
| + | --- | ||
| + | |||
| + | ## 8. Kesalahan `docker compose pull` | ||
| + | |||
| + | Ketika menjalankan: | ||
| + | |||
| + | ```bash | ||
| + | docker compose pull | ||
| + | ``` | ||
| + | |||
| + | muncul pesan: | ||
| + | |||
| + | ```text | ||
| + | pull access denied for local/comfyui | ||
| + | repository does not exist or may require docker login | ||
| + | ``` | ||
| + | |||
| + | Hal ini terjadi karena: | ||
```yaml | ```yaml | ||
| − | + | image: local/comfyui:cu128 | |
| − | |||
``` | ``` | ||
| − | + | merupakan image lokal yang harus dibangun dari Dockerfile, bukan diunduh dari Docker Hub. | |
| + | |||
| + | Tidak perlu melakukan `docker login`. | ||
| − | + | Untuk service ComfyUI, gunakan: | |
| − | ``` | + | ```bash |
| − | + | docker compose build comfyui | |
| − | |||
``` | ``` | ||
| − | + | Untuk memperbarui image service lain tanpa mencoba menarik image ComfyUI: | |
| + | |||
| + | ```bash | ||
| + | docker compose pull --ignore-buildable | ||
| + | ``` | ||
--- | --- | ||
| − | ## | + | ## 9. Membangun image ComfyUI |
Jalankan: | Jalankan: | ||
```bash | ```bash | ||
| − | docker compose | + | cd /opt/ai-stack |
| + | docker compose build comfyui | ||
``` | ``` | ||
| − | + | Docker akan melakukan beberapa hal: | |
| + | |||
| + | * Mengunduh base image Python 3.12. | ||
| + | * Menginstal Git, FFmpeg, library OpenGL, dan compiler. | ||
| + | * Mengambil source code ComfyUI. | ||
| + | * Menginstal PyTorch dengan CUDA 12.8. | ||
| + | * Menginstal seluruh requirement ComfyUI. | ||
| + | * Menginstal ComfyUI-Manager. | ||
| + | * Memberikan nama image `local/comfyui:cu128`. | ||
| + | |||
| + | Periksa image setelah build: | ||
```bash | ```bash | ||
| − | docker | + | docker image ls local/comfyui |
``` | ``` | ||
| − | + | --- | |
| + | |||
| + | ## 10. Menjalankan ComfyUI | ||
| + | |||
| + | Jalankan hanya service ComfyUI: | ||
```bash | ```bash | ||
| − | docker compose up -d comfyui | + | docker compose up -d --no-deps comfyui |
``` | ``` | ||
| − | + | Opsi `--no-deps` mencegah Docker Compose menjalankan ulang atau mengubah service lain. | |
| − | + | Periksa status: | |
| − | |||
| − | |||
| − | Periksa | + | ```bash |
| + | docker compose ps comfyui | ||
| + | ``` | ||
| + | |||
| + | Periksa log: | ||
```bash | ```bash | ||
| − | docker compose | + | docker compose logs -f --tail=100 comfyui |
``` | ``` | ||
| − | + | Instalasi berhasil ketika muncul: | |
```text | ```text | ||
| − | + | [INFO] Starting server | |
| + | |||
| + | [INFO] To see the GUI go to: http://0.0.0.0:8188 | ||
| + | ``` | ||
| + | |||
| + | Pada instalasi ini ComfyUI berhasil menjalankan: | ||
| + | |||
| + | ```text | ||
| + | ComfyUI version: 0.28.0 | ||
| + | comfyui-frontend-package version: 1.45.21 | ||
| + | ComfyUI-Manager | ||
``` | ``` | ||
--- | --- | ||
| − | ## | + | ## 11. Peringatan yang aman diabaikan |
| − | ``` | + | Log menampilkan: |
| − | + | ||
| + | ```text | ||
| + | The matrix sharing feature has been disabled because the matrix-nio dependency is not installed. | ||
| + | ``` | ||
| + | |||
| + | Ini bukan error. Fitur berbagi melalui Matrix tidak diperlukan untuk penggunaan normal ComfyUI. | ||
| + | |||
| + | Log juga menampilkan: | ||
| + | |||
| + | ```text | ||
| + | No OpenGL_accelerate module loaded | ||
``` | ``` | ||
| − | + | Ini juga bukan error fatal. ComfyUI tetap dapat berjalan menggunakan CUDA dan antarmuka web. | |
| + | |||
| + | Tidak perlu memasang kedua modul tersebut apabila ComfyUI sudah berjalan normal. | ||
| + | |||
| + | --- | ||
| + | |||
| + | ## 12. Mengakses ComfyUI | ||
| + | |||
| + | Buka browser dari komputer yang berada dalam jaringan yang sama: | ||
```text | ```text | ||
| − | + | http://192.168.0.230:8188 | |
| − | |||
| − | |||
| − | |||
``` | ``` | ||
| − | + | Port `8188` diarahkan dari host ke container: | |
| + | |||
| + | ```yaml | ||
| + | ports: | ||
| + | - "8188:8188" | ||
| + | ``` | ||
--- | --- | ||
| − | ## | + | ## 13. Memastikan ComfyUI menggunakan GPU |
Jalankan: | Jalankan: | ||
```bash | ```bash | ||
| − | docker exec comfyui python -c | + | docker exec comfyui python -c ' |
| − | + | import torch | |
| + | |||
| + | print("PyTorch :", torch.__version__) | ||
| + | print("CUDA runtime :", torch.version.cuda) | ||
| + | print("CUDA tersedia :", torch.cuda.is_available()) | ||
| + | |||
| + | if torch.cuda.is_available(): | ||
| + | print("GPU :", torch.cuda.get_device_name(0)) | ||
| + | print( | ||
| + | "VRAM :", | ||
| + | round(torch.cuda.get_device_properties(0).total_memory / 1024**3, 2), | ||
| + | "GB" | ||
| + | ) | ||
| + | ' | ||
``` | ``` | ||
| Line 328: | Line 470: | ||
```text | ```text | ||
| − | CUDA tersedia: True | + | CUDA tersedia : True |
| − | + | GPU : NVIDIA GeForce RTX 4060 Laptop GPU | |
| − | + | VRAM : sekitar 8 GB | |
| − | GPU: NVIDIA GeForce RTX | ||
``` | ``` | ||
--- | --- | ||
| − | ## | + | ## 14. Menyalin model DreamShaper ke server |
| − | + | Model berada pada laptop `i3` di: | |
```text | ```text | ||
| − | + | /home/onno/Downloads/LIBRARY/DreamShaper_8_pruned.safetensors | |
``` | ``` | ||
| − | + | Tujuan model di server: | |
```text | ```text | ||
| − | comfyui/data/models/checkpoints/ | + | /opt/ai-stack/comfyui/data/models/checkpoints/ |
``` | ``` | ||
| − | + | Dari laptop `i3`, jalankan: | |
| + | |||
| + | ```bash | ||
| + | cd ~/Downloads/LIBRARY | ||
| + | ``` | ||
| + | |||
| + | Kemudian salin menggunakan SCP: | ||
| + | |||
| + | ```bash | ||
| + | scp DreamShaper_8_pruned.safetensors \ | ||
| + | onno@192.168.0.230:/opt/ai-stack/comfyui/data/models/checkpoints/ | ||
| + | ``` | ||
| + | |||
| + | Masukkan password user `onno` pada server. | ||
| + | |||
| + | Periksa file dari server: | ||
| + | |||
| + | ```bash | ||
| + | ssh onno@192.168.0.230 | ||
| + | ``` | ||
| + | |||
| + | ```bash | ||
| + | ls -lh /opt/ai-stack/comfyui/data/models/checkpoints/ | ||
| + | ``` | ||
| + | |||
| + | File yang harus terlihat: | ||
```text | ```text | ||
| − | comfyui/data/models/ | + | DreamShaper_8_pruned.safetensors |
| + | ``` | ||
| + | |||
| + | --- | ||
| + | |||
| + | ## 15. Jika terjadi `Permission denied` saat SCP | ||
| + | |||
| + | Salin dahulu ke home user: | ||
| + | |||
| + | ```bash | ||
| + | scp DreamShaper_8_pruned.safetensors \ | ||
| + | onno@192.168.0.230:/home/onno/ | ||
| + | ``` | ||
| + | |||
| + | Masuk ke server: | ||
| + | |||
| + | ```bash | ||
| + | ssh onno@192.168.0.230 | ||
| + | ``` | ||
| + | |||
| + | Pindahkan menggunakan `sudo`: | ||
| + | |||
| + | ```bash | ||
| + | sudo mv ~/DreamShaper_8_pruned.safetensors \ | ||
| + | /opt/ai-stack/comfyui/data/models/checkpoints/ | ||
``` | ``` | ||
| − | + | Atur kepemilikan: | |
| − | ``` | + | ```bash |
| − | comfyui/data/models/ | + | sudo chown onno:onno \ |
| + | /opt/ai-stack/comfyui/data/models/checkpoints/DreamShaper_8_pruned.safetensors | ||
| + | ``` | ||
| + | |||
| + | --- | ||
| + | |||
| + | ## 16. Mengatur kepemilikan direktori ComfyUI | ||
| + | |||
| + | Karena beberapa file dibuat sebagai `root`, ubah kepemilikannya agar user `onno` dapat mengelola model, input, dan output: | ||
| + | |||
| + | ```bash | ||
| + | sudo chown -R onno:onno /opt/ai-stack/comfyui | ||
| + | ``` | ||
| + | |||
| + | Periksa: | ||
| + | |||
| + | ```bash | ||
| + | ls -ld /opt/ai-stack/comfyui | ||
| + | ls -ld /opt/ai-stack/comfyui/data/models/checkpoints | ||
``` | ``` | ||
| − | + | --- | |
| + | |||
| + | ## 17. Memuat model yang baru disalin | ||
| − | Setelah | + | Setelah model selesai disalin, restart ComfyUI: |
```bash | ```bash | ||
| + | cd /opt/ai-stack | ||
docker compose restart comfyui | docker compose restart comfyui | ||
``` | ``` | ||
| + | |||
| + | Pantau log: | ||
| + | |||
| + | ```bash | ||
| + | docker compose logs -f --tail=100 comfyui | ||
| + | ``` | ||
| + | |||
| + | Kemudian muat ulang halaman browser: | ||
| + | |||
| + | ```text | ||
| + | http://192.168.0.230:8188 | ||
| + | ``` | ||
| + | |||
| + | Pada node `Load Checkpoint`, pilih: | ||
| + | |||
| + | ```text | ||
| + | DreamShaper_8_pruned.safetensors | ||
| + | ``` | ||
| + | |||
| + | DreamShaper 8 merupakan checkpoint berbasis Stable Diffusion 1.5, sehingga relatif sesuai untuk GPU dengan VRAM 8 GB. | ||
--- | --- | ||
| − | ## | + | ## 18. Perintah operasional sehari-hari |
| − | + | Menjalankan ComfyUI: | |
```bash | ```bash | ||
| − | docker compose | + | cd /opt/ai-stack |
| + | docker compose start comfyui | ||
``` | ``` | ||
| − | + | Menghentikan ComfyUI: | |
```bash | ```bash | ||
| − | docker compose | + | docker compose stop comfyui |
``` | ``` | ||
| Line 392: | Line 624: | ||
``` | ``` | ||
| − | + | Melihat status: | |
```bash | ```bash | ||
| − | docker compose | + | docker compose ps comfyui |
``` | ``` | ||
| − | Membangun ulang | + | Melihat log: |
| + | |||
| + | ```bash | ||
| + | docker compose logs -f --tail=100 comfyui | ||
| + | ``` | ||
| + | |||
| + | Membangun ulang setelah Dockerfile berubah: | ||
| + | |||
| + | ```bash | ||
| + | docker compose build comfyui | ||
| + | docker compose up -d --no-deps comfyui | ||
| + | ``` | ||
| + | |||
| + | Membangun ulang tanpa menggunakan build cache: | ||
```bash | ```bash | ||
docker compose build --no-cache comfyui | docker compose build --no-cache comfyui | ||
| − | docker compose up -d comfyui | + | docker compose up -d --no-deps comfyui |
``` | ``` | ||
| − | + | --- | |
| − | + | ## 19. Penggunaan bersama Ollama | |
| − | + | Ollama dan ComfyUI menggunakan GPU yang sama. | |
| − | + | RTX 4060 memiliki VRAM sekitar 8 GB. Jika model Ollama masih berada dalam VRAM, ComfyUI dapat kehabisan memori dan menampilkan: | |
```text | ```text | ||
| Line 417: | Line 662: | ||
``` | ``` | ||
| − | + | Sebelum menghasilkan gambar besar, Ollama dapat dihentikan sementara: | |
```bash | ```bash | ||
| + | cd /opt/ai-stack | ||
docker compose stop ollama | docker compose stop ollama | ||
``` | ``` | ||
| − | + | Restart ComfyUI: | |
```bash | ```bash | ||
| Line 429: | Line 675: | ||
``` | ``` | ||
| − | Setelah selesai | + | Setelah selesai menggunakan ComfyUI, jalankan kembali Ollama: |
```bash | ```bash | ||
| Line 435: | Line 681: | ||
``` | ``` | ||
| − | + | --- | |
| + | |||
| + | ## 20. Lokasi file penting | ||
| + | |||
| + | Dockerfile: | ||
| + | |||
| + | ```text | ||
| + | /opt/ai-stack/comfyui/Dockerfile | ||
| + | ``` | ||
| + | |||
| + | Docker Compose: | ||
| + | |||
| + | ```text | ||
| + | /opt/ai-stack/compose.yaml | ||
| + | ``` | ||
| + | |||
| + | Checkpoint: | ||
| + | |||
| + | ```text | ||
| + | /opt/ai-stack/comfyui/data/models/checkpoints/ | ||
| + | ``` | ||
| + | |||
| + | LoRA: | ||
| + | |||
| + | ```text | ||
| + | /opt/ai-stack/comfyui/data/models/loras/ | ||
| + | ``` | ||
| + | |||
| + | VAE: | ||
| + | |||
| + | ```text | ||
| + | /opt/ai-stack/comfyui/data/models/vae/ | ||
| + | ``` | ||
| + | |||
| + | Input gambar: | ||
| + | |||
| + | ```text | ||
| + | /opt/ai-stack/comfyui/data/input/ | ||
| + | ``` | ||
| + | |||
| + | Hasil gambar: | ||
| + | |||
| + | ```text | ||
| + | /opt/ai-stack/comfyui/data/output/ | ||
| + | ``` | ||
| + | |||
| + | Custom node: | ||
| + | |||
| + | ```text | ||
| + | /opt/ai-stack/comfyui/data/custom_nodes/ | ||
| + | ``` | ||
| + | |||
| + | Cache model: | ||
| + | |||
| + | ```text | ||
| + | /opt/ai-stack/comfyui/data/cache/ | ||
| + | ``` | ||
| + | |||
| + | --- | ||
| + | |||
| + | ## 21. Status akhir instalasi | ||
| + | |||
| + | ComfyUI telah berhasil: | ||
| + | |||
| + | * Dibangun menggunakan Dockerfile lokal. | ||
| + | * Ditambahkan sebagai service kelima di Docker Compose. | ||
| + | * Mengakses GPU NVIDIA melalui NVIDIA Container Toolkit. | ||
| + | * Menjalankan PyTorch dengan dukungan CUDA. | ||
| + | * Menjalankan ComfyUI-Manager. | ||
| + | * Membuka antarmuka web pada port `8188`. | ||
| + | * Menyimpan model, input, output, dan custom node secara persisten di host. | ||
| + | * Siap menggunakan checkpoint `DreamShaper_8_pruned.safetensors`. | ||
| + | |||
| + | Alamat akses akhir: | ||
| + | |||
| + | ```text | ||
| + | http://192.168.0.230:8188 | ||
| + | ``` | ||
| − | + | Panduan ini dapat langsung disimpan sebagai `/opt/ai-stack/README-ComfyUI.md`. | |
| − | |||
| − | |||
| − | |||
Latest revision as of 18:39, 21 July 2026
Berikut rangkuman final yang sesuai dengan instalasi yang baru dilakukan.
- Instalasi ComfyUI GPU dengan Docker Compose di Ubuntu 24.04
Panduan ini mendokumentasikan instalasi ComfyUI pada server Ubuntu 24.04 dengan alamat IP `192.168.0.230`. ComfyUI ditambahkan ke dalam Docker Compose yang sebelumnya sudah menjalankan Ollama, Open-WebUI, n8n, dan WAHA.
Server menggunakan GPU NVIDIA GeForce RTX 4060 Laptop GPU dengan VRAM sekitar 8 GB.
---
- 1. Lokasi instalasi
Seluruh stack berada di:
```bash /opt/ai-stack ```
File utama Docker Compose:
```bash /opt/ai-stack/compose.yaml ```
Direktori ComfyUI:
```bash /opt/ai-stack/comfyui ```
---
- 2. Memastikan GPU NVIDIA tersedia
Periksa GPU pada host:
```bash nvidia-smi ```
Kemudian periksa apakah Docker dapat mengakses GPU:
```bash docker run --rm --gpus all \
nvidia/cuda:12.9.0-base-ubuntu22.04 \ nvidia-smi
```
Pengujian berhasil apabila container menampilkan GPU NVIDIA, driver, CUDA, dan kapasitas VRAM.
Pada instalasi ini, Docker berhasil mendeteksi:
```text NVIDIA GeForce RTX 4060 Laptop GPU VRAM sekitar 8188 MiB NVIDIA Driver 595.71.05 ```
Artinya NVIDIA Container Toolkit dan integrasi GPU Docker sudah berjalan dengan benar.
---
- 3. Membuat direktori ComfyUI
Masuk ke direktori stack:
```bash cd /opt/ai-stack ```
Buat direktori utama dan direktori data ComfyUI:
```bash mkdir -p comfyui/data/{models,input,output,custom_nodes,user,cache} ```
Buat subdirektori model:
```bash mkdir -p comfyui/data/models/{checkpoints,vae,loras,controlnet,clip,clip_vision,diffusion_models,text_encoders,unet,upscale_models,embeddings} ```
Struktur akhirnya:
```text /opt/ai-stack/ ├── compose.yaml └── comfyui/
├── Dockerfile
├── .dockerignore
└── data/
├── models/
│ ├── checkpoints/
│ ├── vae/
│ ├── loras/
│ ├── controlnet/
│ ├── clip/
│ ├── clip_vision/
│ ├── diffusion_models/
│ ├── text_encoders/
│ ├── unet/
│ ├── upscale_models/
│ └── embeddings/
├── input/
├── output/
├── custom_nodes/
├── user/
└── cache/
```
---
- 4. Membuat Dockerfile ComfyUI
Buat file:
```bash cat > /opt/ai-stack/comfyui/Dockerfile <<'EOF' FROM python:3.12-slim-bookworm
ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONUNBUFFERED=1 ENV PIP_NO_CACHE_DIR=1
RUN apt-get update && apt-get install -y --no-install-recommends \
git \ ca-certificates \ curl \ ffmpeg \ build-essential \ libgl1 \ libglib2.0-0 \ libgomp1 \ && rm -rf /var/lib/apt/lists/*
WORKDIR /opt
RUN git clone --depth 1 \
https://github.com/Comfy-Org/ComfyUI.git \ /opt/ComfyUI
WORKDIR /opt/ComfyUI
RUN python -m pip install --upgrade pip setuptools wheel
RUN python -m pip install \
torch==2.11.0 \ torchvision==0.26.0 \ torchaudio==2.11.0 \ --index-url https://download.pytorch.org/whl/cu128
RUN python -m pip install -r requirements.txt \
&& python -m pip install -r manager_requirements.txt
EXPOSE 8188
CMD ["python", "main.py", \
"--listen", "0.0.0.0", \
"--port", "8188", \
"--enable-manager", \
"--preview-method", "auto"]
EOF ```
Periksa bahwa file sudah dibuat:
```bash ls -lah /opt/ai-stack/comfyui/Dockerfile ```
Hasil instalasi ini menunjukkan:
```text -rw-r--r-- 1 root root 1001 Jul 21 10:58 comfyui/Dockerfile ```
---
- 5. Membuat `.dockerignore`
File ini mencegah direktori model dan hasil gambar ikut dimasukkan ke Docker build context.
```bash cat > /opt/ai-stack/comfyui/.dockerignore <<'EOF' data/ .git/ __pycache__/
- .pyc
- .pyo
EOF ```
---
- 6. Menambahkan ComfyUI ke Docker Compose
Tambahkan service berikut ke dalam `/opt/ai-stack/compose.yaml`.
Letakkan bagian ini setelah service WAHA dan sebelum bagian global `volumes:`.
```yaml
################################
# 5. COMFYUI (GPU)
################################
comfyui:
build:
context: ./comfyui
dockerfile: Dockerfile
image: local/comfyui:cu128 container_name: comfyui restart: unless-stopped
ports:
- "8188:8188"
environment:
- TZ=Asia/Jakarta
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute,utility
volumes:
- ./comfyui/data/models:/opt/ComfyUI/models
- ./comfyui/data/input:/opt/ComfyUI/input
- ./comfyui/data/output:/opt/ComfyUI/output
- ./comfyui/data/custom_nodes:/opt/ComfyUI/custom_nodes
- ./comfyui/data/user:/opt/ComfyUI/user
- ./comfyui/data/cache:/root/.cache
shm_size: "8gb"
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities:
- gpu
```
Bagian volume utama tetap:
```yaml volumes:
ollama_data: openwebui_data: n8n_data:
```
ComfyUI tidak membutuhkan named volume tambahan karena semua datanya menggunakan bind mount di:
```text /opt/ai-stack/comfyui/data ```
---
- 7. Memvalidasi Docker Compose
Masuk ke direktori stack:
```bash cd /opt/ai-stack ```
Validasi konfigurasi:
```bash docker compose config ```
Pastikan Compose mendeteksi seluruh service:
```bash docker compose config --services ```
Hasilnya harus mencakup:
```text ollama open-webui n8n waha comfyui ```
Pada instalasi ini, konfigurasi ComfyUI terbaca sebagai:
```text build context: /opt/ai-stack/comfyui dockerfile: Dockerfile image: local/comfyui:cu128 port: 8188 GPU driver: nvidia GPU count: all ```
---
- 8. Kesalahan `docker compose pull`
Ketika menjalankan:
```bash docker compose pull ```
muncul pesan:
```text pull access denied for local/comfyui repository does not exist or may require docker login ```
Hal ini terjadi karena:
```yaml image: local/comfyui:cu128 ```
merupakan image lokal yang harus dibangun dari Dockerfile, bukan diunduh dari Docker Hub.
Tidak perlu melakukan `docker login`.
Untuk service ComfyUI, gunakan:
```bash docker compose build comfyui ```
Untuk memperbarui image service lain tanpa mencoba menarik image ComfyUI:
```bash docker compose pull --ignore-buildable ```
---
- 9. Membangun image ComfyUI
Jalankan:
```bash cd /opt/ai-stack docker compose build comfyui ```
Docker akan melakukan beberapa hal:
- Mengunduh base image Python 3.12.
- Menginstal Git, FFmpeg, library OpenGL, dan compiler.
- Mengambil source code ComfyUI.
- Menginstal PyTorch dengan CUDA 12.8.
- Menginstal seluruh requirement ComfyUI.
- Menginstal ComfyUI-Manager.
- Memberikan nama image `local/comfyui:cu128`.
Periksa image setelah build:
```bash docker image ls local/comfyui ```
---
- 10. Menjalankan ComfyUI
Jalankan hanya service ComfyUI:
```bash docker compose up -d --no-deps comfyui ```
Opsi `--no-deps` mencegah Docker Compose menjalankan ulang atau mengubah service lain.
Periksa status:
```bash docker compose ps comfyui ```
Periksa log:
```bash docker compose logs -f --tail=100 comfyui ```
Instalasi berhasil ketika muncul:
```text [INFO] Starting server
[INFO] To see the GUI go to: http://0.0.0.0:8188 ```
Pada instalasi ini ComfyUI berhasil menjalankan:
```text ComfyUI version: 0.28.0 comfyui-frontend-package version: 1.45.21 ComfyUI-Manager ```
---
- 11. Peringatan yang aman diabaikan
Log menampilkan:
```text The matrix sharing feature has been disabled because the matrix-nio dependency is not installed. ```
Ini bukan error. Fitur berbagi melalui Matrix tidak diperlukan untuk penggunaan normal ComfyUI.
Log juga menampilkan:
```text No OpenGL_accelerate module loaded ```
Ini juga bukan error fatal. ComfyUI tetap dapat berjalan menggunakan CUDA dan antarmuka web.
Tidak perlu memasang kedua modul tersebut apabila ComfyUI sudah berjalan normal.
---
- 12. Mengakses ComfyUI
Buka browser dari komputer yang berada dalam jaringan yang sama:
```text http://192.168.0.230:8188 ```
Port `8188` diarahkan dari host ke container:
```yaml ports:
- "8188:8188"
```
---
- 13. Memastikan ComfyUI menggunakan GPU
Jalankan:
```bash docker exec comfyui python -c ' import torch
print("PyTorch :", torch.__version__) print("CUDA runtime :", torch.version.cuda) print("CUDA tersedia :", torch.cuda.is_available())
if torch.cuda.is_available():
print("GPU :", torch.cuda.get_device_name(0))
print(
"VRAM :",
round(torch.cuda.get_device_properties(0).total_memory / 1024**3, 2),
"GB"
)
' ```
Hasil yang diharapkan:
```text CUDA tersedia : True GPU : NVIDIA GeForce RTX 4060 Laptop GPU VRAM : sekitar 8 GB ```
---
- 14. Menyalin model DreamShaper ke server
Model berada pada laptop `i3` di:
```text /home/onno/Downloads/LIBRARY/DreamShaper_8_pruned.safetensors ```
Tujuan model di server:
```text /opt/ai-stack/comfyui/data/models/checkpoints/ ```
Dari laptop `i3`, jalankan:
```bash cd ~/Downloads/LIBRARY ```
Kemudian salin menggunakan SCP:
```bash scp DreamShaper_8_pruned.safetensors \
onno@192.168.0.230:/opt/ai-stack/comfyui/data/models/checkpoints/
```
Masukkan password user `onno` pada server.
Periksa file dari server:
```bash ssh onno@192.168.0.230 ```
```bash ls -lh /opt/ai-stack/comfyui/data/models/checkpoints/ ```
File yang harus terlihat:
```text DreamShaper_8_pruned.safetensors ```
---
- 15. Jika terjadi `Permission denied` saat SCP
Salin dahulu ke home user:
```bash scp DreamShaper_8_pruned.safetensors \
onno@192.168.0.230:/home/onno/
```
Masuk ke server:
```bash ssh onno@192.168.0.230 ```
Pindahkan menggunakan `sudo`:
```bash sudo mv ~/DreamShaper_8_pruned.safetensors \
/opt/ai-stack/comfyui/data/models/checkpoints/
```
Atur kepemilikan:
```bash sudo chown onno:onno \
/opt/ai-stack/comfyui/data/models/checkpoints/DreamShaper_8_pruned.safetensors
```
---
- 16. Mengatur kepemilikan direktori ComfyUI
Karena beberapa file dibuat sebagai `root`, ubah kepemilikannya agar user `onno` dapat mengelola model, input, dan output:
```bash sudo chown -R onno:onno /opt/ai-stack/comfyui ```
Periksa:
```bash ls -ld /opt/ai-stack/comfyui ls -ld /opt/ai-stack/comfyui/data/models/checkpoints ```
---
- 17. Memuat model yang baru disalin
Setelah model selesai disalin, restart ComfyUI:
```bash cd /opt/ai-stack docker compose restart comfyui ```
Pantau log:
```bash docker compose logs -f --tail=100 comfyui ```
Kemudian muat ulang halaman browser:
```text http://192.168.0.230:8188 ```
Pada node `Load Checkpoint`, pilih:
```text DreamShaper_8_pruned.safetensors ```
DreamShaper 8 merupakan checkpoint berbasis Stable Diffusion 1.5, sehingga relatif sesuai untuk GPU dengan VRAM 8 GB.
---
- 18. Perintah operasional sehari-hari
Menjalankan ComfyUI:
```bash cd /opt/ai-stack docker compose start comfyui ```
Menghentikan ComfyUI:
```bash docker compose stop comfyui ```
Restart:
```bash docker compose restart comfyui ```
Melihat status:
```bash docker compose ps comfyui ```
Melihat log:
```bash docker compose logs -f --tail=100 comfyui ```
Membangun ulang setelah Dockerfile berubah:
```bash docker compose build comfyui docker compose up -d --no-deps comfyui ```
Membangun ulang tanpa menggunakan build cache:
```bash docker compose build --no-cache comfyui docker compose up -d --no-deps comfyui ```
---
- 19. Penggunaan bersama Ollama
Ollama dan ComfyUI menggunakan GPU yang sama.
RTX 4060 memiliki VRAM sekitar 8 GB. Jika model Ollama masih berada dalam VRAM, ComfyUI dapat kehabisan memori dan menampilkan:
```text CUDA out of memory ```
Sebelum menghasilkan gambar besar, Ollama dapat dihentikan sementara:
```bash cd /opt/ai-stack docker compose stop ollama ```
Restart ComfyUI:
```bash docker compose restart comfyui ```
Setelah selesai menggunakan ComfyUI, jalankan kembali Ollama:
```bash docker compose start ollama ```
---
- 20. Lokasi file penting
Dockerfile:
```text /opt/ai-stack/comfyui/Dockerfile ```
Docker Compose:
```text /opt/ai-stack/compose.yaml ```
Checkpoint:
```text /opt/ai-stack/comfyui/data/models/checkpoints/ ```
LoRA:
```text /opt/ai-stack/comfyui/data/models/loras/ ```
VAE:
```text /opt/ai-stack/comfyui/data/models/vae/ ```
Input gambar:
```text /opt/ai-stack/comfyui/data/input/ ```
Hasil gambar:
```text /opt/ai-stack/comfyui/data/output/ ```
Custom node:
```text /opt/ai-stack/comfyui/data/custom_nodes/ ```
Cache model:
```text /opt/ai-stack/comfyui/data/cache/ ```
---
- 21. Status akhir instalasi
ComfyUI telah berhasil:
- Dibangun menggunakan Dockerfile lokal.
- Ditambahkan sebagai service kelima di Docker Compose.
- Mengakses GPU NVIDIA melalui NVIDIA Container Toolkit.
- Menjalankan PyTorch dengan dukungan CUDA.
- Menjalankan ComfyUI-Manager.
- Membuka antarmuka web pada port `8188`.
- Menyimpan model, input, output, dan custom node secara persisten di host.
- Siap menggunakan checkpoint `DreamShaper_8_pruned.safetensors`.
Alamat akses akhir:
```text http://192.168.0.230:8188 ```
Panduan ini dapat langsung disimpan sebagai `/opt/ai-stack/README-ComfyUI.md`.