Implemented runners for 3 different OS

This commit is contained in:
TheUnfocused 2024-08-04 10:42:17 -07:00
parent 84e89c5a01
commit 75b0f4ad82
11 changed files with 101 additions and 35 deletions

5
.gitignore vendored
View File

@ -19,3 +19,8 @@ venv/
/user/ /user/
*.log *.log
web_custom_versions/ web_custom_versions/
*.txt
*.deb*
.venv/*
*mycreds.txt*
*client_secrets.json*

View File

@ -17,15 +17,9 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"#@title Environment Setup\n",
"\n",
"import argparse\n",
"from pathlib import Path\n",
"from google.colab import drive\n", "from google.colab import drive\n",
"\n", "\n",
"parser = argparse.ArgumentParser()\n", "BRANCH_NAME = \"master\" # FILL THIS WITH YOUR BRANCH NAME\n",
"parser.add_argument('-b', '--branch', help=\"Mandatory branch name to checkout and run\", type=str)\n",
"args = parser.parse_args()\n",
"\n", "\n",
"WORKSPACE = 'ComfyUI'\n", "WORKSPACE = 'ComfyUI'\n",
"\n", "\n",
@ -44,7 +38,7 @@
"\n", "\n",
"!echo \"Updating ComfyUI...\"\n", "!echo \"Updating ComfyUI...\"\n",
"!git fetch\n", "!git fetch\n",
"!git checkout args.branch\n", "!git checkout BRANCH_NAME\n",
"!git pull\n", "!git pull\n",
"\n", "\n",
"!echo \"Install pip dependencies...\"\n", "!echo \"Install pip dependencies...\"\n",

48
connect_to_colab.py Normal file
View File

@ -0,0 +1,48 @@
import webbrowser
from pydrive.drive import GoogleDrive
from pydrive.auth import GoogleAuth
gauth = GoogleAuth()
gauth.LoadCredentialsFile("mycreds.txt")
if gauth.credentials is None:
gauth.LocalWebserverAuth()
elif gauth.access_token_expired:
gauth.Refresh()
else:
gauth.Authorize()
gauth.SaveCredentialsFile("mycreds.txt")
drive = GoogleDrive(gauth)
notebook_name = "colab_runner.ipynb"
# Delete the files with the same name (clear the cache)
file_list = drive.ListFile({'q': f"title='{notebook_name}'"}).GetList()
if file_list:
for file in file_list:
file.Trash()
file.UnTrash()
file.Delete()
# Create the new updated file and run it
notebook_path = "./{}".format(notebook_name)
notebook_file = drive.CreateFile({ 'title': notebook_name })
notebook_file.SetContentFile(notebook_path)
notebook_file.Upload()
notebook_file = None
# Print all the existing files and go to the last one on
# the list, hoping it is the most recent one
file_list = drive.ListFile({'q': "title='{}'".format(notebook_name)}).GetList()
if file_list:
for file in file_list:
print("Found file: {0} with ID: {1}".format(file['title'], file['id']))
file_id = file_list[-1]['id']
colab_url = "https://colab.research.google.com/drive/{}".format(file_id)
print("Opening notebook: {}".format(colab_url))
if webbrowser.open(colab_url):
print("Check your browser!")
else:
print("Couldn't open the browser!")

View File

@ -1,10 +0,0 @@
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)

9
install_required_mac.sh Normal file → Executable file
View File

@ -5,7 +5,9 @@ if command -v brew >/dev/null 2>&1; then
echo "Homebrew is already installed." echo "Homebrew is already installed."
else else
echo "Installing Homebrew..." echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "Homebrew has been installed." echo "Homebrew has been installed."
fi fi
@ -14,7 +16,9 @@ if command -v git >/dev/null 2>&1; then
echo "Git is already installed." echo "Git is already installed."
else else
echo "Installing GIT..." echo "Installing GIT..."
brew install git brew install git
echo "Git has been installed." echo "Git has been installed."
fi fi
@ -23,8 +27,10 @@ if command -v python3 >/dev/null 2>&1; then
echo "Python3.8 is already installed." echo "Python3.8 is already installed."
else else
echo "Installing Python3.8..." echo "Installing Python3.8..."
brew install pyenv brew install pyenv
pyenv install 3.8 pyenv install 3.8
echo "Python3.8 has been installed." echo "Python3.8 has been installed."
fi fi
@ -37,13 +43,10 @@ else
CUDA_VERSION="11.8" CUDA_VERSION="11.8"
CUDA_INSTALLER="cuda_${CUDA_VERSION}_mac.dmg" CUDA_INSTALLER="cuda_${CUDA_VERSION}_mac.dmg"
CUDA_URL="https://developer.download.nvidia.com/compute/cuda/${CUDA_VERSION}/local_installers/${CUDA_INSTALLER}" CUDA_URL="https://developer.download.nvidia.com/compute/cuda/${CUDA_VERSION}/local_installers/${CUDA_INSTALLER}"
curl -LO ${CUDA_URL} curl -LO ${CUDA_URL}
hdiutil mount ${CUDA_INSTALLER} hdiutil mount ${CUDA_INSTALLER}
sudo installer -pkg /Volumes/CUDA\ ${CUDA_VERSION}/CUDA.pkg -target / sudo installer -pkg /Volumes/CUDA\ ${CUDA_VERSION}/CUDA.pkg -target /
hdiutil unmount /Volumes/CUDA\ ${CUDA_VERSION} hdiutil unmount /Volumes/CUDA\ ${CUDA_VERSION}
rm ${CUDA_INSTALLER} rm ${CUDA_INSTALLER}
echo "CUDA has been installed." echo "CUDA has been installed."

20
install_required_ubuntu.sh Normal file → Executable file
View File

@ -5,8 +5,10 @@ if command -v git >/dev/null 2>&1; then
echo "Git is already installed." echo "Git is already installed."
else else
echo "Git is not installed. Installing..." echo "Git is not installed. Installing..."
sudo apt update sudo apt update
sudo apt install -y git sudo apt install -y git
echo "Git has been installed." echo "Git has been installed."
fi fi
@ -15,8 +17,10 @@ if command -v python3 >/dev/null 2>&1; then
echo "Python3.8 is already installed." echo "Python3.8 is already installed."
else else
echo "Installing Python3.8..." echo "Installing Python3.8..."
sudo apt-get update sudo apt-get update
sudo apt-get install -y python3.8 sudo apt-get install -y python3.8
echo "Python3.8 has been installed." echo "Python3.8 has been installed."
fi fi
@ -25,8 +29,10 @@ if nvidia-smi >/dev/null 2>&1; then
echo "NVIDIA drivers are already installed." echo "NVIDIA drivers are already installed."
else else
echo "Installing NVIDIA driver..." echo "Installing NVIDIA driver..."
sudo apt update sudo apt update
sudo apt install -y nvidia-driver-535 sudo apt install -y nvidia-driver-535
echo "NVIDIA driver has been installed." echo "NVIDIA driver has been installed."
fi fi
@ -35,10 +41,14 @@ if command -v nvcc >/dev/null 2>&1; then
echo "CUDA is already installed." echo "CUDA is already installed."
else else
echo "Installing CUDA..." 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 wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7fa2af80 sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt update wget https://developer.download.nvidia.com/compute/cuda/12.6.0/local_installers/cuda-repo-ubuntu2204-12-6-local_12.6.0-560.28.03-1_amd64.deb
sudo apt install -y cuda sudo dpkg -i cuda-repo-ubuntu2204-12-6-local_12.6.0-560.28.03-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2204-12-6-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-6
echo "CUDA installed." echo "CUDA installed."
fi fi

9
install_required_win.bat Normal file → Executable file
View File

@ -1,4 +1,3 @@
@echo off
setlocal setlocal
REM Function to check if Git is installed REM Function to check if Git is installed
@ -12,9 +11,7 @@ if %ERRORLEVEL% == 0 (
set "gitInstaller=Git-2.42.0-64-bit.exe" 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%" 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%'" powershell -Command "Invoke-WebRequest -Uri '%gitUrl%' -OutFile '%gitInstaller%'"
start /wait %gitInstaller% /VERYSILENT start /wait %gitInstaller% /VERYSILENT
del %gitInstaller% del %gitInstaller%
echo Git has been installed. echo Git has been installed.
@ -27,11 +24,13 @@ if %ERRORLEVEL% EQU 0 (
echo Python3.8 is already installed. echo Python3.8 is already installed.
) else ( ) else (
echo Python3.8 is not installed. Installing... 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_URL=https://www.python.org/ftp/python/3.8.0/python-3.8.0a1-amd64.exe
set PYTHON_INSTALLER=python_installer.exe set PYTHON_INSTALLER=python_installer.exe
powershell -Command "Invoke-WebRequest -Uri %PYTHON_INSTALLER_URL% -OutFile %PYTHON_INSTALLER%" powershell -Command "Invoke-WebRequest -Uri %PYTHON_INSTALLER_URL% -OutFile %PYTHON_INSTALLER%"
%PYTHON_INSTALLER% /quiet InstallAllUsers=1 PrependPath=1 %PYTHON_INSTALLER% /quiet InstallAllUsers=1 PrependPath=1
del %PYTHON_INSTALLER% del %PYTHON_INSTALLER%
echo Python3.8 has been installed. echo Python3.8 has been installed.
) )
@ -46,9 +45,7 @@ if %ERRORLEVEL% == 0 (
set "nvidiaDriverInstaller= NVIDIA-Driver-531.41-Win10-Win11-64Bit-English.exe" set "nvidiaDriverInstaller= NVIDIA-Driver-531.41-Win10-Win11-64Bit-English.exe"
set "nvidiaDriverUrl=https://download.nvidia.com/Windows/531.41/%nvidiaDriverInstaller%" set "nvidiaDriverUrl=https://download.nvidia.com/Windows/531.41/%nvidiaDriverInstaller%"
powershell -Command "Invoke-WebRequest -Uri '%nvidiaDriverUrl%' -OutFile '%nvidiaDriverInstaller%'" powershell -Command "Invoke-WebRequest -Uri '%nvidiaDriverUrl%' -OutFile '%nvidiaDriverInstaller%'"
start /wait %nvidiaDriverInstaller% -s start /wait %nvidiaDriverInstaller% -s
del %nvidiaDriverInstaller% del %nvidiaDriverInstaller%
echo NVIDIA driver has been installed. echo NVIDIA driver has been installed.
@ -65,9 +62,7 @@ if exist "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin\nvcc.exe"
set "cudaInstaller=cuda_11.8.0_windows.exe" set "cudaInstaller=cuda_11.8.0_windows.exe"
set "cudaUrl=https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/%cudaInstaller%" set "cudaUrl=https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/%cudaInstaller%"
powershell -Command "Invoke-WebRequest -Uri '%cudaUrl%' -OutFile '%cudaInstaller%'" powershell -Command "Invoke-WebRequest -Uri '%cudaUrl%' -OutFile '%cudaInstaller%'"
start /wait %cudaInstaller% /S start /wait %cudaInstaller% /S
del %cudaInstaller% del %cudaInstaller%
echo CUDA has been installed. echo CUDA has been installed.

View File

@ -13,6 +13,7 @@ Pillow
scipy scipy
tqdm tqdm
psutil psutil
pydrive
#non essential dependencies: #non essential dependencies:
kornia>=0.7.1 kornia>=0.7.1

9
run_colab_mac.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/zsh
echo "Make sure you set up your branch name in colab_runner.ipynb"
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install pydrive
sudo python3 connect_to_colab.py
deactivate

4
run_colab_ubuntu.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
echo "Make sure you set up your branch name in colab_runner.ipynb"
python3 -m venv .venv && source .venv/bin/activate && python3 -m pip install pydrive && sudo python3 connect_to_colab.py && deactivate

7
run_colab_win.bat Normal file
View File

@ -0,0 +1,7 @@
echo Make sure you set up your branch name in colab_runner.ipynb
python -m venv .venv
call .venv\Scripts\activate.bat
python -m pip install pydrive
python connect_to_colab.py
deactivate