#!/bin/bash # Function to check if a command exists command_exists() { command -v "$1" >/dev/null 2>&1 } # Create installation directory mkdir -p comfyui-installer cd comfyui-installer # Install required packages if not present echo "Checking and installing required packages..." if ! command_exists curl; then sudo yum update -y && sudo yum install -y curl fi if ! command_exists git; then sudo yum install -y git fi # Download and install Miniconda if not exists if [ ! -d "miniconda3" ]; then echo "Downloading Miniconda..." curl -L -o miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh if [ $? -ne 0 ]; then echo "Error downloading Miniconda. Please check your internet connection and try again." exit 1 fi echo "Installing Miniconda..." bash miniconda.sh -b -p $PWD/miniconda3 rm miniconda.sh fi # Add Miniconda to PATH for this session export PATH="$PWD/miniconda3/bin:$PATH" # Create and activate conda environment echo "Creating conda environment for ComfyUI..." conda create -y -n comfyui-env python=3.10 # Activate the conda environment in the script (using 'source') source activate comfyui-env # Clone ComfyUI repositories echo "Cloning ComfyUI and dependencies..." git clone https://github.com/comfyanonymous/ComfyUI.git cd ComfyUI git clone https://github.com/ltdrdata/ComfyUI-Manager.git custom_nodes/ComfyUI-Manager git clone https://github.com/rgthree/rgthree-comfy.git custom_nodes/rgthree-comfy git clone https://github.com/kijai/ComfyUI-FluxTrainer.git custom_nodes/ComfyUI-FluxTrainer git clone https://github.com/LarryJane491/Image-Captioning-in-ComfyUI.git custom_nodes/Image-Captioning-in-ComfyUI git clone https://github.com/kijai/ComfyUI-KJNodes.git custom_nodes/ComfyUI-KJNodes git clone https://github.com/WASasquatch/was-node-suite-comfyui.git custom_nodes/was-node-suite-comfyui cd .. # Install Python requirements for ComfyUI within the activated environment echo "Installing ComfyUI Python requirements..." cd ComfyUI # Ensure pip is using the correct version for the activated environment. pip install --upgrade pip # Upgrade pip to the latest version in case it's outdated. pip install -r requirements.txt pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 pip install -r ./custom_nodes/ComfyUI-Manager/requirements.txt pip install -r ./custom_nodes/ComfyUI-FluxTrainer/requirements.txt pip install -r ./custom_nodes/ComfyUI-KJNodes/requirements.txt pip install -r ./custom_nodes/rgthree-comfy/requirements.txt pip install -r ./custom_nodes/was-node-suite-comfyui/requirements.txt cd .. # Create start-comfyui.sh script to run ComfyUI easily later on. echo "Creating start-comfyui.sh script..." cat > start-comfyui.sh << 'EOF' #!/bin/bash cd "$(dirname "$0")/ComfyUI" source ../miniconda3/bin/activate comfyui-env # Activate the environment when starting ComfyUI. python main.py --listen # Start ComfyUI. EOF chmod +x start-comfyui.sh echo "Installation completed successfully!" echo "To start ComfyUI, run ./start-comfyui.sh from the comfyui-installer directory." echo "ComfyUI will be accessible at http://your_server_ip:8188" pause