diff --git a/notebooks/comfyui_colab.ipynb b/colab_runner.ipynb similarity index 85% rename from notebooks/comfyui_colab.ipynb rename to colab_runner.ipynb index ec83265b4..971c34859 100644 --- a/notebooks/comfyui_colab.ipynb +++ b/colab_runner.ipynb @@ -19,34 +19,35 @@ "source": [ "#@title Environment Setup\n", "\n", + "import argparse\n", "from pathlib import Path\n", + "from google.colab import drive\n", "\n", - "OPTIONS = {}\n", + "parser = argparse.ArgumentParser()\n", + "parser.add_argument('-b', '--branch', help=\"Mandatory branch name to checkout and run\", type=str)\n", + "args = parser.parse_args()\n", "\n", - "USE_GOOGLE_DRIVE = False #@param {type:\"boolean\"}\n", - "UPDATE_COMFY_UI = True #@param {type:\"boolean\"}\n", "WORKSPACE = 'ComfyUI'\n", - "OPTIONS['USE_GOOGLE_DRIVE'] = USE_GOOGLE_DRIVE\n", - "OPTIONS['UPDATE_COMFY_UI'] = UPDATE_COMFY_UI\n", "\n", - "if OPTIONS['USE_GOOGLE_DRIVE']:\n", - " !echo \"Mounting Google Drive...\"\n", - " %cd /\n", + "!echo \"Mounting Google Drive...\"\n", + "%cd /\n", " \n", - " from google.colab import drive\n", - " drive.mount('/content/drive')\n", + "drive.mount('/content/drive')\n", "\n", - " WORKSPACE = \"/content/drive/MyDrive/ComfyUI\"\n", - " %cd /content/drive/MyDrive\n", + "WORKSPACE = \"/content/drive/MyDrive/ComfyUI\"\n", + "%cd /content/drive/MyDrive\n", "\n", - "![ ! -d $WORKSPACE ] && echo -= Initial setup ComfyUI =- && git clone https://github.com/comfyanonymous/ComfyUI\n", + "![ ! -d $WORKSPACE ] \n", + "!echo \"Installing ComfyUI...\"\n", + "!git clone https://github.com/AdminGENARC-I/ComfyUI.git\n", "%cd $WORKSPACE\n", "\n", - "if OPTIONS['UPDATE_COMFY_UI']:\n", - " !echo -= Updating ComfyUI =-\n", - " !git pull\n", + "!echo \"Updating ComfyUI...\"\n", + "!git fetch\n", + "!git checkout args.branch\n", + "!git pull\n", "\n", - "!echo -= Install dependencies =-\n", + "!echo \"Install pip dependencies...\"\n", "!pip install xformers!=0.0.18 -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu121 --extra-index-url https://download.pytorch.org/whl/cu118 --extra-index-url https://download.pytorch.org/whl/cu117" ] }, @@ -264,50 +265,6 @@ "\n", "!python main.py --dont-print-server" ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "gggggggggg" - }, - "source": [ - "### Run ComfyUI with colab iframe (use only in case the previous way with localtunnel doesn't work)\n", - "\n", - "You should see the ui appear in an iframe. If you get a 403 error, it's your firefox settings or an extension that's messing things up.\n", - "\n", - "If you want to open it in another window use the link.\n", - "\n", - "Note that some UI features like live image previews won't work because the colab iframe blocks websockets." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "hhhhhhhhhh" - }, - "outputs": [], - "source": [ - "import threading\n", - "import time\n", - "import socket\n", - "def iframe_thread(port):\n", - " while True:\n", - " time.sleep(0.5)\n", - " sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n", - " result = sock.connect_ex(('127.0.0.1', port))\n", - " if result == 0:\n", - " break\n", - " sock.close()\n", - " from google.colab import output\n", - " output.serve_kernel_port_as_iframe(port, height=1024)\n", - " print(\"to open it in a window you can open this link here:\")\n", - " output.serve_kernel_port_as_window(port)\n", - "\n", - "threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n", - "\n", - "!python main.py --dont-print-server" - ] } ], "metadata": { diff --git a/comfyui_screenshot.png b/comfyui_screenshot.png deleted file mode 100644 index 73272eae6..000000000 Binary files a/comfyui_screenshot.png and /dev/null differ diff --git a/connect_to_collab.py b/connect_to_collab.py new file mode 100644 index 000000000..55b4cfa7b --- /dev/null +++ b/connect_to_collab.py @@ -0,0 +1,10 @@ +import shutil +from google.colab import drive, notebooks + +drive.mount('/content/drive') + +local_file_path = "./colab_runner.ipynb" +drive_file_path = '/content/drive/MyDrive/colab_runner.ipynb' +shutil.copy(local_file_path, drive_file_path) + +notebooks.run_notebook(drive_file_path) \ No newline at end of file diff --git a/install_required_mac.sh b/install_required_mac.sh new file mode 100644 index 000000000..ea81ad272 --- /dev/null +++ b/install_required_mac.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Check for Homebrew +if command -v brew >/dev/null 2>&1; then + echo "Homebrew is already installed." +else + echo "Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + echo "Homebrew has been installed." +fi + +# Check for git +if command -v git >/dev/null 2>&1; then + echo "Git is already installed." +else + echo "Installing GIT..." + brew install git + echo "Git has been installed." +fi + +# Check for Python3.8 +if command -v python3 >/dev/null 2>&1; then + echo "Python3.8 is already installed." +else + echo "Installing Python3.8..." + brew install pyenv + pyenv install 3.8 + echo "Python3.8 has been installed." +fi + +# Check for CUDA +if command -v nvcc >/dev/null 2>&1; then + echo "CUDA is already installed." +else + echo "Installing CUDA..." + + CUDA_VERSION="11.8" + CUDA_INSTALLER="cuda_${CUDA_VERSION}_mac.dmg" + CUDA_URL="https://developer.download.nvidia.com/compute/cuda/${CUDA_VERSION}/local_installers/${CUDA_INSTALLER}" + + curl -LO ${CUDA_URL} + + hdiutil mount ${CUDA_INSTALLER} + sudo installer -pkg /Volumes/CUDA\ ${CUDA_VERSION}/CUDA.pkg -target / + hdiutil unmount /Volumes/CUDA\ ${CUDA_VERSION} + + rm ${CUDA_INSTALLER} + + echo "CUDA has been installed." +fi \ No newline at end of file diff --git a/install_required_ubuntu.sh b/install_required_ubuntu.sh new file mode 100644 index 000000000..703c52f64 --- /dev/null +++ b/install_required_ubuntu.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Check for git +if command -v git >/dev/null 2>&1; then + echo "Git is already installed." +else + echo "Git is not installed. Installing..." + sudo apt update + sudo apt install -y git + echo "Git has been installed." +fi + +# Check for Python3.8 +if command -v python3 >/dev/null 2>&1; then + echo "Python3.8 is already installed." +else + echo "Installing Python3.8..." + sudo apt-get update + sudo apt-get install -y python3.8 + echo "Python3.8 has been installed." +fi + +# Check for NVIDIA drivers +if nvidia-smi >/dev/null 2>&1; then + echo "NVIDIA drivers are already installed." +else + echo "Installing NVIDIA driver..." + sudo apt update + sudo apt install -y nvidia-driver-535 + echo "NVIDIA driver has been installed." +fi + +# Check for CUDA +if command -v nvcc >/dev/null 2>&1; then + echo "CUDA is already installed." +else + echo "Installing CUDA..." + wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu$(lsb_release -rs)/x86_64/cuda-repo-ubuntu$(lsb_release -rs)_12.2.0-1_amd64.deb + sudo dpkg -i cuda-repo-ubuntu$(lsb_release -rs)_12.2.0-1_amd64.deb + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7fa2af80 + sudo apt update + sudo apt install -y cuda + echo "CUDA installed." +fi \ No newline at end of file diff --git a/install_required_win.bat b/install_required_win.bat new file mode 100644 index 000000000..e432cd77e --- /dev/null +++ b/install_required_win.bat @@ -0,0 +1,82 @@ +@echo off +setlocal + +REM Function to check if Git is installed +:CheckGit +where git >nul 2>&1 +if %ERRORLEVEL% == 0 ( + echo Git is already installed. +) else ( + echo Git is not installed. Installing... + + set "gitInstaller=Git-2.42.0-64-bit.exe" + set "gitUrl=https://github.com/git-for-windows/git/releases/download/v2.42.0.windows.1/%gitInstaller%" + powershell -Command "Invoke-WebRequest -Uri '%gitUrl%' -OutFile '%gitInstaller%'" + + start /wait %gitInstaller% /VERYSILENT + + del %gitInstaller% + + echo Git has been installed. +) +goto :eof + +REM Check if Python is installed +python --version >nul 2>&1 +if %ERRORLEVEL% EQU 0 ( + echo Python3.8 is already installed. +) else ( + echo Python3.8 is not installed. Installing... + set PYTHON_INSTALLER_URL=https://www.python.org/ftp/python/3.8.0/python-3.8.0a1-amd64.exe + set PYTHON_INSTALLER=python_installer.exe + powershell -Command "Invoke-WebRequest -Uri %PYTHON_INSTALLER_URL% -OutFile %PYTHON_INSTALLER%" + %PYTHON_INSTALLER% /quiet InstallAllUsers=1 PrependPath=1 + del %PYTHON_INSTALLER% + echo Python3.8 has been installed. +) + +REM Function to check if NVIDIA drivers are installed +:CheckNvidiaDriver +wmic path Win32_PnPSignedDriver get DeviceName | find /i "NVIDIA" >nul +if %ERRORLEVEL% == 0 ( + echo NVIDIA driver is already installed. +) else ( + echo NVIDIA driver is not installed. Installing... + + set "nvidiaDriverInstaller= NVIDIA-Driver-531.41-Win10-Win11-64Bit-English.exe" + set "nvidiaDriverUrl=https://download.nvidia.com/Windows/531.41/%nvidiaDriverInstaller%" + powershell -Command "Invoke-WebRequest -Uri '%nvidiaDriverUrl%' -OutFile '%nvidiaDriverInstaller%'" + + start /wait %nvidiaDriverInstaller% -s + + del %nvidiaDriverInstaller% + + echo NVIDIA driver has been installed. +) +goto :eof + +REM Function to check if CUDA is installed +:CheckCUDA +if exist "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin\nvcc.exe" ( + echo CUDA is already installed. +) else ( + echo CUDA is not installed. Installing... + + set "cudaInstaller=cuda_11.8.0_windows.exe" + set "cudaUrl=https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/%cudaInstaller%" + powershell -Command "Invoke-WebRequest -Uri '%cudaUrl%' -OutFile '%cudaInstaller%'" + + start /wait %cudaInstaller% /S + + del %cudaInstaller% + + echo CUDA has been installed. +) +goto :eof + +call :CheckGit +call :CheckNvidiaDriver +call :CheckCUDA + +endlocal +pause