ComfyUIをUbuntu24.04にインストール


ComfyUIをUbuntu24.04にインストール

ずいぶん乗り遅れているが、画像生成AIを使って見たいと思い、ComfyUIをUbuntuにインストールしてみた。

基本的にはComfyUI Wikiの通りにするだけ。

comfycli

Terminal window
python -m venv comfy-env
source comfy-env/bin/activate
pip install comfy-cli
comfy --install-comp
comfy install
pip3 install torch torchvision torchaudio
comfy launch -- --listen 0.0.0.0

~/comfy/ComfyUI/にインストールされた。--listen 0.0.0.0で別PCのブラウザから、ip address:8188でアクセスできる。

systemdで自動起動

起動スクリプト作成

Terminal window
vim ~/comfy/comfyui-start.sh
comfyui-start.sh
#!/bin/bash
cd /home/myusername/comfy
source /home/myusername/.bashrc
source /home/myusername/comfy-env/bin/activate
comfy launch -- --listen 0.0.0.0
Terminal window
chmod +x ~/comfy/comfyui-start.sh

systemdユニットファイル作成

Terminal window
sudo vim /etc/systemd/system/comfyui.service
comfyui.service
[Unit]
Description=ComfyUI Service
After=network.target
[Service]
Type=simple
User=myusername
ExecStart=/home/myusername/comfy/comfyui-start.sh
Restart=always
WorkingDirectory=/home/myusername/comfy/ComfyUI
[Install]
WantedBy=multi-user.target

systemdに登録

Terminal window
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enabel comfyui
sudo systemctl start comfyui
systemctl status comfyui

Author

me

入谷 史人

Scientist (Ph.D.), Programer, Web Developer, Guitarist, Photographer

more...