Implemented somewhat working installers and runners

This commit is contained in:
TheUnfocused 2024-08-03 12:08:11 -07:00
parent ba9095e5bd
commit 84e89c5a01
6 changed files with 204 additions and 61 deletions

View File

@ -19,34 +19,35 @@
"source": [ "source": [
"#@title Environment Setup\n", "#@title Environment Setup\n",
"\n", "\n",
"import argparse\n",
"from pathlib import Path\n", "from pathlib import Path\n",
"from google.colab import drive\n",
"\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", "\n",
"USE_GOOGLE_DRIVE = False #@param {type:\"boolean\"}\n",
"UPDATE_COMFY_UI = True #@param {type:\"boolean\"}\n",
"WORKSPACE = 'ComfyUI'\n", "WORKSPACE = 'ComfyUI'\n",
"OPTIONS['USE_GOOGLE_DRIVE'] = USE_GOOGLE_DRIVE\n",
"OPTIONS['UPDATE_COMFY_UI'] = UPDATE_COMFY_UI\n",
"\n", "\n",
"if OPTIONS['USE_GOOGLE_DRIVE']:\n", "!echo \"Mounting Google Drive...\"\n",
" !echo \"Mounting Google Drive...\"\n", "%cd /\n",
" %cd /\n",
" \n", " \n",
" from google.colab import drive\n", "drive.mount('/content/drive')\n",
" drive.mount('/content/drive')\n",
"\n", "\n",
" WORKSPACE = \"/content/drive/MyDrive/ComfyUI\"\n", "WORKSPACE = \"/content/drive/MyDrive/ComfyUI\"\n",
" %cd /content/drive/MyDrive\n", "%cd /content/drive/MyDrive\n",
"\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", "%cd $WORKSPACE\n",
"\n", "\n",
"if OPTIONS['UPDATE_COMFY_UI']:\n", "!echo \"Updating ComfyUI...\"\n",
" !echo -= Updating ComfyUI =-\n", "!git fetch\n",
" !git pull\n", "!git checkout args.branch\n",
"!git pull\n",
"\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" "!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", "\n",
"!python main.py --dont-print-server" "!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": { "metadata": {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

10
connect_to_collab.py Normal file
View File

@ -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)

50
install_required_mac.sh Normal file
View File

@ -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

View File

@ -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

82
install_required_win.bat Normal file
View File

@ -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