feat: add virtual environment support for ComfyUI

Changes:
- Create venv for ComfyUI in setup/comfyui-base script
- Install extension dependencies: GitPython, opencv-python-headless,
  diffusers, insightface, onnxruntime
- Update start.sh to activate venv before running
- Add musicgen model directory

This fixes import errors for custom nodes:
- ComfyUI-Manager (needs GitPython)
- ComfyUI-Impact-Pack (needs opencv)
- ComfyUI-VideoHelperSuite (needs opencv)
- ComfyUI-CogVideoXWrapper (needs diffusers)
- ComfyUI-Inspire-Pack (needs insightface, onnxruntime)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-23 06:57:51 +01:00
parent 904a70df76
commit 4dd608a67d
2 changed files with 28 additions and 5 deletions

View File

@@ -229,19 +229,34 @@ scripts:
cd $COMFYUI_ROOT && git pull
fi
# Create virtual environment for ComfyUI
echo "Creating virtual environment for ComfyUI..."
cd $COMFYUI_ROOT
if [ ! -d "venv" ]; then
python3 -m venv venv
fi
source venv/bin/activate
# Install ComfyUI dependencies
echo "Installing ComfyUI dependencies..."
sudo pip3 install -r $COMFYUI_ROOT/requirements.txt
pip install -r requirements.txt
# Install additional ComfyUI dependencies
if [ -f "comfyui/requirements.txt" ]; then
if [ -f "$AI_ROOT/comfyui/requirements.txt" ]; then
echo "Installing additional ComfyUI dependencies..."
sudo pip3 install -r comfyui/requirements.txt
pip install -r $AI_ROOT/comfyui/requirements.txt
fi
# Install common extension dependencies
echo "Installing common extension dependencies..."
pip install GitPython opencv-python-headless diffusers insightface onnxruntime
deactivate
cd $AI_ROOT
# Create model directory structure
echo "Creating ComfyUI model directories..."
mkdir -p $COMFYUI_ROOT/models/{checkpoints,unet,vae,loras,clip,clip_vision,controlnet,ipadapter,embeddings,upscale_models,video_models,animatediff_models,animatediff_motion_lora,audio_models,configs,diffusers,diffusion_models}
mkdir -p $COMFYUI_ROOT/models/{checkpoints,unet,vae,loras,clip,clip_vision,controlnet,ipadapter,embeddings,upscale_models,video_models,animatediff_models,animatediff_motion_lora,audio_models,configs,diffusers,diffusion_models,musicgen}
# Create symlink to huggingface cache
echo "Creating symlink to HuggingFace cache..."

View File

@@ -16,12 +16,20 @@ export TQDM_DISABLE=1
# Navigate to ComfyUI directory
cd "${COMFYUI_DIR}" || exit 1
# Activate virtual environment
if [ -d "venv" ]; then
echo "Activating ComfyUI virtual environment..."
source venv/bin/activate
else
echo "WARNING: venv not found, using system Python"
fi
echo "Starting ComfyUI on port 8188..."
echo "Access at: http://localhost:8188"
echo "Using HuggingFace cache: ${HF_CACHE}"
# Start ComfyUI with GPU support
python3 main.py \
python main.py \
--listen 0.0.0.0 \
--port 8188 \
--enable-cors-header \