diff --git a/.gitignore b/.gitignore index 5092c98f4..7779bbc03 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,9 @@ venv/ /tests-ui/data/object_info.json /user/ *.log -web_custom_versions/ \ No newline at end of file +web_custom_versions/ +*.txt +*.deb* +.venv/* +*mycreds.txt* +*client_secrets.json* diff --git a/colab_runner.ipynb b/colab_runner.ipynb index 971c34859..edc1a9509 100644 --- a/colab_runner.ipynb +++ b/colab_runner.ipynb @@ -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", diff --git a/connect_to_colab.py b/connect_to_colab.py new file mode 100644 index 000000000..3baf859af --- /dev/null +++ b/connect_to_colab.py @@ -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!") \ No newline at end of file diff --git a/connect_to_collab.py b/connect_to_collab.py deleted file mode 100644 index 55b4cfa7b..000000000 --- a/connect_to_collab.py +++ /dev/null @@ -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) \ No newline at end of file diff --git a/install_required_mac.sh b/install_required_mac.sh old mode 100644 new mode 100755 index ea81ad272..2bdb7597d --- a/install_required_mac.sh +++ b/install_required_mac.sh @@ -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." diff --git a/install_required_ubuntu.sh b/install_required_ubuntu.sh old mode 100644 new mode 100755 index 703c52f64..405a3d99c --- a/install_required_ubuntu.sh +++ b/install_required_ubuntu.sh @@ -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 \ No newline at end of file +fi diff --git a/install_required_win.bat b/install_required_win.bat old mode 100644 new mode 100755 index e432cd77e..6995c1413 --- a/install_required_win.bat +++ b/install_required_win.bat @@ -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. diff --git a/requirements.txt b/requirements.txt index 4c2c0b2b2..1ef849c12 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,6 +13,7 @@ Pillow scipy tqdm psutil +pydrive #non essential dependencies: kornia>=0.7.1 diff --git a/run_colab_mac.sh b/run_colab_mac.sh new file mode 100644 index 000000000..33364663e --- /dev/null +++ b/run_colab_mac.sh @@ -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 diff --git a/run_colab_ubuntu.sh b/run_colab_ubuntu.sh new file mode 100755 index 000000000..ded86964c --- /dev/null +++ b/run_colab_ubuntu.sh @@ -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 \ No newline at end of file diff --git a/run_colab_win.bat b/run_colab_win.bat new file mode 100644 index 000000000..bc6677632 --- /dev/null +++ b/run_colab_win.bat @@ -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