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/
*.log
web_custom_versions/
*.txt
*.deb*
.venv/*
*mycreds.txt*
*client_secrets.json*

View File

@ -17,15 +17,9 @@
},
"outputs": [],
"source": [
"#@title Environment Setup\n",
"\n",
"import argparse\n",
"from pathlib import Path\n",
"from google.colab import drive\n",
"\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",
"BRANCH_NAME = \"master\" # FILL THIS WITH YOUR BRANCH NAME\n",
"\n",
"WORKSPACE = 'ComfyUI'\n",
"\n",
@ -44,7 +38,7 @@
"\n",
"!echo \"Updating ComfyUI...\"\n",
"!git fetch\n",
"!git checkout args.branch\n",
"!git checkout BRANCH_NAME\n",
"!git pull\n",
"\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."
else
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "Homebrew has been installed."
fi
@ -14,7 +16,9 @@ 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
@ -23,8 +27,10 @@ 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
@ -37,13 +43,10 @@ else
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."

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."
else
echo "Git is not installed. Installing..."
sudo apt update
sudo apt install -y git
echo "Git has been installed."
fi
@ -15,8 +17,10 @@ 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
@ -25,8 +29,10 @@ 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
@ -35,10 +41,14 @@ 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
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
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 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."
fi

9
install_required_win.bat Normal file → Executable file
View File

@ -1,4 +1,3 @@
@echo off
setlocal
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 "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.
@ -27,11 +24,13 @@ 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.
)
@ -46,9 +45,7 @@ if %ERRORLEVEL% == 0 (
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.
@ -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 "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.

View File

@ -13,6 +13,7 @@ Pillow
scipy
tqdm
psutil
pydrive
#non essential dependencies:
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