From 1c946561d3b6419f2b3a74b76721ac56b61d645b Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 16:38:06 +0530 Subject: [PATCH 01/57] 1-click installer using micromamba to install git and python into a contained environment (if necessary) before running the normal installation script --- installer/How to create the installers.md | 51 ++++++++++++++ installer/install.bat | 80 +++++++++++++++++++++ installer/install.sh | 85 +++++++++++++++++++++++ invoke.bat | 29 ++++++++ invoke.sh | 27 +++++++ update.bat | 11 +++ update.sh | 10 +++ 7 files changed, 293 insertions(+) create mode 100644 installer/How to create the installers.md create mode 100644 installer/install.bat create mode 100644 installer/install.sh create mode 100644 invoke.bat create mode 100644 invoke.sh create mode 100644 update.bat create mode 100644 update.sh diff --git a/installer/How to create the installers.md b/installer/How to create the installers.md new file mode 100644 index 0000000000..7089f7929a --- /dev/null +++ b/installer/How to create the installers.md @@ -0,0 +1,51 @@ +The installer zip contains two files: the script, and the micromamba binary. + +Micromamba is a single ~8mb binary file, that acts like a package manager (drop-in replacement for conda). + +# Download micromamba from: +* Windows x64: `curl -Ls https://micro.mamba.pm/api/micromamba/win-64/latest | tar -xvj bin/micromamba_win_x64.exe` + +* Linux x64: `curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba_linux_x64` +* Linux arm64: `curl -Ls https://micro.mamba.pm/api/micromamba/linux-aarch64/latest | tar -xvj bin/micromamba_linux_arm64` + +* Mac x64: `curl -Ls https://micro.mamba.pm/api/micromamba/osx-64/latest | tar -xvj bin/micromamba_mac_x64` +* Mac arm64 (M1/Apple Silicon): `curl -Ls https://micro.mamba.pm/api/micromamba/osx-arm64/latest | tar -xvj bin/micromamba_mac_arm64` + +The download link provides tar.bz2 files. + +(source https://mamba.readthedocs.io/en/latest/installation.html) + +# Create the installer +Create the following folder structure, and zip it up. + +For Linux/Mac: Make sure the `chmod u+x` permission is granted to `installer.sh` and the corresponding `micromamba` binary. + +### Windows x64: +``` +.\installer.bat +.\installer_files\micromamba_win_x64.exe +``` + +### Linux x64: +``` +.\installer.sh +.\installer_files\micromamba_linux_x64 +``` + +### Linux arm64: +``` +.\installer.sh +.\installer_files\micromamba_linux_arm64 +``` + +### Mac x64: +``` +.\installer.sh +.\installer_files\micromamba_mac_x64 +``` + +### Mac arm64 (M1/Apple Silicon): +``` +.\installer.sh +.\installer_files\micromamba_mac_arm64 +``` \ No newline at end of file diff --git a/installer/install.bat b/installer/install.bat new file mode 100644 index 0000000000..806e6ea745 --- /dev/null +++ b/installer/install.bat @@ -0,0 +1,80 @@ +@echo off + +@rem This script will install git and python (if not found on the PATH variable) +@rem using micromamba (an 8mb static-linked single-file binary, conda replacement). +@rem For users who already have git and python, this step will be skipped. + +@rem Next, it'll checkout the project's git repo, if necessary. +@rem Finally, it'll create the conda environment and preload the models. + +@rem This enables a user to install this project without manually installing python and git. + +@rem prevent the window from closing after an error +if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) + +@rem config +set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba +set INSTALL_ENV_DIR=%cd%\installer_files\env +set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe +set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts + +@rem initialize micromamba +if not exist "%MAMBA_ROOT_PREFIX%" ( + mkdir "%MAMBA_ROOT_PREFIX%" + copy "%MICROMAMBA_BINARY_FILE%" "%MAMBA_ROOT_PREFIX%\micromamba.exe" + + @rem test the mamba binary + echo Micromamba version: + call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version + + @rem run the shell hook, otherwise activate will fail + if not exist "%MAMBA_ROOT_PREFIX%\Scripts" ( + call "%MAMBA_ROOT_PREFIX%\micromamba.exe" shell hook --log-level 4 -s cmd.exe + ) +) + +call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" + +@rem figure out whether git and python needs to be installed +set PACKAGES_TO_INSTALL= + +call python --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% python + +call git --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git + +@rem (if necessary) install git and python into a contained environment +if "%PACKAGES_TO_INSTALL%" NEQ "" ( + echo "Packages to install: %PACKAGES_TO_INSTALL%" + + @rem install git and python into the installer env + if not exist "%INSTALL_ENV_DIR%" ( + call micromamba create -y --prefix "%INSTALL_ENV_DIR%" + ) + + call micromamba install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL% + + @rem activate + call micromamba activate "%INSTALL_ENV_DIR%" +) + +@rem get the repo (and load into the current directory) +if not exist ".git" ( + call git init + call git remote add origin https://github.com/cmdr2/InvokeAI.git + call git fetch + call git checkout origin/main -ft +) + +@rem create the environment +call micromamba create -f environment.yml +call micromamba activate invokeai + +@rem preload the models +call python scripts\preload_models.py + +@rem make the models dir +mkdir models\ldm\stable-diffusion-v1 + +pause diff --git a/installer/install.sh b/installer/install.sh new file mode 100644 index 0000000000..569a4fc47a --- /dev/null +++ b/installer/install.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +# This script will install git and python (if not found on the PATH variable) +# using micromamba (an 8mb static-linked single-file binary, conda replacement). +# For users who already have git and python, this step will be skipped. + +# Next, it'll checkout the project's git repo, if necessary. +# Finally, it'll create the conda environment and preload the models. + +# This enables a user to install this project without manually installing python and git. + +OS_NAME=$(uname -s) +case "${OS_NAME}" in + Linux*) OS_NAME="linux";; + Darwin*) OS_NAME="mac";; + *) echo "Unknown OS: $OS_NAME! This script runs only on Linux or Mac" && exit +esac + +OS_ARCH=$(uname -m) +case "${OS_ARCH}" in + x86_64*) OS_ARCH="x64";; + arm64*) OS_ARCH="arm64";; + *) echo "Unknown system architecture: $OS_ARCH! This script runs only on x86_64 or arm64" && exit +esac + +# config +export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" +INSTALL_ENV_DIR="$(pwd)/installer_files/env" +MICROMAMBA_BINARY_FILE="$(pwd)/installer_files/micromamba_${OS_NAME}_${OS_ARCH}" +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi + +# initialize micromamba +mkdir -p "$MAMBA_ROOT_PREFIX" +cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" + +# test the mamba binary +echo Micromamba version: +"$MAMBA_ROOT_PREFIX/micromamba" --version + +# run the shell hook, otherwise activate will fail +eval "$($MAMBA_ROOT_PREFIX/micromamba shell hook -s posix)" + +# figure out what needs to be installed +PACKAGES_TO_INSTALL="" + +if ! hash "python" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL python"; fi +if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi + +# install git and python into a contained environment (if necessary) +if [ "$PACKAGES_TO_INSTALL" != "" ]; then + echo "Packages to install: $PACKAGES_TO_INSTALL" + + # install git and python into the installer env + if [ ! -e "$INSTALL_ENV_DIR" ]; then + micromamba create -y --prefix "$INSTALL_ENV_DIR" + fi + + micromamba install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL + + # activate + micromamba activate "$INSTALL_ENV_DIR" +fi + +# get the repo (and load into the current directory) +if [ ! -e ".git" ]; then + git init + git remote add origin https://github.com/cmdr2/InvokeAI.git + git fetch + git checkout origin/main -ft +fi + +# create the environment +if [ "$OS_NAME" == "mac" ]; then + PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 micromamba create -f environment-mac.yml +else + micromamba create -f environment.yml +fi + +micromamba activate invokeai + +# preload the models +python scripts/preload_models.py + +# make the models dir +mkdir -p models/ldm/stable-diffusion-v1 diff --git a/invoke.bat b/invoke.bat new file mode 100644 index 0000000000..ac5bcc4500 --- /dev/null +++ b/invoke.bat @@ -0,0 +1,29 @@ +@echo off + +@rem prevent the window from closing after running the commands +if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) + +@rem check if conda exists, otherwise use micromamba +set CONDA_COMMAND=conda + +call conda --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set CONDA_COMMAND=micromamba + +@rem initialize micromamba, if using that +if "%CONDA_COMMAND%" EQU "micromamba" ( + set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba + set INSTALL_ENV_DIR=%cd%\installer_files\env + + if not exist "%MAMBA_ROOT_PREFIX%\condabin" ( + echo "Have you run install.bat?" + exit /b + ) + + call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" + + call micromamba activate "%INSTALL_ENV_DIR%" +) + +call %CONDA_COMMAND% activate invokeai + +pause diff --git a/invoke.sh b/invoke.sh new file mode 100644 index 0000000000..e999923f40 --- /dev/null +++ b/invoke.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ "$0" == "bash" ]; then + # check if conda exists, otherwise use micromamba + CONDA_COMMAND="conda" + + if ! hash "conda" &>/dev/null; then CONDA_COMMAND="micromamba"; fi + + # initialize micromamba, if using that + if [ "$CONDA_COMMAND" == "micromamba" ]; then + export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" + INSTALL_ENV_DIR="$(pwd)/installer_files/env" + + if [ ! -e "$MAMBA_ROOT_PREFIX" ]; then + echo "Have you run install.sh?" + exit + fi + + eval "$($MAMBA_ROOT_PREFIX/micromamba shell hook -s posix)" + + micromamba activate "$INSTALL_ENV_DIR" + ) + + $CONDA_COMMAND activate invokeai +else + bash --init-file invoke.sh +fi diff --git a/update.bat b/update.bat new file mode 100644 index 0000000000..f346dce3e6 --- /dev/null +++ b/update.bat @@ -0,0 +1,11 @@ +@echo off + +set INSTALL_ENV_DIR=%cd%\installer_files\env +set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts + +@rem update the repo +if exist ".git" ( + call git pull +) + +pause \ No newline at end of file diff --git a/update.sh b/update.sh new file mode 100644 index 0000000000..7ec5bfcb8e --- /dev/null +++ b/update.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +INSTALL_ENV_DIR="$(pwd)/installer_files/env" + +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi + +# update the repo +if [ -e ".git" ]; then + git pull +fi From 1ec92dd5f3042e85a217f4d3ccbd0d9c4faac2e8 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 16:53:07 +0530 Subject: [PATCH 02/57] Check for missing python/git before activating micromamba --- installer/install.bat | 18 +++++++++--------- installer/install.sh | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index 806e6ea745..a1ca837607 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -18,6 +18,15 @@ set INSTALL_ENV_DIR=%cd%\installer_files\env set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts +@rem figure out whether git and python needs to be installed +set PACKAGES_TO_INSTALL= + +call python --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% python + +call git --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git + @rem initialize micromamba if not exist "%MAMBA_ROOT_PREFIX%" ( mkdir "%MAMBA_ROOT_PREFIX%" @@ -35,15 +44,6 @@ if not exist "%MAMBA_ROOT_PREFIX%" ( call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" -@rem figure out whether git and python needs to be installed -set PACKAGES_TO_INSTALL= - -call python --version "" >tmp/stdout.txt 2>tmp/stderr.txt -if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% python - -call git --version "" >tmp/stdout.txt 2>tmp/stderr.txt -if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git - @rem (if necessary) install git and python into a contained environment if "%PACKAGES_TO_INSTALL%" NEQ "" ( echo "Packages to install: %PACKAGES_TO_INSTALL%" diff --git a/installer/install.sh b/installer/install.sh index 569a4fc47a..6bf606497e 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -29,6 +29,12 @@ INSTALL_ENV_DIR="$(pwd)/installer_files/env" MICROMAMBA_BINARY_FILE="$(pwd)/installer_files/micromamba_${OS_NAME}_${OS_ARCH}" if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi +# figure out what needs to be installed +PACKAGES_TO_INSTALL="" + +if ! hash "python" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL python"; fi +if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi + # initialize micromamba mkdir -p "$MAMBA_ROOT_PREFIX" cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" @@ -40,12 +46,6 @@ echo Micromamba version: # run the shell hook, otherwise activate will fail eval "$($MAMBA_ROOT_PREFIX/micromamba shell hook -s posix)" -# figure out what needs to be installed -PACKAGES_TO_INSTALL="" - -if ! hash "python" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL python"; fi -if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi - # install git and python into a contained environment (if necessary) if [ "$PACKAGES_TO_INSTALL" != "" ]; then echo "Packages to install: $PACKAGES_TO_INSTALL" From af56aee5c68a8526bf18dda5a48fca6764e93e00 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 16:56:40 +0530 Subject: [PATCH 03/57] Create the env using -y --- installer/install.bat | 2 +- installer/install.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index a1ca837607..82af2b2ab7 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -68,7 +68,7 @@ if not exist ".git" ( ) @rem create the environment -call micromamba create -f environment.yml +call micromamba create -y -f environment.yml call micromamba activate invokeai @rem preload the models diff --git a/installer/install.sh b/installer/install.sh index 6bf606497e..5edf465902 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -71,9 +71,9 @@ fi # create the environment if [ "$OS_NAME" == "mac" ]; then - PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 micromamba create -f environment-mac.yml + PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 micromamba create -y -f environment-mac.yml else - micromamba create -f environment.yml + micromamba create -y -f environment.yml fi micromamba activate invokeai From 86b7b07c2496add072b2f5e0d816024bdf5bdf55 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 16:58:19 +0530 Subject: [PATCH 04/57] Make the linux/mac scripts executable --- installer/install.sh | 0 invoke.sh | 0 update.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 installer/install.sh mode change 100644 => 100755 invoke.sh mode change 100644 => 100755 update.sh diff --git a/installer/install.sh b/installer/install.sh old mode 100644 new mode 100755 diff --git a/invoke.sh b/invoke.sh old mode 100644 new mode 100755 diff --git a/update.sh b/update.sh old mode 100644 new mode 100755 From 8604fd27271aaeadea6df9af1995f59522b3e447 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 22:15:38 +0530 Subject: [PATCH 05/57] Updated the installer to simplify the use of micromamba, and use conda for the actual installation; Update conda during the update script --- installer/How to create the installers.md | 12 ++-- installer/install.bat | 67 +++++++++++----------- installer/install.sh | 70 +++++++++++++---------- invoke.bat | 26 ++------- invoke.sh | 23 ++------ update.bat | 2 + update.sh | 8 ++- 7 files changed, 96 insertions(+), 112 deletions(-) diff --git a/installer/How to create the installers.md b/installer/How to create the installers.md index 7089f7929a..9b76c61aba 100644 --- a/installer/How to create the installers.md +++ b/installer/How to create the installers.md @@ -18,34 +18,34 @@ The download link provides tar.bz2 files. # Create the installer Create the following folder structure, and zip it up. -For Linux/Mac: Make sure the `chmod u+x` permission is granted to `installer.sh` and the corresponding `micromamba` binary. +For Linux/Mac: Make sure the `chmod u+x` permission is granted to `install.sh` and the corresponding `micromamba` binary. ### Windows x64: ``` -.\installer.bat +.\install.bat .\installer_files\micromamba_win_x64.exe ``` ### Linux x64: ``` -.\installer.sh +.\install.sh .\installer_files\micromamba_linux_x64 ``` ### Linux arm64: ``` -.\installer.sh +.\install.sh .\installer_files\micromamba_linux_arm64 ``` ### Mac x64: ``` -.\installer.sh +.\install.sh .\installer_files\micromamba_mac_x64 ``` ### Mac arm64 (M1/Apple Silicon): ``` -.\installer.sh +.\install.sh .\installer_files\micromamba_mac_arm64 ``` \ No newline at end of file diff --git a/installer/install.bat b/installer/install.bat index 82af2b2ab7..e2c8260114 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -1,13 +1,13 @@ @echo off -@rem This script will install git and python (if not found on the PATH variable) +@rem This script will install git and conda (if not found on the PATH variable) @rem using micromamba (an 8mb static-linked single-file binary, conda replacement). -@rem For users who already have git and python, this step will be skipped. +@rem For users who already have git and conda, this step will be skipped. @rem Next, it'll checkout the project's git repo, if necessary. @rem Finally, it'll create the conda environment and preload the models. -@rem This enables a user to install this project without manually installing python and git. +@rem This enables a user to install this project without manually installing conda and git. @rem prevent the window from closing after an error if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) @@ -16,51 +16,43 @@ if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe -set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts -@rem figure out whether git and python needs to be installed +@rem figure out whether git and conda needs to be installed set PACKAGES_TO_INSTALL= -call python --version "" >tmp/stdout.txt 2>tmp/stderr.txt -if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% python +call conda --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda call git --version "" >tmp/stdout.txt 2>tmp/stderr.txt if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git -@rem initialize micromamba -if not exist "%MAMBA_ROOT_PREFIX%" ( - mkdir "%MAMBA_ROOT_PREFIX%" - copy "%MICROMAMBA_BINARY_FILE%" "%MAMBA_ROOT_PREFIX%\micromamba.exe" - - @rem test the mamba binary - echo Micromamba version: - call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version - - @rem run the shell hook, otherwise activate will fail - if not exist "%MAMBA_ROOT_PREFIX%\Scripts" ( - call "%MAMBA_ROOT_PREFIX%\micromamba.exe" shell hook --log-level 4 -s cmd.exe - ) -) - -call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" - -@rem (if necessary) install git and python into a contained environment +@rem (if necessary) install git and conda into a contained environment if "%PACKAGES_TO_INSTALL%" NEQ "" ( - echo "Packages to install: %PACKAGES_TO_INSTALL%" + @rem initialize micromamba + if not exist "%MAMBA_ROOT_PREFIX%" ( + mkdir "%MAMBA_ROOT_PREFIX%" + copy "%MICROMAMBA_BINARY_FILE%" "%MAMBA_ROOT_PREFIX%\micromamba.exe" - @rem install git and python into the installer env - if not exist "%INSTALL_ENV_DIR%" ( - call micromamba create -y --prefix "%INSTALL_ENV_DIR%" + @rem test the mamba binary + echo Micromamba version: + call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version ) - call micromamba install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL% + @rem create the installer env + if not exist "%INSTALL_ENV_DIR%" ( + call "%MAMBA_ROOT_PREFIX%\micromamba.exe" create -y --prefix "%INSTALL_ENV_DIR%" + ) - @rem activate - call micromamba activate "%INSTALL_ENV_DIR%" + echo "Packages to install:%PACKAGES_TO_INSTALL%" + + call "%MAMBA_ROOT_PREFIX%\micromamba.exe" install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL% ) +set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts + @rem get the repo (and load into the current directory) if not exist ".git" ( + call git config --global init.defaultBranch main call git init call git remote add origin https://github.com/cmdr2/InvokeAI.git call git fetch @@ -68,8 +60,8 @@ if not exist ".git" ( ) @rem create the environment -call micromamba create -y -f environment.yml -call micromamba activate invokeai +call conda env create +call conda activate invokeai @rem preload the models call python scripts\preload_models.py @@ -77,4 +69,11 @@ call python scripts\preload_models.py @rem make the models dir mkdir models\ldm\stable-diffusion-v1 +@rem tell the user that they need to download the ckpt +echo. +echo "Now you need to install the weights for the stable diffusion model." +echo "Please follow the steps at https://invoke-ai.github.io/InvokeAI/installation/INSTALL_WINDOWS/ to complete the installation" + +@rem it would be nice if the weights downloaded automatically, and didn't need the user to do this manually. + pause diff --git a/installer/install.sh b/installer/install.sh index 5edf465902..005e3f80e1 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -1,13 +1,13 @@ #!/bin/bash -# This script will install git and python (if not found on the PATH variable) +# This script will install git and conda (if not found on the PATH variable) # using micromamba (an 8mb static-linked single-file binary, conda replacement). -# For users who already have git and python, this step will be skipped. +# For users who already have git and conda, this step will be skipped. # Next, it'll checkout the project's git repo, if necessary. # Finally, it'll create the conda environment and preload the models. -# This enables a user to install this project without manually installing python and git. +# This enables a user to install this project without manually installing conda and git. OS_NAME=$(uname -s) case "${OS_NAME}" in @@ -27,42 +27,40 @@ esac export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" INSTALL_ENV_DIR="$(pwd)/installer_files/env" MICROMAMBA_BINARY_FILE="$(pwd)/installer_files/micromamba_${OS_NAME}_${OS_ARCH}" -if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi -# figure out what needs to be installed +# figure out whether git and conda needs to be installed PACKAGES_TO_INSTALL="" -if ! hash "python" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL python"; fi +if ! hash "conda" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL conda"; fi if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi -# initialize micromamba -mkdir -p "$MAMBA_ROOT_PREFIX" -cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" - -# test the mamba binary -echo Micromamba version: -"$MAMBA_ROOT_PREFIX/micromamba" --version - -# run the shell hook, otherwise activate will fail -eval "$($MAMBA_ROOT_PREFIX/micromamba shell hook -s posix)" - -# install git and python into a contained environment (if necessary) +# (if necessary) install git and conda into a contained environment if [ "$PACKAGES_TO_INSTALL" != "" ]; then - echo "Packages to install: $PACKAGES_TO_INSTALL" + # initialize micromamba + if [ ! -e "$MAMBA_ROOT_PREFIX" ]; then + mkdir -p "$MAMBA_ROOT_PREFIX" + cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" - # install git and python into the installer env - if [ ! -e "$INSTALL_ENV_DIR" ]; then - micromamba create -y --prefix "$INSTALL_ENV_DIR" + # test the mamba binary + echo "Micromamba version:" + "$MAMBA_ROOT_PREFIX/micromamba" --version fi - micromamba install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL + # create the installer env + if [ ! -e "$INSTALL_ENV_DIR" ]; then + "$MAMBA_ROOT_PREFIX/micromamba" create -y --prefix "$INSTALL_ENV_DIR" + fi - # activate - micromamba activate "$INSTALL_ENV_DIR" + echo "Packages to install:$PACKAGES_TO_INSTALL" + + "$MAMBA_ROOT_PREFIX/micromamba" install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL fi +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi + # get the repo (and load into the current directory) -if [ ! -e ".git" ]; then +if [ ! -e ".git"]; then + git config --global init.defaultBranch main git init git remote add origin https://github.com/cmdr2/InvokeAI.git git fetch @@ -71,15 +69,27 @@ fi # create the environment if [ "$OS_NAME" == "mac" ]; then - PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 micromamba create -y -f environment-mac.yml + PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 conda env create -y -f environment-mac.yml else - micromamba create -y -f environment.yml + conda env create -y -f environment.yml fi -micromamba activate invokeai +conda activate invokeai # preload the models python scripts/preload_models.py # make the models dir -mkdir -p models/ldm/stable-diffusion-v1 +mkdir models/ldm/stable-diffusion-v1 + +# tell the user that they need to download the ckpt +WEIGHTS_DOC_URL="https://invoke-ai.github.io/InvokeAI/installation/INSTALL_LINUX/" +if [ "$OS_NAME" == "mac" ]; then + WEIGHTS_DOC_URL="https://invoke-ai.github.io/InvokeAI/installation/INSTALL_MAC/" +fi + +echo. +echo "Now you need to install the weights for the stable diffusion model." +echo "Please follow the steps at $WEIGHTS_DOC_URL to complete the installation" + +# it would be nice if the weights downloaded automatically, and didn't need the user to do this manually. diff --git a/invoke.bat b/invoke.bat index ac5bcc4500..ff96fcd4fb 100644 --- a/invoke.bat +++ b/invoke.bat @@ -3,27 +3,9 @@ @rem prevent the window from closing after running the commands if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) -@rem check if conda exists, otherwise use micromamba -set CONDA_COMMAND=conda +set INSTALL_ENV_DIR=%cd%\installer_files\env +set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts -call conda --version "" >tmp/stdout.txt 2>tmp/stderr.txt -if "%ERRORLEVEL%" NEQ "0" set CONDA_COMMAND=micromamba +call conda activate invokeai -@rem initialize micromamba, if using that -if "%CONDA_COMMAND%" EQU "micromamba" ( - set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba - set INSTALL_ENV_DIR=%cd%\installer_files\env - - if not exist "%MAMBA_ROOT_PREFIX%\condabin" ( - echo "Have you run install.bat?" - exit /b - ) - - call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" - - call micromamba activate "%INSTALL_ENV_DIR%" -) - -call %CONDA_COMMAND% activate invokeai - -pause +echo Ready to dream.. diff --git a/invoke.sh b/invoke.sh index e999923f40..639b66233a 100644 --- a/invoke.sh +++ b/invoke.sh @@ -1,27 +1,12 @@ #!/bin/bash if [ "$0" == "bash" ]; then - # check if conda exists, otherwise use micromamba - CONDA_COMMAND="conda" + INSTALL_ENV_DIR="$(pwd)/installer_files/env" + if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi - if ! hash "conda" &>/dev/null; then CONDA_COMMAND="micromamba"; fi + conda activate invokeai - # initialize micromamba, if using that - if [ "$CONDA_COMMAND" == "micromamba" ]; then - export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" - INSTALL_ENV_DIR="$(pwd)/installer_files/env" - - if [ ! -e "$MAMBA_ROOT_PREFIX" ]; then - echo "Have you run install.sh?" - exit - fi - - eval "$($MAMBA_ROOT_PREFIX/micromamba shell hook -s posix)" - - micromamba activate "$INSTALL_ENV_DIR" - ) - - $CONDA_COMMAND activate invokeai + echo "Ready to dream.." else bash --init-file invoke.sh fi diff --git a/update.bat b/update.bat index f346dce3e6..cfffd80d51 100644 --- a/update.bat +++ b/update.bat @@ -8,4 +8,6 @@ if exist ".git" ( call git pull ) +conda env update + pause \ No newline at end of file diff --git a/update.sh b/update.sh index 7ec5bfcb8e..3e82f419ff 100644 --- a/update.sh +++ b/update.sh @@ -1,10 +1,16 @@ #!/bin/bash INSTALL_ENV_DIR="$(pwd)/installer_files/env" - if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi # update the repo if [ -e ".git" ]; then git pull fi + +OS_NAME=$(uname -s) +case "${OS_NAME}" in + Linux*) conda env update;; + Darwin*) conda env update -f environment-mac.yml;; + *) echo "Unknown OS: $OS_NAME! This script runs only on Linux or Mac" && exit +esac From cafaef11f75498eb9bb00ca27dedbeeb064020e2 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 22:20:06 +0530 Subject: [PATCH 06/57] Remove unnecessary quotes while checking if git and conda exist --- installer/install.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index e2c8260114..a63b8c2ead 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -20,10 +20,10 @@ set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe @rem figure out whether git and conda needs to be installed set PACKAGES_TO_INSTALL= -call conda --version "" >tmp/stdout.txt 2>tmp/stderr.txt +call conda --version >tmp/stdout.txt 2>tmp/stderr.txt if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda -call git --version "" >tmp/stdout.txt 2>tmp/stderr.txt +call git --version >tmp/stdout.txt 2>tmp/stderr.txt if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git @rem (if necessary) install git and conda into a contained environment From 7d201d7be06e07447a92af8261ddb5ce60e1ad6c Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 22:27:22 +0530 Subject: [PATCH 07/57] Fix the tmp file used for checking the existence of git and conda commands --- installer/install.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index a63b8c2ead..aa7c099bcd 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -20,10 +20,10 @@ set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe @rem figure out whether git and conda needs to be installed set PACKAGES_TO_INSTALL= -call conda --version >tmp/stdout.txt 2>tmp/stderr.txt +call conda --version >.tmp1 2>.tmp2 if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda -call git --version >tmp/stdout.txt 2>tmp/stderr.txt +call git --version >.tmp1 2>.tmp2 if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git @rem (if necessary) install git and conda into a contained environment From 3d6650e59bc1f48b52419a6df592942b0fc443e6 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 22:44:11 +0530 Subject: [PATCH 08/57] Don't close after updating --- installer/install.bat | 1 - update.bat | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index aa7c099bcd..ef5789e486 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -76,4 +76,3 @@ echo "Please follow the steps at https://invoke-ai.github.io/InvokeAI/installati @rem it would be nice if the weights downloaded automatically, and didn't need the user to do this manually. -pause diff --git a/update.bat b/update.bat index cfffd80d51..ae61a45ab2 100644 --- a/update.bat +++ b/update.bat @@ -1,5 +1,8 @@ @echo off +@rem prevent the window from closing after an error +if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) + set INSTALL_ENV_DIR=%cd%\installer_files\env set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts @@ -9,5 +12,3 @@ if exist ".git" ( ) conda env update - -pause \ No newline at end of file From 9dcfa8de2569edefc1af9902c2cf1e440da941ce Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 22:56:28 +0530 Subject: [PATCH 09/57] Typo in install.sh --- installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/install.sh b/installer/install.sh index 005e3f80e1..8485c9d7e5 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -59,7 +59,7 @@ fi if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi # get the repo (and load into the current directory) -if [ ! -e ".git"]; then +if [ ! -e ".git" ]; then git config --global init.defaultBranch main git init git remote add origin https://github.com/cmdr2/InvokeAI.git From 75f23793df9c177253b706dd6055a9e8061b5c1c Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 23:01:08 +0530 Subject: [PATCH 10/57] Remove -y in linux script --- installer/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/install.sh b/installer/install.sh index 8485c9d7e5..9dd1c03a22 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -69,9 +69,9 @@ fi # create the environment if [ "$OS_NAME" == "mac" ]; then - PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 conda env create -y -f environment-mac.yml + PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 conda env create -f environment-mac.yml else - conda env create -y -f environment.yml + conda env create -f environment.yml fi conda activate invokeai From c16b7f090e8e00ccb669af7c57b7df19152646a1 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 09:57:14 +0530 Subject: [PATCH 11/57] Initialize conda for the shell before running the activate --- installer/install.sh | 5 ++++- invoke.sh | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/installer/install.sh b/installer/install.sh index 9dd1c03a22..b424170443 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -68,8 +68,11 @@ if [ ! -e ".git" ]; then fi # create the environment +CONDA_BASEPATH=$(conda info --base) +source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) + if [ "$OS_NAME" == "mac" ]; then - PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 conda env create -f environment-mac.yml + PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-${OS_ARCH} conda env create -f environment-mac.yml else conda env create -f environment.yml fi diff --git a/invoke.sh b/invoke.sh index 639b66233a..676fc77eee 100755 --- a/invoke.sh +++ b/invoke.sh @@ -4,6 +4,9 @@ if [ "$0" == "bash" ]; then INSTALL_ENV_DIR="$(pwd)/installer_files/env" if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi + CONDA_BASEPATH=$(conda info --base) + source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) + conda activate invokeai echo "Ready to dream.." From 132e2b3ae558eba8e8e7a645e5c860ca85cf228f Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 10:00:53 +0530 Subject: [PATCH 12/57] Typo in the bash script --- installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/install.sh b/installer/install.sh index b424170443..b80c9aed9f 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -91,7 +91,7 @@ if [ "$OS_NAME" == "mac" ]; then WEIGHTS_DOC_URL="https://invoke-ai.github.io/InvokeAI/installation/INSTALL_MAC/" fi -echo. +echo "" echo "Now you need to install the weights for the stable diffusion model." echo "Please follow the steps at $WEIGHTS_DOC_URL to complete the installation" From 15c5d6a5effca11bf34d9b7db393fdd32a2b032f Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 10:24:44 +0530 Subject: [PATCH 13/57] Typo in bash path --- installer/install.sh | 2 +- invoke.sh | 2 +- update.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installer/install.sh b/installer/install.sh index b80c9aed9f..7e3714434c 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -56,7 +56,7 @@ if [ "$PACKAGES_TO_INSTALL" != "" ]; then "$MAMBA_ROOT_PREFIX/micromamba" install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL fi -if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH:$INSTALL_ENV_DIR/bin"; fi # get the repo (and load into the current directory) if [ ! -e ".git" ]; then diff --git a/invoke.sh b/invoke.sh index 676fc77eee..45de0223b6 100755 --- a/invoke.sh +++ b/invoke.sh @@ -2,7 +2,7 @@ if [ "$0" == "bash" ]; then INSTALL_ENV_DIR="$(pwd)/installer_files/env" - if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi + if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH:$INSTALL_ENV_DIR/bin"; fi CONDA_BASEPATH=$(conda info --base) source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) diff --git a/update.sh b/update.sh index 3e82f419ff..a3e30348aa 100755 --- a/update.sh +++ b/update.sh @@ -1,7 +1,7 @@ #!/bin/bash INSTALL_ENV_DIR="$(pwd)/installer_files/env" -if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH:$INSTALL_ENV_DIR/bin"; fi # update the repo if [ -e ".git" ]; then From e405385e0d1edafa629249c7f3768304a1f563d0 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 10:56:04 +0530 Subject: [PATCH 14/57] Prefer the locally installed conda over any global conda installation; activate the env before updating --- installer/install.sh | 2 +- invoke.sh | 2 +- update.sh | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/installer/install.sh b/installer/install.sh index 7e3714434c..a41b2891ce 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -56,7 +56,7 @@ if [ "$PACKAGES_TO_INSTALL" != "" ]; then "$MAMBA_ROOT_PREFIX/micromamba" install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL fi -if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH:$INSTALL_ENV_DIR/bin"; fi +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi # get the repo (and load into the current directory) if [ ! -e ".git" ]; then diff --git a/invoke.sh b/invoke.sh index 45de0223b6..4e72fc0591 100755 --- a/invoke.sh +++ b/invoke.sh @@ -2,7 +2,7 @@ if [ "$0" == "bash" ]; then INSTALL_ENV_DIR="$(pwd)/installer_files/env" - if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH:$INSTALL_ENV_DIR/bin"; fi + if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi CONDA_BASEPATH=$(conda info --base) source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) diff --git a/update.sh b/update.sh index a3e30348aa..4b15218560 100755 --- a/update.sh +++ b/update.sh @@ -1,13 +1,18 @@ #!/bin/bash INSTALL_ENV_DIR="$(pwd)/installer_files/env" -if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH:$INSTALL_ENV_DIR/bin"; fi +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi # update the repo if [ -e ".git" ]; then git pull fi +CONDA_BASEPATH=$(conda info --base) +source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) + +conda activate invokeai + OS_NAME=$(uname -s) case "${OS_NAME}" in Linux*) conda env update;; From 1cb365fff1ac06fa599ee837d7021f8ca6939c45 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 11:01:09 +0530 Subject: [PATCH 15/57] Prefer the locally installed conda over any global conda installation --- installer/install.bat | 2 +- invoke.bat | 2 +- update.bat | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index ef5789e486..630fd8037c 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -48,7 +48,7 @@ if "%PACKAGES_TO_INSTALL%" NEQ "" ( call "%MAMBA_ROOT_PREFIX%\micromamba.exe" install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL% ) -set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% @rem get the repo (and load into the current directory) if not exist ".git" ( diff --git a/invoke.bat b/invoke.bat index ff96fcd4fb..4689153ae8 100644 --- a/invoke.bat +++ b/invoke.bat @@ -4,7 +4,7 @@ if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) set INSTALL_ENV_DIR=%cd%\installer_files\env -set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% call conda activate invokeai diff --git a/update.bat b/update.bat index ae61a45ab2..e81a426faf 100644 --- a/update.bat +++ b/update.bat @@ -4,7 +4,7 @@ if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) set INSTALL_ENV_DIR=%cd%\installer_files\env -set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% @rem update the repo if exist ".git" ( From 8c47638eec13ddb80c2aa1a60aa5b27a19d57b91 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 11:25:02 +0530 Subject: [PATCH 16/57] Update How to create the installers.md --- installer/How to create the installers.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/installer/How to create the installers.md b/installer/How to create the installers.md index 9b76c61aba..bc6862695e 100644 --- a/installer/How to create the installers.md +++ b/installer/How to create the installers.md @@ -1,3 +1,7 @@ +**Important:** These instructions are for the developers of this project, not for users! The users should use the pre-created zip files for installation. + +This guide explains how to create the zip files that users will use for installing. + The installer zip contains two files: the script, and the micromamba binary. Micromamba is a single ~8mb binary file, that acts like a package manager (drop-in replacement for conda). @@ -48,4 +52,4 @@ For Linux/Mac: Make sure the `chmod u+x` permission is granted to `install.sh` a ``` .\install.sh .\installer_files\micromamba_mac_arm64 -``` \ No newline at end of file +``` From 759f563b6dc3a63183ef65e6c8278f2e7b8a76e7 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 15:20:29 +0530 Subject: [PATCH 17/57] Add a pause before the script ends --- installer/install.bat | 4 +--- invoke.bat | 5 ++--- update.bat | 5 ++--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index 630fd8037c..ecb23ac438 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -9,9 +9,6 @@ @rem This enables a user to install this project without manually installing conda and git. -@rem prevent the window from closing after an error -if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) - @rem config set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env @@ -76,3 +73,4 @@ echo "Please follow the steps at https://invoke-ai.github.io/InvokeAI/installati @rem it would be nice if the weights downloaded automatically, and didn't need the user to do this manually. +pause diff --git a/invoke.bat b/invoke.bat index 4689153ae8..8d23ab660b 100644 --- a/invoke.bat +++ b/invoke.bat @@ -1,11 +1,10 @@ @echo off -@rem prevent the window from closing after running the commands -if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) - set INSTALL_ENV_DIR=%cd%\installer_files\env set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% call conda activate invokeai echo Ready to dream.. + +cmd /k diff --git a/update.bat b/update.bat index e81a426faf..426c43d9ba 100644 --- a/update.bat +++ b/update.bat @@ -1,8 +1,5 @@ @echo off -@rem prevent the window from closing after an error -if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) - set INSTALL_ENV_DIR=%cd%\installer_files\env set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% @@ -12,3 +9,5 @@ if exist ".git" ( ) conda env update + +pause From 065a1da9d1492e588854d5e5c6abaf769a39b396 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 14 Oct 2022 08:56:27 +0530 Subject: [PATCH 18/57] Fix line endings for mac --- installer/install.sh | 1 + invoke.sh | 1 + update.sh | 1 + 3 files changed, 3 insertions(+) diff --git a/installer/install.sh b/installer/install.sh index a41b2891ce..0e72ff96fd 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -9,6 +9,7 @@ # This enables a user to install this project without manually installing conda and git. + OS_NAME=$(uname -s) case "${OS_NAME}" in Linux*) OS_NAME="linux";; diff --git a/invoke.sh b/invoke.sh index 4e72fc0591..6257aaefa2 100755 --- a/invoke.sh +++ b/invoke.sh @@ -1,5 +1,6 @@ #!/bin/bash + if [ "$0" == "bash" ]; then INSTALL_ENV_DIR="$(pwd)/installer_files/env" if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi diff --git a/update.sh b/update.sh index 4b15218560..edf7756015 100755 --- a/update.sh +++ b/update.sh @@ -1,5 +1,6 @@ #!/bin/bash + INSTALL_ENV_DIR="$(pwd)/installer_files/env" if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi From 11dc3ca1f865c20b67a3f55c8c473ff6f25d26b4 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 14 Oct 2022 10:13:41 +0530 Subject: [PATCH 19/57] Don't continue if micromamba was required but didn't initialize properly --- installer/install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/installer/install.sh b/installer/install.sh index 0e72ff96fd..bbc606bb97 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -55,6 +55,11 @@ if [ "$PACKAGES_TO_INSTALL" != "" ]; then echo "Packages to install:$PACKAGES_TO_INSTALL" "$MAMBA_ROOT_PREFIX/micromamba" install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL + + if [ ! -e "$INSTALL_ENV_DIR" ]; then + echo "There was a problem while initializing micromamba. Cannot continue." + exit + fi fi if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi From 9a3c7800a7172a947a8105d2bd386edde612bf8e Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 14 Oct 2022 10:23:55 +0530 Subject: [PATCH 20/57] Use the correct conda os arch for mac x64 --- installer/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/installer/install.sh b/installer/install.sh index bbc606bb97..6090c2374d 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -78,6 +78,7 @@ CONDA_BASEPATH=$(conda info --base) source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) if [ "$OS_NAME" == "mac" ]; then + if [ "$OS_ARCH" == "x64" ]; then OS_ARCH="64"; fi PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-${OS_ARCH} conda env create -f environment-mac.yml else conda env create -f environment.yml From 8aa40714e37d00cdc87f7e49b2a298612bc9ccaf Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 26 Oct 2022 15:30:48 +0530 Subject: [PATCH 21/57] Single-file installer script, micromamba will now be downloaded automatically on the first run; Activate the base environment before running the rest of the conda commands; Don't download conda/git again if it's already been installed by the installer --- installer/How to create the installers.md | 54 +---------------------- installer/install.bat | 22 +++++++-- installer/install.sh | 22 ++++++--- 3 files changed, 36 insertions(+), 62 deletions(-) diff --git a/installer/How to create the installers.md b/installer/How to create the installers.md index bc6862695e..8030ff7790 100644 --- a/installer/How to create the installers.md +++ b/installer/How to create the installers.md @@ -1,55 +1,5 @@ **Important:** These instructions are for the developers of this project, not for users! The users should use the pre-created zip files for installation. -This guide explains how to create the zip files that users will use for installing. +Just distribute the `install.bat` or `install.sh` file. -The installer zip contains two files: the script, and the micromamba binary. - -Micromamba is a single ~8mb binary file, that acts like a package manager (drop-in replacement for conda). - -# Download micromamba from: -* Windows x64: `curl -Ls https://micro.mamba.pm/api/micromamba/win-64/latest | tar -xvj bin/micromamba_win_x64.exe` - -* Linux x64: `curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba_linux_x64` -* Linux arm64: `curl -Ls https://micro.mamba.pm/api/micromamba/linux-aarch64/latest | tar -xvj bin/micromamba_linux_arm64` - -* Mac x64: `curl -Ls https://micro.mamba.pm/api/micromamba/osx-64/latest | tar -xvj bin/micromamba_mac_x64` -* Mac arm64 (M1/Apple Silicon): `curl -Ls https://micro.mamba.pm/api/micromamba/osx-arm64/latest | tar -xvj bin/micromamba_mac_arm64` - -The download link provides tar.bz2 files. - -(source https://mamba.readthedocs.io/en/latest/installation.html) - -# Create the installer -Create the following folder structure, and zip it up. - -For Linux/Mac: Make sure the `chmod u+x` permission is granted to `install.sh` and the corresponding `micromamba` binary. - -### Windows x64: -``` -.\install.bat -.\installer_files\micromamba_win_x64.exe -``` - -### Linux x64: -``` -.\install.sh -.\installer_files\micromamba_linux_x64 -``` - -### Linux arm64: -``` -.\install.sh -.\installer_files\micromamba_linux_arm64 -``` - -### Mac x64: -``` -.\install.sh -.\installer_files\micromamba_mac_x64 -``` - -### Mac arm64 (M1/Apple Silicon): -``` -.\install.sh -.\installer_files\micromamba_mac_arm64 -``` +Running that file will download the invokeAI repository into the same folder as the script, and install the required dependencies. diff --git a/installer/install.bat b/installer/install.bat index ecb23ac438..e21edd695a 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -12,9 +12,12 @@ @rem config set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env -set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe +set MICROMAMBA_DOWNLOAD_URL=https://github.com/cmdr2/stable-diffusion-ui/releases/download/v1.1/micromamba.exe +@rem Change the download URL to an InvokeAI repo's release URL @rem figure out whether git and conda needs to be installed +if exist "%INSTALL_ENV_DIR%" set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH% + set PACKAGES_TO_INSTALL= call conda --version >.tmp1 2>.tmp2 @@ -25,10 +28,12 @@ if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git @rem (if necessary) install git and conda into a contained environment if "%PACKAGES_TO_INSTALL%" NEQ "" ( - @rem initialize micromamba - if not exist "%MAMBA_ROOT_PREFIX%" ( + @rem download micromamba + if not exist "%MAMBA_ROOT_PREFIX%\micromamba.exe" ( + echo "Downloading micromamba from %MICROMAMBA_DOWNLOAD_URL% to %MAMBA_ROOT_PREFIX%\micromamba.exe" + mkdir "%MAMBA_ROOT_PREFIX%" - copy "%MICROMAMBA_BINARY_FILE%" "%MAMBA_ROOT_PREFIX%\micromamba.exe" + call curl -L "%MICROMAMBA_DOWNLOAD_URL%" > "%MAMBA_ROOT_PREFIX%\micromamba.exe" @rem test the mamba binary echo Micromamba version: @@ -43,6 +48,12 @@ if "%PACKAGES_TO_INSTALL%" NEQ "" ( echo "Packages to install:%PACKAGES_TO_INSTALL%" call "%MAMBA_ROOT_PREFIX%\micromamba.exe" install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL% + + if not exist "%INSTALL_ENV_DIR%" ( + echo "There was a problem while installing%PACKAGES_TO_INSTALL% using micromamba. Cannot continue." + pause + exit /b + ) ) set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% @@ -56,6 +67,9 @@ if not exist ".git" ( call git checkout origin/main -ft ) +@rem activate the base env +call conda activate + @rem create the environment call conda env create call conda activate invokeai diff --git a/installer/install.sh b/installer/install.sh index 6090c2374d..4e93ea1eac 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -19,17 +19,22 @@ esac OS_ARCH=$(uname -m) case "${OS_ARCH}" in - x86_64*) OS_ARCH="x64";; + x86_64*) OS_ARCH="64";; arm64*) OS_ARCH="arm64";; *) echo "Unknown system architecture: $OS_ARCH! This script runs only on x86_64 or arm64" && exit esac +# https://mamba.readthedocs.io/en/latest/installation.html +if [ "$OS_NAME" == "linux" ] && [ "$OS_ARCH" == "arm64" ]; then OS_ARCH="aarch64"; fi + # config export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" INSTALL_ENV_DIR="$(pwd)/installer_files/env" -MICROMAMBA_BINARY_FILE="$(pwd)/installer_files/micromamba_${OS_NAME}_${OS_ARCH}" +MICROMAMBA_DOWNLOAD_URL="https://micro.mamba.pm/api/micromamba/${OS_NAME}-${OS_ARCH}/latest" # figure out whether git and conda needs to be installed +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi + PACKAGES_TO_INSTALL="" if ! hash "conda" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL conda"; fi @@ -37,10 +42,14 @@ if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git" # (if necessary) install git and conda into a contained environment if [ "$PACKAGES_TO_INSTALL" != "" ]; then - # initialize micromamba - if [ ! -e "$MAMBA_ROOT_PREFIX" ]; then + # download micromamba + if [ ! -e "$MAMBA_ROOT_PREFIX/micromamba" ]; then + echo "Downloading micromamba from $MICROMAMBA_DOWNLOAD_URL to $MAMBA_ROOT_PREFIX/micromamba" + mkdir -p "$MAMBA_ROOT_PREFIX" - cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" + curl -L "$MICROMAMBA_DOWNLOAD_URL" | tar -xvj bin/micromamba -O > "$MAMBA_ROOT_PREFIX/micromamba" + + chmod u+x "$MAMBA_ROOT_PREFIX/micromamba" # test the mamba binary echo "Micromamba version:" @@ -77,8 +86,9 @@ fi CONDA_BASEPATH=$(conda info --base) source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) +conda activate + if [ "$OS_NAME" == "mac" ]; then - if [ "$OS_ARCH" == "x64" ]; then OS_ARCH="64"; fi PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-${OS_ARCH} conda env create -f environment-mac.yml else conda env create -f environment.yml From f73a116f436cccfc31204eb06a3a04b054abb95c Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 26 Oct 2022 15:35:42 +0530 Subject: [PATCH 22/57] header --- installer/install.bat | 3 +++ installer/install.sh | 2 ++ 2 files changed, 5 insertions(+) diff --git a/installer/install.bat b/installer/install.bat index e21edd695a..45e0e24e2d 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -9,6 +9,9 @@ @rem This enables a user to install this project without manually installing conda and git. +echo "Installing InvokeAI.." +echo. + @rem config set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env diff --git a/installer/install.sh b/installer/install.sh index 4e93ea1eac..48f816a427 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -9,6 +9,8 @@ # This enables a user to install this project without manually installing conda and git. +echo "Installing InvokeAI.." +echo "" OS_NAME=$(uname -s) case "${OS_NAME}" in From 422f2ecc9103f647ccc836e676a9408a2c72761f Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 26 Oct 2022 15:38:49 +0530 Subject: [PATCH 23/57] Repo URL constant --- installer/install.bat | 3 ++- installer/install.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index 45e0e24e2d..8ba2cae2c3 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -16,6 +16,7 @@ echo. set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env set MICROMAMBA_DOWNLOAD_URL=https://github.com/cmdr2/stable-diffusion-ui/releases/download/v1.1/micromamba.exe +set REPO_URL=https://github.com/cmdr2/InvokeAI.git @rem Change the download URL to an InvokeAI repo's release URL @rem figure out whether git and conda needs to be installed @@ -65,7 +66,7 @@ set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scrip if not exist ".git" ( call git config --global init.defaultBranch main call git init - call git remote add origin https://github.com/cmdr2/InvokeAI.git + call git remote add origin %REPO_URL% call git fetch call git checkout origin/main -ft ) diff --git a/installer/install.sh b/installer/install.sh index 48f816a427..83957d2a9d 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -33,6 +33,7 @@ if [ "$OS_NAME" == "linux" ] && [ "$OS_ARCH" == "arm64" ]; then OS_ARCH="aarch64 export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" INSTALL_ENV_DIR="$(pwd)/installer_files/env" MICROMAMBA_DOWNLOAD_URL="https://micro.mamba.pm/api/micromamba/${OS_NAME}-${OS_ARCH}/latest" +REPO_URL="https://github.com/cmdr2/InvokeAI.git" # figure out whether git and conda needs to be installed if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi @@ -79,7 +80,7 @@ if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi if [ ! -e ".git" ]; then git config --global init.defaultBranch main git init - git remote add origin https://github.com/cmdr2/InvokeAI.git + git remote add origin "$REPO_URL" git fetch git checkout origin/main -ft fi From d03947a6ee6b88ce9fe6ac7fc041fd6ba8cd5888 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 26 Oct 2022 16:39:21 +0530 Subject: [PATCH 24/57] Add Library\usr\bin to the PATH --- installer/install.bat | 2 +- invoke.bat | 2 +- update.bat | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index 8ba2cae2c3..d6bf2723b1 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -60,7 +60,7 @@ if "%PACKAGES_TO_INSTALL%" NEQ "" ( ) ) -set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH% @rem get the repo (and load into the current directory) if not exist ".git" ( diff --git a/invoke.bat b/invoke.bat index 8d23ab660b..b9fb7902de 100644 --- a/invoke.bat +++ b/invoke.bat @@ -1,7 +1,7 @@ @echo off set INSTALL_ENV_DIR=%cd%\installer_files\env -set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH% call conda activate invokeai diff --git a/update.bat b/update.bat index 426c43d9ba..9beda82d0f 100644 --- a/update.bat +++ b/update.bat @@ -1,7 +1,7 @@ @echo off set INSTALL_ENV_DIR=%cd%\installer_files\env -set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH% @rem update the repo if exist ".git" ( From 71426d200e24785089b98bbdb974961ecabb6c71 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 16:38:06 +0530 Subject: [PATCH 25/57] 1-click installer using micromamba to install git and python into a contained environment (if necessary) before running the normal installation script --- installer/How to create the installers.md | 51 ++++++++++++++ installer/install.bat | 80 +++++++++++++++++++++ installer/install.sh | 85 +++++++++++++++++++++++ invoke.bat | 29 ++++++++ invoke.sh | 27 +++++++ update.bat | 11 +++ update.sh | 10 +++ 7 files changed, 293 insertions(+) create mode 100644 installer/How to create the installers.md create mode 100644 installer/install.bat create mode 100644 installer/install.sh create mode 100644 invoke.bat create mode 100644 invoke.sh create mode 100644 update.bat create mode 100644 update.sh diff --git a/installer/How to create the installers.md b/installer/How to create the installers.md new file mode 100644 index 0000000000..7089f7929a --- /dev/null +++ b/installer/How to create the installers.md @@ -0,0 +1,51 @@ +The installer zip contains two files: the script, and the micromamba binary. + +Micromamba is a single ~8mb binary file, that acts like a package manager (drop-in replacement for conda). + +# Download micromamba from: +* Windows x64: `curl -Ls https://micro.mamba.pm/api/micromamba/win-64/latest | tar -xvj bin/micromamba_win_x64.exe` + +* Linux x64: `curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba_linux_x64` +* Linux arm64: `curl -Ls https://micro.mamba.pm/api/micromamba/linux-aarch64/latest | tar -xvj bin/micromamba_linux_arm64` + +* Mac x64: `curl -Ls https://micro.mamba.pm/api/micromamba/osx-64/latest | tar -xvj bin/micromamba_mac_x64` +* Mac arm64 (M1/Apple Silicon): `curl -Ls https://micro.mamba.pm/api/micromamba/osx-arm64/latest | tar -xvj bin/micromamba_mac_arm64` + +The download link provides tar.bz2 files. + +(source https://mamba.readthedocs.io/en/latest/installation.html) + +# Create the installer +Create the following folder structure, and zip it up. + +For Linux/Mac: Make sure the `chmod u+x` permission is granted to `installer.sh` and the corresponding `micromamba` binary. + +### Windows x64: +``` +.\installer.bat +.\installer_files\micromamba_win_x64.exe +``` + +### Linux x64: +``` +.\installer.sh +.\installer_files\micromamba_linux_x64 +``` + +### Linux arm64: +``` +.\installer.sh +.\installer_files\micromamba_linux_arm64 +``` + +### Mac x64: +``` +.\installer.sh +.\installer_files\micromamba_mac_x64 +``` + +### Mac arm64 (M1/Apple Silicon): +``` +.\installer.sh +.\installer_files\micromamba_mac_arm64 +``` \ No newline at end of file diff --git a/installer/install.bat b/installer/install.bat new file mode 100644 index 0000000000..806e6ea745 --- /dev/null +++ b/installer/install.bat @@ -0,0 +1,80 @@ +@echo off + +@rem This script will install git and python (if not found on the PATH variable) +@rem using micromamba (an 8mb static-linked single-file binary, conda replacement). +@rem For users who already have git and python, this step will be skipped. + +@rem Next, it'll checkout the project's git repo, if necessary. +@rem Finally, it'll create the conda environment and preload the models. + +@rem This enables a user to install this project without manually installing python and git. + +@rem prevent the window from closing after an error +if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) + +@rem config +set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba +set INSTALL_ENV_DIR=%cd%\installer_files\env +set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe +set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts + +@rem initialize micromamba +if not exist "%MAMBA_ROOT_PREFIX%" ( + mkdir "%MAMBA_ROOT_PREFIX%" + copy "%MICROMAMBA_BINARY_FILE%" "%MAMBA_ROOT_PREFIX%\micromamba.exe" + + @rem test the mamba binary + echo Micromamba version: + call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version + + @rem run the shell hook, otherwise activate will fail + if not exist "%MAMBA_ROOT_PREFIX%\Scripts" ( + call "%MAMBA_ROOT_PREFIX%\micromamba.exe" shell hook --log-level 4 -s cmd.exe + ) +) + +call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" + +@rem figure out whether git and python needs to be installed +set PACKAGES_TO_INSTALL= + +call python --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% python + +call git --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git + +@rem (if necessary) install git and python into a contained environment +if "%PACKAGES_TO_INSTALL%" NEQ "" ( + echo "Packages to install: %PACKAGES_TO_INSTALL%" + + @rem install git and python into the installer env + if not exist "%INSTALL_ENV_DIR%" ( + call micromamba create -y --prefix "%INSTALL_ENV_DIR%" + ) + + call micromamba install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL% + + @rem activate + call micromamba activate "%INSTALL_ENV_DIR%" +) + +@rem get the repo (and load into the current directory) +if not exist ".git" ( + call git init + call git remote add origin https://github.com/cmdr2/InvokeAI.git + call git fetch + call git checkout origin/main -ft +) + +@rem create the environment +call micromamba create -f environment.yml +call micromamba activate invokeai + +@rem preload the models +call python scripts\preload_models.py + +@rem make the models dir +mkdir models\ldm\stable-diffusion-v1 + +pause diff --git a/installer/install.sh b/installer/install.sh new file mode 100644 index 0000000000..569a4fc47a --- /dev/null +++ b/installer/install.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +# This script will install git and python (if not found on the PATH variable) +# using micromamba (an 8mb static-linked single-file binary, conda replacement). +# For users who already have git and python, this step will be skipped. + +# Next, it'll checkout the project's git repo, if necessary. +# Finally, it'll create the conda environment and preload the models. + +# This enables a user to install this project without manually installing python and git. + +OS_NAME=$(uname -s) +case "${OS_NAME}" in + Linux*) OS_NAME="linux";; + Darwin*) OS_NAME="mac";; + *) echo "Unknown OS: $OS_NAME! This script runs only on Linux or Mac" && exit +esac + +OS_ARCH=$(uname -m) +case "${OS_ARCH}" in + x86_64*) OS_ARCH="x64";; + arm64*) OS_ARCH="arm64";; + *) echo "Unknown system architecture: $OS_ARCH! This script runs only on x86_64 or arm64" && exit +esac + +# config +export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" +INSTALL_ENV_DIR="$(pwd)/installer_files/env" +MICROMAMBA_BINARY_FILE="$(pwd)/installer_files/micromamba_${OS_NAME}_${OS_ARCH}" +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi + +# initialize micromamba +mkdir -p "$MAMBA_ROOT_PREFIX" +cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" + +# test the mamba binary +echo Micromamba version: +"$MAMBA_ROOT_PREFIX/micromamba" --version + +# run the shell hook, otherwise activate will fail +eval "$($MAMBA_ROOT_PREFIX/micromamba shell hook -s posix)" + +# figure out what needs to be installed +PACKAGES_TO_INSTALL="" + +if ! hash "python" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL python"; fi +if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi + +# install git and python into a contained environment (if necessary) +if [ "$PACKAGES_TO_INSTALL" != "" ]; then + echo "Packages to install: $PACKAGES_TO_INSTALL" + + # install git and python into the installer env + if [ ! -e "$INSTALL_ENV_DIR" ]; then + micromamba create -y --prefix "$INSTALL_ENV_DIR" + fi + + micromamba install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL + + # activate + micromamba activate "$INSTALL_ENV_DIR" +fi + +# get the repo (and load into the current directory) +if [ ! -e ".git" ]; then + git init + git remote add origin https://github.com/cmdr2/InvokeAI.git + git fetch + git checkout origin/main -ft +fi + +# create the environment +if [ "$OS_NAME" == "mac" ]; then + PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 micromamba create -f environment-mac.yml +else + micromamba create -f environment.yml +fi + +micromamba activate invokeai + +# preload the models +python scripts/preload_models.py + +# make the models dir +mkdir -p models/ldm/stable-diffusion-v1 diff --git a/invoke.bat b/invoke.bat new file mode 100644 index 0000000000..ac5bcc4500 --- /dev/null +++ b/invoke.bat @@ -0,0 +1,29 @@ +@echo off + +@rem prevent the window from closing after running the commands +if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) + +@rem check if conda exists, otherwise use micromamba +set CONDA_COMMAND=conda + +call conda --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set CONDA_COMMAND=micromamba + +@rem initialize micromamba, if using that +if "%CONDA_COMMAND%" EQU "micromamba" ( + set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba + set INSTALL_ENV_DIR=%cd%\installer_files\env + + if not exist "%MAMBA_ROOT_PREFIX%\condabin" ( + echo "Have you run install.bat?" + exit /b + ) + + call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" + + call micromamba activate "%INSTALL_ENV_DIR%" +) + +call %CONDA_COMMAND% activate invokeai + +pause diff --git a/invoke.sh b/invoke.sh new file mode 100644 index 0000000000..e999923f40 --- /dev/null +++ b/invoke.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ "$0" == "bash" ]; then + # check if conda exists, otherwise use micromamba + CONDA_COMMAND="conda" + + if ! hash "conda" &>/dev/null; then CONDA_COMMAND="micromamba"; fi + + # initialize micromamba, if using that + if [ "$CONDA_COMMAND" == "micromamba" ]; then + export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" + INSTALL_ENV_DIR="$(pwd)/installer_files/env" + + if [ ! -e "$MAMBA_ROOT_PREFIX" ]; then + echo "Have you run install.sh?" + exit + fi + + eval "$($MAMBA_ROOT_PREFIX/micromamba shell hook -s posix)" + + micromamba activate "$INSTALL_ENV_DIR" + ) + + $CONDA_COMMAND activate invokeai +else + bash --init-file invoke.sh +fi diff --git a/update.bat b/update.bat new file mode 100644 index 0000000000..f346dce3e6 --- /dev/null +++ b/update.bat @@ -0,0 +1,11 @@ +@echo off + +set INSTALL_ENV_DIR=%cd%\installer_files\env +set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts + +@rem update the repo +if exist ".git" ( + call git pull +) + +pause \ No newline at end of file diff --git a/update.sh b/update.sh new file mode 100644 index 0000000000..7ec5bfcb8e --- /dev/null +++ b/update.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +INSTALL_ENV_DIR="$(pwd)/installer_files/env" + +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi + +# update the repo +if [ -e ".git" ]; then + git pull +fi From 74e6ce3e6ac71e038d5cfda78ff933df238b7a7d Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 16:53:07 +0530 Subject: [PATCH 26/57] Check for missing python/git before activating micromamba --- installer/install.bat | 18 +++++++++--------- installer/install.sh | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index 806e6ea745..a1ca837607 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -18,6 +18,15 @@ set INSTALL_ENV_DIR=%cd%\installer_files\env set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts +@rem figure out whether git and python needs to be installed +set PACKAGES_TO_INSTALL= + +call python --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% python + +call git --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git + @rem initialize micromamba if not exist "%MAMBA_ROOT_PREFIX%" ( mkdir "%MAMBA_ROOT_PREFIX%" @@ -35,15 +44,6 @@ if not exist "%MAMBA_ROOT_PREFIX%" ( call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" -@rem figure out whether git and python needs to be installed -set PACKAGES_TO_INSTALL= - -call python --version "" >tmp/stdout.txt 2>tmp/stderr.txt -if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% python - -call git --version "" >tmp/stdout.txt 2>tmp/stderr.txt -if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git - @rem (if necessary) install git and python into a contained environment if "%PACKAGES_TO_INSTALL%" NEQ "" ( echo "Packages to install: %PACKAGES_TO_INSTALL%" diff --git a/installer/install.sh b/installer/install.sh index 569a4fc47a..6bf606497e 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -29,6 +29,12 @@ INSTALL_ENV_DIR="$(pwd)/installer_files/env" MICROMAMBA_BINARY_FILE="$(pwd)/installer_files/micromamba_${OS_NAME}_${OS_ARCH}" if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi +# figure out what needs to be installed +PACKAGES_TO_INSTALL="" + +if ! hash "python" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL python"; fi +if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi + # initialize micromamba mkdir -p "$MAMBA_ROOT_PREFIX" cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" @@ -40,12 +46,6 @@ echo Micromamba version: # run the shell hook, otherwise activate will fail eval "$($MAMBA_ROOT_PREFIX/micromamba shell hook -s posix)" -# figure out what needs to be installed -PACKAGES_TO_INSTALL="" - -if ! hash "python" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL python"; fi -if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi - # install git and python into a contained environment (if necessary) if [ "$PACKAGES_TO_INSTALL" != "" ]; then echo "Packages to install: $PACKAGES_TO_INSTALL" From 3ae094b673e156c98f492a8f64fbf9534370f2a4 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 16:56:40 +0530 Subject: [PATCH 27/57] Create the env using -y --- installer/install.bat | 2 +- installer/install.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index a1ca837607..82af2b2ab7 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -68,7 +68,7 @@ if not exist ".git" ( ) @rem create the environment -call micromamba create -f environment.yml +call micromamba create -y -f environment.yml call micromamba activate invokeai @rem preload the models diff --git a/installer/install.sh b/installer/install.sh index 6bf606497e..5edf465902 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -71,9 +71,9 @@ fi # create the environment if [ "$OS_NAME" == "mac" ]; then - PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 micromamba create -f environment-mac.yml + PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 micromamba create -y -f environment-mac.yml else - micromamba create -f environment.yml + micromamba create -y -f environment.yml fi micromamba activate invokeai From 8c2e82cc548cc8bd31dff54b3b9dc705190e535d Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 16:58:19 +0530 Subject: [PATCH 28/57] Make the linux/mac scripts executable --- installer/install.sh | 0 invoke.sh | 0 update.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 installer/install.sh mode change 100644 => 100755 invoke.sh mode change 100644 => 100755 update.sh diff --git a/installer/install.sh b/installer/install.sh old mode 100644 new mode 100755 diff --git a/invoke.sh b/invoke.sh old mode 100644 new mode 100755 diff --git a/update.sh b/update.sh old mode 100644 new mode 100755 From b12c8a28d7c98f47f9b74d5cccbcea63bb168bb8 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 22:15:38 +0530 Subject: [PATCH 29/57] Updated the installer to simplify the use of micromamba, and use conda for the actual installation; Update conda during the update script --- installer/How to create the installers.md | 12 ++-- installer/install.bat | 67 +++++++++++----------- installer/install.sh | 70 +++++++++++++---------- invoke.bat | 26 ++------- invoke.sh | 23 ++------ update.bat | 2 + update.sh | 8 ++- 7 files changed, 96 insertions(+), 112 deletions(-) diff --git a/installer/How to create the installers.md b/installer/How to create the installers.md index 7089f7929a..9b76c61aba 100644 --- a/installer/How to create the installers.md +++ b/installer/How to create the installers.md @@ -18,34 +18,34 @@ The download link provides tar.bz2 files. # Create the installer Create the following folder structure, and zip it up. -For Linux/Mac: Make sure the `chmod u+x` permission is granted to `installer.sh` and the corresponding `micromamba` binary. +For Linux/Mac: Make sure the `chmod u+x` permission is granted to `install.sh` and the corresponding `micromamba` binary. ### Windows x64: ``` -.\installer.bat +.\install.bat .\installer_files\micromamba_win_x64.exe ``` ### Linux x64: ``` -.\installer.sh +.\install.sh .\installer_files\micromamba_linux_x64 ``` ### Linux arm64: ``` -.\installer.sh +.\install.sh .\installer_files\micromamba_linux_arm64 ``` ### Mac x64: ``` -.\installer.sh +.\install.sh .\installer_files\micromamba_mac_x64 ``` ### Mac arm64 (M1/Apple Silicon): ``` -.\installer.sh +.\install.sh .\installer_files\micromamba_mac_arm64 ``` \ No newline at end of file diff --git a/installer/install.bat b/installer/install.bat index 82af2b2ab7..e2c8260114 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -1,13 +1,13 @@ @echo off -@rem This script will install git and python (if not found on the PATH variable) +@rem This script will install git and conda (if not found on the PATH variable) @rem using micromamba (an 8mb static-linked single-file binary, conda replacement). -@rem For users who already have git and python, this step will be skipped. +@rem For users who already have git and conda, this step will be skipped. @rem Next, it'll checkout the project's git repo, if necessary. @rem Finally, it'll create the conda environment and preload the models. -@rem This enables a user to install this project without manually installing python and git. +@rem This enables a user to install this project without manually installing conda and git. @rem prevent the window from closing after an error if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) @@ -16,51 +16,43 @@ if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe -set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts -@rem figure out whether git and python needs to be installed +@rem figure out whether git and conda needs to be installed set PACKAGES_TO_INSTALL= -call python --version "" >tmp/stdout.txt 2>tmp/stderr.txt -if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% python +call conda --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda call git --version "" >tmp/stdout.txt 2>tmp/stderr.txt if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git -@rem initialize micromamba -if not exist "%MAMBA_ROOT_PREFIX%" ( - mkdir "%MAMBA_ROOT_PREFIX%" - copy "%MICROMAMBA_BINARY_FILE%" "%MAMBA_ROOT_PREFIX%\micromamba.exe" - - @rem test the mamba binary - echo Micromamba version: - call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version - - @rem run the shell hook, otherwise activate will fail - if not exist "%MAMBA_ROOT_PREFIX%\Scripts" ( - call "%MAMBA_ROOT_PREFIX%\micromamba.exe" shell hook --log-level 4 -s cmd.exe - ) -) - -call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" - -@rem (if necessary) install git and python into a contained environment +@rem (if necessary) install git and conda into a contained environment if "%PACKAGES_TO_INSTALL%" NEQ "" ( - echo "Packages to install: %PACKAGES_TO_INSTALL%" + @rem initialize micromamba + if not exist "%MAMBA_ROOT_PREFIX%" ( + mkdir "%MAMBA_ROOT_PREFIX%" + copy "%MICROMAMBA_BINARY_FILE%" "%MAMBA_ROOT_PREFIX%\micromamba.exe" - @rem install git and python into the installer env - if not exist "%INSTALL_ENV_DIR%" ( - call micromamba create -y --prefix "%INSTALL_ENV_DIR%" + @rem test the mamba binary + echo Micromamba version: + call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version ) - call micromamba install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL% + @rem create the installer env + if not exist "%INSTALL_ENV_DIR%" ( + call "%MAMBA_ROOT_PREFIX%\micromamba.exe" create -y --prefix "%INSTALL_ENV_DIR%" + ) - @rem activate - call micromamba activate "%INSTALL_ENV_DIR%" + echo "Packages to install:%PACKAGES_TO_INSTALL%" + + call "%MAMBA_ROOT_PREFIX%\micromamba.exe" install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL% ) +set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts + @rem get the repo (and load into the current directory) if not exist ".git" ( + call git config --global init.defaultBranch main call git init call git remote add origin https://github.com/cmdr2/InvokeAI.git call git fetch @@ -68,8 +60,8 @@ if not exist ".git" ( ) @rem create the environment -call micromamba create -y -f environment.yml -call micromamba activate invokeai +call conda env create +call conda activate invokeai @rem preload the models call python scripts\preload_models.py @@ -77,4 +69,11 @@ call python scripts\preload_models.py @rem make the models dir mkdir models\ldm\stable-diffusion-v1 +@rem tell the user that they need to download the ckpt +echo. +echo "Now you need to install the weights for the stable diffusion model." +echo "Please follow the steps at https://invoke-ai.github.io/InvokeAI/installation/INSTALL_WINDOWS/ to complete the installation" + +@rem it would be nice if the weights downloaded automatically, and didn't need the user to do this manually. + pause diff --git a/installer/install.sh b/installer/install.sh index 5edf465902..005e3f80e1 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -1,13 +1,13 @@ #!/bin/bash -# This script will install git and python (if not found on the PATH variable) +# This script will install git and conda (if not found on the PATH variable) # using micromamba (an 8mb static-linked single-file binary, conda replacement). -# For users who already have git and python, this step will be skipped. +# For users who already have git and conda, this step will be skipped. # Next, it'll checkout the project's git repo, if necessary. # Finally, it'll create the conda environment and preload the models. -# This enables a user to install this project without manually installing python and git. +# This enables a user to install this project without manually installing conda and git. OS_NAME=$(uname -s) case "${OS_NAME}" in @@ -27,42 +27,40 @@ esac export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" INSTALL_ENV_DIR="$(pwd)/installer_files/env" MICROMAMBA_BINARY_FILE="$(pwd)/installer_files/micromamba_${OS_NAME}_${OS_ARCH}" -if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi -# figure out what needs to be installed +# figure out whether git and conda needs to be installed PACKAGES_TO_INSTALL="" -if ! hash "python" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL python"; fi +if ! hash "conda" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL conda"; fi if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi -# initialize micromamba -mkdir -p "$MAMBA_ROOT_PREFIX" -cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" - -# test the mamba binary -echo Micromamba version: -"$MAMBA_ROOT_PREFIX/micromamba" --version - -# run the shell hook, otherwise activate will fail -eval "$($MAMBA_ROOT_PREFIX/micromamba shell hook -s posix)" - -# install git and python into a contained environment (if necessary) +# (if necessary) install git and conda into a contained environment if [ "$PACKAGES_TO_INSTALL" != "" ]; then - echo "Packages to install: $PACKAGES_TO_INSTALL" + # initialize micromamba + if [ ! -e "$MAMBA_ROOT_PREFIX" ]; then + mkdir -p "$MAMBA_ROOT_PREFIX" + cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" - # install git and python into the installer env - if [ ! -e "$INSTALL_ENV_DIR" ]; then - micromamba create -y --prefix "$INSTALL_ENV_DIR" + # test the mamba binary + echo "Micromamba version:" + "$MAMBA_ROOT_PREFIX/micromamba" --version fi - micromamba install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL + # create the installer env + if [ ! -e "$INSTALL_ENV_DIR" ]; then + "$MAMBA_ROOT_PREFIX/micromamba" create -y --prefix "$INSTALL_ENV_DIR" + fi - # activate - micromamba activate "$INSTALL_ENV_DIR" + echo "Packages to install:$PACKAGES_TO_INSTALL" + + "$MAMBA_ROOT_PREFIX/micromamba" install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL fi +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi + # get the repo (and load into the current directory) -if [ ! -e ".git" ]; then +if [ ! -e ".git"]; then + git config --global init.defaultBranch main git init git remote add origin https://github.com/cmdr2/InvokeAI.git git fetch @@ -71,15 +69,27 @@ fi # create the environment if [ "$OS_NAME" == "mac" ]; then - PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 micromamba create -y -f environment-mac.yml + PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 conda env create -y -f environment-mac.yml else - micromamba create -y -f environment.yml + conda env create -y -f environment.yml fi -micromamba activate invokeai +conda activate invokeai # preload the models python scripts/preload_models.py # make the models dir -mkdir -p models/ldm/stable-diffusion-v1 +mkdir models/ldm/stable-diffusion-v1 + +# tell the user that they need to download the ckpt +WEIGHTS_DOC_URL="https://invoke-ai.github.io/InvokeAI/installation/INSTALL_LINUX/" +if [ "$OS_NAME" == "mac" ]; then + WEIGHTS_DOC_URL="https://invoke-ai.github.io/InvokeAI/installation/INSTALL_MAC/" +fi + +echo. +echo "Now you need to install the weights for the stable diffusion model." +echo "Please follow the steps at $WEIGHTS_DOC_URL to complete the installation" + +# it would be nice if the weights downloaded automatically, and didn't need the user to do this manually. diff --git a/invoke.bat b/invoke.bat index ac5bcc4500..ff96fcd4fb 100644 --- a/invoke.bat +++ b/invoke.bat @@ -3,27 +3,9 @@ @rem prevent the window from closing after running the commands if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) -@rem check if conda exists, otherwise use micromamba -set CONDA_COMMAND=conda +set INSTALL_ENV_DIR=%cd%\installer_files\env +set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts -call conda --version "" >tmp/stdout.txt 2>tmp/stderr.txt -if "%ERRORLEVEL%" NEQ "0" set CONDA_COMMAND=micromamba +call conda activate invokeai -@rem initialize micromamba, if using that -if "%CONDA_COMMAND%" EQU "micromamba" ( - set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba - set INSTALL_ENV_DIR=%cd%\installer_files\env - - if not exist "%MAMBA_ROOT_PREFIX%\condabin" ( - echo "Have you run install.bat?" - exit /b - ) - - call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" - - call micromamba activate "%INSTALL_ENV_DIR%" -) - -call %CONDA_COMMAND% activate invokeai - -pause +echo Ready to dream.. diff --git a/invoke.sh b/invoke.sh index e999923f40..639b66233a 100755 --- a/invoke.sh +++ b/invoke.sh @@ -1,27 +1,12 @@ #!/bin/bash if [ "$0" == "bash" ]; then - # check if conda exists, otherwise use micromamba - CONDA_COMMAND="conda" + INSTALL_ENV_DIR="$(pwd)/installer_files/env" + if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi - if ! hash "conda" &>/dev/null; then CONDA_COMMAND="micromamba"; fi + conda activate invokeai - # initialize micromamba, if using that - if [ "$CONDA_COMMAND" == "micromamba" ]; then - export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" - INSTALL_ENV_DIR="$(pwd)/installer_files/env" - - if [ ! -e "$MAMBA_ROOT_PREFIX" ]; then - echo "Have you run install.sh?" - exit - fi - - eval "$($MAMBA_ROOT_PREFIX/micromamba shell hook -s posix)" - - micromamba activate "$INSTALL_ENV_DIR" - ) - - $CONDA_COMMAND activate invokeai + echo "Ready to dream.." else bash --init-file invoke.sh fi diff --git a/update.bat b/update.bat index f346dce3e6..cfffd80d51 100644 --- a/update.bat +++ b/update.bat @@ -8,4 +8,6 @@ if exist ".git" ( call git pull ) +conda env update + pause \ No newline at end of file diff --git a/update.sh b/update.sh index 7ec5bfcb8e..3e82f419ff 100755 --- a/update.sh +++ b/update.sh @@ -1,10 +1,16 @@ #!/bin/bash INSTALL_ENV_DIR="$(pwd)/installer_files/env" - if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi # update the repo if [ -e ".git" ]; then git pull fi + +OS_NAME=$(uname -s) +case "${OS_NAME}" in + Linux*) conda env update;; + Darwin*) conda env update -f environment-mac.yml;; + *) echo "Unknown OS: $OS_NAME! This script runs only on Linux or Mac" && exit +esac From 7179cc7f2560b8e9c2532afdd652f0d8284e5324 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 22:20:06 +0530 Subject: [PATCH 30/57] Remove unnecessary quotes while checking if git and conda exist --- installer/install.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index e2c8260114..a63b8c2ead 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -20,10 +20,10 @@ set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe @rem figure out whether git and conda needs to be installed set PACKAGES_TO_INSTALL= -call conda --version "" >tmp/stdout.txt 2>tmp/stderr.txt +call conda --version >tmp/stdout.txt 2>tmp/stderr.txt if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda -call git --version "" >tmp/stdout.txt 2>tmp/stderr.txt +call git --version >tmp/stdout.txt 2>tmp/stderr.txt if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git @rem (if necessary) install git and conda into a contained environment From 29eea935924d1de1ba62476cd5b082188c8594dd Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 22:27:22 +0530 Subject: [PATCH 31/57] Fix the tmp file used for checking the existence of git and conda commands --- installer/install.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index a63b8c2ead..aa7c099bcd 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -20,10 +20,10 @@ set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe @rem figure out whether git and conda needs to be installed set PACKAGES_TO_INSTALL= -call conda --version >tmp/stdout.txt 2>tmp/stderr.txt +call conda --version >.tmp1 2>.tmp2 if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda -call git --version >tmp/stdout.txt 2>tmp/stderr.txt +call git --version >.tmp1 2>.tmp2 if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git @rem (if necessary) install git and conda into a contained environment From 1f6251763608c0a7623e2cfffc1890b800219490 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 22:44:11 +0530 Subject: [PATCH 32/57] Don't close after updating --- installer/install.bat | 1 - update.bat | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index aa7c099bcd..ef5789e486 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -76,4 +76,3 @@ echo "Please follow the steps at https://invoke-ai.github.io/InvokeAI/installati @rem it would be nice if the weights downloaded automatically, and didn't need the user to do this manually. -pause diff --git a/update.bat b/update.bat index cfffd80d51..ae61a45ab2 100644 --- a/update.bat +++ b/update.bat @@ -1,5 +1,8 @@ @echo off +@rem prevent the window from closing after an error +if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) + set INSTALL_ENV_DIR=%cd%\installer_files\env set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts @@ -9,5 +12,3 @@ if exist ".git" ( ) conda env update - -pause \ No newline at end of file From 90d9d6ea0018a814fac46bbe3cea449d38e7a25d Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 22:56:28 +0530 Subject: [PATCH 33/57] Typo in install.sh --- installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/install.sh b/installer/install.sh index 005e3f80e1..8485c9d7e5 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -59,7 +59,7 @@ fi if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi # get the repo (and load into the current directory) -if [ ! -e ".git"]; then +if [ ! -e ".git" ]; then git config --global init.defaultBranch main git init git remote add origin https://github.com/cmdr2/InvokeAI.git From c6c146f54fa30e126bef7907366380318f61704b Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 23:01:08 +0530 Subject: [PATCH 34/57] Remove -y in linux script --- installer/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/install.sh b/installer/install.sh index 8485c9d7e5..9dd1c03a22 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -69,9 +69,9 @@ fi # create the environment if [ "$OS_NAME" == "mac" ]; then - PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 conda env create -y -f environment-mac.yml + PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 conda env create -f environment-mac.yml else - conda env create -y -f environment.yml + conda env create -f environment.yml fi conda activate invokeai From 14725f9d598a8b5f1f982e2dc3a2f6372fa6f4dc Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 09:57:14 +0530 Subject: [PATCH 35/57] Initialize conda for the shell before running the activate --- installer/install.sh | 5 ++++- invoke.sh | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/installer/install.sh b/installer/install.sh index 9dd1c03a22..b424170443 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -68,8 +68,11 @@ if [ ! -e ".git" ]; then fi # create the environment +CONDA_BASEPATH=$(conda info --base) +source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) + if [ "$OS_NAME" == "mac" ]; then - PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 conda env create -f environment-mac.yml + PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-${OS_ARCH} conda env create -f environment-mac.yml else conda env create -f environment.yml fi diff --git a/invoke.sh b/invoke.sh index 639b66233a..676fc77eee 100755 --- a/invoke.sh +++ b/invoke.sh @@ -4,6 +4,9 @@ if [ "$0" == "bash" ]; then INSTALL_ENV_DIR="$(pwd)/installer_files/env" if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi + CONDA_BASEPATH=$(conda info --base) + source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) + conda activate invokeai echo "Ready to dream.." From 94cd20de05d14015f66fbd996db58616d6adb212 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 10:00:53 +0530 Subject: [PATCH 36/57] Typo in the bash script --- installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/install.sh b/installer/install.sh index b424170443..b80c9aed9f 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -91,7 +91,7 @@ if [ "$OS_NAME" == "mac" ]; then WEIGHTS_DOC_URL="https://invoke-ai.github.io/InvokeAI/installation/INSTALL_MAC/" fi -echo. +echo "" echo "Now you need to install the weights for the stable diffusion model." echo "Please follow the steps at $WEIGHTS_DOC_URL to complete the installation" From 90c8aa716d97afd35745f5606a99401e7a68d6e3 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 10:24:44 +0530 Subject: [PATCH 37/57] Typo in bash path --- installer/install.sh | 2 +- invoke.sh | 2 +- update.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installer/install.sh b/installer/install.sh index b80c9aed9f..7e3714434c 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -56,7 +56,7 @@ if [ "$PACKAGES_TO_INSTALL" != "" ]; then "$MAMBA_ROOT_PREFIX/micromamba" install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL fi -if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH:$INSTALL_ENV_DIR/bin"; fi # get the repo (and load into the current directory) if [ ! -e ".git" ]; then diff --git a/invoke.sh b/invoke.sh index 676fc77eee..45de0223b6 100755 --- a/invoke.sh +++ b/invoke.sh @@ -2,7 +2,7 @@ if [ "$0" == "bash" ]; then INSTALL_ENV_DIR="$(pwd)/installer_files/env" - if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi + if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH:$INSTALL_ENV_DIR/bin"; fi CONDA_BASEPATH=$(conda info --base) source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) diff --git a/update.sh b/update.sh index 3e82f419ff..a3e30348aa 100755 --- a/update.sh +++ b/update.sh @@ -1,7 +1,7 @@ #!/bin/bash INSTALL_ENV_DIR="$(pwd)/installer_files/env" -if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH:$INSTALL_ENV_DIR/bin"; fi # update the repo if [ -e ".git" ]; then From da012e1bfd43002ca6850a7bb85396944ab63fb3 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 10:56:04 +0530 Subject: [PATCH 38/57] Prefer the locally installed conda over any global conda installation; activate the env before updating --- installer/install.sh | 2 +- invoke.sh | 2 +- update.sh | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/installer/install.sh b/installer/install.sh index 7e3714434c..a41b2891ce 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -56,7 +56,7 @@ if [ "$PACKAGES_TO_INSTALL" != "" ]; then "$MAMBA_ROOT_PREFIX/micromamba" install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL fi -if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH:$INSTALL_ENV_DIR/bin"; fi +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi # get the repo (and load into the current directory) if [ ! -e ".git" ]; then diff --git a/invoke.sh b/invoke.sh index 45de0223b6..4e72fc0591 100755 --- a/invoke.sh +++ b/invoke.sh @@ -2,7 +2,7 @@ if [ "$0" == "bash" ]; then INSTALL_ENV_DIR="$(pwd)/installer_files/env" - if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH:$INSTALL_ENV_DIR/bin"; fi + if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi CONDA_BASEPATH=$(conda info --base) source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) diff --git a/update.sh b/update.sh index a3e30348aa..4b15218560 100755 --- a/update.sh +++ b/update.sh @@ -1,13 +1,18 @@ #!/bin/bash INSTALL_ENV_DIR="$(pwd)/installer_files/env" -if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH:$INSTALL_ENV_DIR/bin"; fi +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi # update the repo if [ -e ".git" ]; then git pull fi +CONDA_BASEPATH=$(conda info --base) +source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) + +conda activate invokeai + OS_NAME=$(uname -s) case "${OS_NAME}" in Linux*) conda env update;; From a9a59a3046e171e1ed580ffa66f2f6247ce58f9d Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 11:01:09 +0530 Subject: [PATCH 39/57] Prefer the locally installed conda over any global conda installation --- installer/install.bat | 2 +- invoke.bat | 2 +- update.bat | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index ef5789e486..630fd8037c 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -48,7 +48,7 @@ if "%PACKAGES_TO_INSTALL%" NEQ "" ( call "%MAMBA_ROOT_PREFIX%\micromamba.exe" install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL% ) -set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% @rem get the repo (and load into the current directory) if not exist ".git" ( diff --git a/invoke.bat b/invoke.bat index ff96fcd4fb..4689153ae8 100644 --- a/invoke.bat +++ b/invoke.bat @@ -4,7 +4,7 @@ if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) set INSTALL_ENV_DIR=%cd%\installer_files\env -set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% call conda activate invokeai diff --git a/update.bat b/update.bat index ae61a45ab2..e81a426faf 100644 --- a/update.bat +++ b/update.bat @@ -4,7 +4,7 @@ if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) set INSTALL_ENV_DIR=%cd%\installer_files\env -set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% @rem update the repo if exist ".git" ( From ef505d2bc5ed32e9f7beac78c1be4e263e2027ed Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 11:25:02 +0530 Subject: [PATCH 40/57] Update How to create the installers.md --- installer/How to create the installers.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/installer/How to create the installers.md b/installer/How to create the installers.md index 9b76c61aba..bc6862695e 100644 --- a/installer/How to create the installers.md +++ b/installer/How to create the installers.md @@ -1,3 +1,7 @@ +**Important:** These instructions are for the developers of this project, not for users! The users should use the pre-created zip files for installation. + +This guide explains how to create the zip files that users will use for installing. + The installer zip contains two files: the script, and the micromamba binary. Micromamba is a single ~8mb binary file, that acts like a package manager (drop-in replacement for conda). @@ -48,4 +52,4 @@ For Linux/Mac: Make sure the `chmod u+x` permission is granted to `install.sh` a ``` .\install.sh .\installer_files\micromamba_mac_arm64 -``` \ No newline at end of file +``` From 1d3c43b67f833f721c703eaffa2133c9ef57d8cd Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 15:20:29 +0530 Subject: [PATCH 41/57] Add a pause before the script ends --- installer/install.bat | 4 +--- invoke.bat | 5 ++--- update.bat | 5 ++--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index 630fd8037c..ecb23ac438 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -9,9 +9,6 @@ @rem This enables a user to install this project without manually installing conda and git. -@rem prevent the window from closing after an error -if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) - @rem config set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env @@ -76,3 +73,4 @@ echo "Please follow the steps at https://invoke-ai.github.io/InvokeAI/installati @rem it would be nice if the weights downloaded automatically, and didn't need the user to do this manually. +pause diff --git a/invoke.bat b/invoke.bat index 4689153ae8..8d23ab660b 100644 --- a/invoke.bat +++ b/invoke.bat @@ -1,11 +1,10 @@ @echo off -@rem prevent the window from closing after running the commands -if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) - set INSTALL_ENV_DIR=%cd%\installer_files\env set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% call conda activate invokeai echo Ready to dream.. + +cmd /k diff --git a/update.bat b/update.bat index e81a426faf..426c43d9ba 100644 --- a/update.bat +++ b/update.bat @@ -1,8 +1,5 @@ @echo off -@rem prevent the window from closing after an error -if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) - set INSTALL_ENV_DIR=%cd%\installer_files\env set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% @@ -12,3 +9,5 @@ if exist ".git" ( ) conda env update + +pause From f7bb90234dc84630aaa29da97058a26c4605a3b6 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 14 Oct 2022 08:56:27 +0530 Subject: [PATCH 42/57] Fix line endings for mac --- installer/install.sh | 1 + invoke.sh | 1 + update.sh | 1 + 3 files changed, 3 insertions(+) diff --git a/installer/install.sh b/installer/install.sh index a41b2891ce..0e72ff96fd 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -9,6 +9,7 @@ # This enables a user to install this project without manually installing conda and git. + OS_NAME=$(uname -s) case "${OS_NAME}" in Linux*) OS_NAME="linux";; diff --git a/invoke.sh b/invoke.sh index 4e72fc0591..6257aaefa2 100755 --- a/invoke.sh +++ b/invoke.sh @@ -1,5 +1,6 @@ #!/bin/bash + if [ "$0" == "bash" ]; then INSTALL_ENV_DIR="$(pwd)/installer_files/env" if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi diff --git a/update.sh b/update.sh index 4b15218560..edf7756015 100755 --- a/update.sh +++ b/update.sh @@ -1,5 +1,6 @@ #!/bin/bash + INSTALL_ENV_DIR="$(pwd)/installer_files/env" if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi From 0050176d57e78a6695b8431350494ae2a1445ad7 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 14 Oct 2022 10:13:41 +0530 Subject: [PATCH 43/57] Don't continue if micromamba was required but didn't initialize properly --- installer/install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/installer/install.sh b/installer/install.sh index 0e72ff96fd..bbc606bb97 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -55,6 +55,11 @@ if [ "$PACKAGES_TO_INSTALL" != "" ]; then echo "Packages to install:$PACKAGES_TO_INSTALL" "$MAMBA_ROOT_PREFIX/micromamba" install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL + + if [ ! -e "$INSTALL_ENV_DIR" ]; then + echo "There was a problem while initializing micromamba. Cannot continue." + exit + fi fi if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi From 83f20c23aa829c1bddda4c9fba3801928b0435a2 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 14 Oct 2022 10:23:55 +0530 Subject: [PATCH 44/57] Use the correct conda os arch for mac x64 --- installer/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/installer/install.sh b/installer/install.sh index bbc606bb97..6090c2374d 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -78,6 +78,7 @@ CONDA_BASEPATH=$(conda info --base) source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) if [ "$OS_NAME" == "mac" ]; then + if [ "$OS_ARCH" == "x64" ]; then OS_ARCH="64"; fi PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-${OS_ARCH} conda env create -f environment-mac.yml else conda env create -f environment.yml From c00da1702f609306fecfbfcc9eaefdeaffd21122 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 26 Oct 2022 15:30:48 +0530 Subject: [PATCH 45/57] Single-file installer script, micromamba will now be downloaded automatically on the first run; Activate the base environment before running the rest of the conda commands; Don't download conda/git again if it's already been installed by the installer --- installer/How to create the installers.md | 54 +---------------------- installer/install.bat | 22 +++++++-- installer/install.sh | 22 ++++++--- 3 files changed, 36 insertions(+), 62 deletions(-) diff --git a/installer/How to create the installers.md b/installer/How to create the installers.md index bc6862695e..8030ff7790 100644 --- a/installer/How to create the installers.md +++ b/installer/How to create the installers.md @@ -1,55 +1,5 @@ **Important:** These instructions are for the developers of this project, not for users! The users should use the pre-created zip files for installation. -This guide explains how to create the zip files that users will use for installing. +Just distribute the `install.bat` or `install.sh` file. -The installer zip contains two files: the script, and the micromamba binary. - -Micromamba is a single ~8mb binary file, that acts like a package manager (drop-in replacement for conda). - -# Download micromamba from: -* Windows x64: `curl -Ls https://micro.mamba.pm/api/micromamba/win-64/latest | tar -xvj bin/micromamba_win_x64.exe` - -* Linux x64: `curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba_linux_x64` -* Linux arm64: `curl -Ls https://micro.mamba.pm/api/micromamba/linux-aarch64/latest | tar -xvj bin/micromamba_linux_arm64` - -* Mac x64: `curl -Ls https://micro.mamba.pm/api/micromamba/osx-64/latest | tar -xvj bin/micromamba_mac_x64` -* Mac arm64 (M1/Apple Silicon): `curl -Ls https://micro.mamba.pm/api/micromamba/osx-arm64/latest | tar -xvj bin/micromamba_mac_arm64` - -The download link provides tar.bz2 files. - -(source https://mamba.readthedocs.io/en/latest/installation.html) - -# Create the installer -Create the following folder structure, and zip it up. - -For Linux/Mac: Make sure the `chmod u+x` permission is granted to `install.sh` and the corresponding `micromamba` binary. - -### Windows x64: -``` -.\install.bat -.\installer_files\micromamba_win_x64.exe -``` - -### Linux x64: -``` -.\install.sh -.\installer_files\micromamba_linux_x64 -``` - -### Linux arm64: -``` -.\install.sh -.\installer_files\micromamba_linux_arm64 -``` - -### Mac x64: -``` -.\install.sh -.\installer_files\micromamba_mac_x64 -``` - -### Mac arm64 (M1/Apple Silicon): -``` -.\install.sh -.\installer_files\micromamba_mac_arm64 -``` +Running that file will download the invokeAI repository into the same folder as the script, and install the required dependencies. diff --git a/installer/install.bat b/installer/install.bat index ecb23ac438..e21edd695a 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -12,9 +12,12 @@ @rem config set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env -set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe +set MICROMAMBA_DOWNLOAD_URL=https://github.com/cmdr2/stable-diffusion-ui/releases/download/v1.1/micromamba.exe +@rem Change the download URL to an InvokeAI repo's release URL @rem figure out whether git and conda needs to be installed +if exist "%INSTALL_ENV_DIR%" set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH% + set PACKAGES_TO_INSTALL= call conda --version >.tmp1 2>.tmp2 @@ -25,10 +28,12 @@ if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git @rem (if necessary) install git and conda into a contained environment if "%PACKAGES_TO_INSTALL%" NEQ "" ( - @rem initialize micromamba - if not exist "%MAMBA_ROOT_PREFIX%" ( + @rem download micromamba + if not exist "%MAMBA_ROOT_PREFIX%\micromamba.exe" ( + echo "Downloading micromamba from %MICROMAMBA_DOWNLOAD_URL% to %MAMBA_ROOT_PREFIX%\micromamba.exe" + mkdir "%MAMBA_ROOT_PREFIX%" - copy "%MICROMAMBA_BINARY_FILE%" "%MAMBA_ROOT_PREFIX%\micromamba.exe" + call curl -L "%MICROMAMBA_DOWNLOAD_URL%" > "%MAMBA_ROOT_PREFIX%\micromamba.exe" @rem test the mamba binary echo Micromamba version: @@ -43,6 +48,12 @@ if "%PACKAGES_TO_INSTALL%" NEQ "" ( echo "Packages to install:%PACKAGES_TO_INSTALL%" call "%MAMBA_ROOT_PREFIX%\micromamba.exe" install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL% + + if not exist "%INSTALL_ENV_DIR%" ( + echo "There was a problem while installing%PACKAGES_TO_INSTALL% using micromamba. Cannot continue." + pause + exit /b + ) ) set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% @@ -56,6 +67,9 @@ if not exist ".git" ( call git checkout origin/main -ft ) +@rem activate the base env +call conda activate + @rem create the environment call conda env create call conda activate invokeai diff --git a/installer/install.sh b/installer/install.sh index 6090c2374d..4e93ea1eac 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -19,17 +19,22 @@ esac OS_ARCH=$(uname -m) case "${OS_ARCH}" in - x86_64*) OS_ARCH="x64";; + x86_64*) OS_ARCH="64";; arm64*) OS_ARCH="arm64";; *) echo "Unknown system architecture: $OS_ARCH! This script runs only on x86_64 or arm64" && exit esac +# https://mamba.readthedocs.io/en/latest/installation.html +if [ "$OS_NAME" == "linux" ] && [ "$OS_ARCH" == "arm64" ]; then OS_ARCH="aarch64"; fi + # config export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" INSTALL_ENV_DIR="$(pwd)/installer_files/env" -MICROMAMBA_BINARY_FILE="$(pwd)/installer_files/micromamba_${OS_NAME}_${OS_ARCH}" +MICROMAMBA_DOWNLOAD_URL="https://micro.mamba.pm/api/micromamba/${OS_NAME}-${OS_ARCH}/latest" # figure out whether git and conda needs to be installed +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi + PACKAGES_TO_INSTALL="" if ! hash "conda" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL conda"; fi @@ -37,10 +42,14 @@ if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git" # (if necessary) install git and conda into a contained environment if [ "$PACKAGES_TO_INSTALL" != "" ]; then - # initialize micromamba - if [ ! -e "$MAMBA_ROOT_PREFIX" ]; then + # download micromamba + if [ ! -e "$MAMBA_ROOT_PREFIX/micromamba" ]; then + echo "Downloading micromamba from $MICROMAMBA_DOWNLOAD_URL to $MAMBA_ROOT_PREFIX/micromamba" + mkdir -p "$MAMBA_ROOT_PREFIX" - cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" + curl -L "$MICROMAMBA_DOWNLOAD_URL" | tar -xvj bin/micromamba -O > "$MAMBA_ROOT_PREFIX/micromamba" + + chmod u+x "$MAMBA_ROOT_PREFIX/micromamba" # test the mamba binary echo "Micromamba version:" @@ -77,8 +86,9 @@ fi CONDA_BASEPATH=$(conda info --base) source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) +conda activate + if [ "$OS_NAME" == "mac" ]; then - if [ "$OS_ARCH" == "x64" ]; then OS_ARCH="64"; fi PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-${OS_ARCH} conda env create -f environment-mac.yml else conda env create -f environment.yml From f25ad030119cb703e09bdbe1288f988e40ce3a38 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 26 Oct 2022 15:35:42 +0530 Subject: [PATCH 46/57] header --- installer/install.bat | 3 +++ installer/install.sh | 2 ++ 2 files changed, 5 insertions(+) diff --git a/installer/install.bat b/installer/install.bat index e21edd695a..45e0e24e2d 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -9,6 +9,9 @@ @rem This enables a user to install this project without manually installing conda and git. +echo "Installing InvokeAI.." +echo. + @rem config set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env diff --git a/installer/install.sh b/installer/install.sh index 4e93ea1eac..48f816a427 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -9,6 +9,8 @@ # This enables a user to install this project without manually installing conda and git. +echo "Installing InvokeAI.." +echo "" OS_NAME=$(uname -s) case "${OS_NAME}" in From 2dd5c0696d2b624ec54ec29dfa674eba2b04c3b9 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 26 Oct 2022 15:38:49 +0530 Subject: [PATCH 47/57] Repo URL constant --- installer/install.bat | 3 ++- installer/install.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index 45e0e24e2d..8ba2cae2c3 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -16,6 +16,7 @@ echo. set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env set MICROMAMBA_DOWNLOAD_URL=https://github.com/cmdr2/stable-diffusion-ui/releases/download/v1.1/micromamba.exe +set REPO_URL=https://github.com/cmdr2/InvokeAI.git @rem Change the download URL to an InvokeAI repo's release URL @rem figure out whether git and conda needs to be installed @@ -65,7 +66,7 @@ set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scrip if not exist ".git" ( call git config --global init.defaultBranch main call git init - call git remote add origin https://github.com/cmdr2/InvokeAI.git + call git remote add origin %REPO_URL% call git fetch call git checkout origin/main -ft ) diff --git a/installer/install.sh b/installer/install.sh index 48f816a427..83957d2a9d 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -33,6 +33,7 @@ if [ "$OS_NAME" == "linux" ] && [ "$OS_ARCH" == "arm64" ]; then OS_ARCH="aarch64 export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" INSTALL_ENV_DIR="$(pwd)/installer_files/env" MICROMAMBA_DOWNLOAD_URL="https://micro.mamba.pm/api/micromamba/${OS_NAME}-${OS_ARCH}/latest" +REPO_URL="https://github.com/cmdr2/InvokeAI.git" # figure out whether git and conda needs to be installed if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi @@ -79,7 +80,7 @@ if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi if [ ! -e ".git" ]; then git config --global init.defaultBranch main git init - git remote add origin https://github.com/cmdr2/InvokeAI.git + git remote add origin "$REPO_URL" git fetch git checkout origin/main -ft fi From e73a2d68b58f5058bbdb4fc4a710341d74bcc847 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 26 Oct 2022 16:39:21 +0530 Subject: [PATCH 48/57] Add Library\usr\bin to the PATH --- installer/install.bat | 2 +- invoke.bat | 2 +- update.bat | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index 8ba2cae2c3..d6bf2723b1 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -60,7 +60,7 @@ if "%PACKAGES_TO_INSTALL%" NEQ "" ( ) ) -set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH% @rem get the repo (and load into the current directory) if not exist ".git" ( diff --git a/invoke.bat b/invoke.bat index 8d23ab660b..b9fb7902de 100644 --- a/invoke.bat +++ b/invoke.bat @@ -1,7 +1,7 @@ @echo off set INSTALL_ENV_DIR=%cd%\installer_files\env -set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH% call conda activate invokeai diff --git a/update.bat b/update.bat index 426c43d9ba..9beda82d0f 100644 --- a/update.bat +++ b/update.bat @@ -1,7 +1,7 @@ @echo off set INSTALL_ENV_DIR=%cd%\installer_files\env -set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH% @rem update the repo if exist ".git" ( From 29d9ce03ab520a501a3c3321db6f91884d79ba3a Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 19:47:55 +0530 Subject: [PATCH 49/57] Redownload micromamba if the download failed midway; Start the script in the script's directory, not where it was run from --- installer/install.bat | 6 +++++- installer/install.sh | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index d6bf2723b1..b59c384391 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -17,6 +17,7 @@ set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env set MICROMAMBA_DOWNLOAD_URL=https://github.com/cmdr2/stable-diffusion-ui/releases/download/v1.1/micromamba.exe set REPO_URL=https://github.com/cmdr2/InvokeAI.git +set umamba_exists=F @rem Change the download URL to an InvokeAI repo's release URL @rem figure out whether git and conda needs to be installed @@ -30,10 +31,13 @@ if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda call git --version >.tmp1 2>.tmp2 if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git +call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version >.tmp1 2>.tmp2 +if "%ERRORLEVEL%" EQU "0" set umamba_exists=T + @rem (if necessary) install git and conda into a contained environment if "%PACKAGES_TO_INSTALL%" NEQ "" ( @rem download micromamba - if not exist "%MAMBA_ROOT_PREFIX%\micromamba.exe" ( + if "%umamba_exists%" == "F" ( echo "Downloading micromamba from %MICROMAMBA_DOWNLOAD_URL% to %MAMBA_ROOT_PREFIX%\micromamba.exe" mkdir "%MAMBA_ROOT_PREFIX%" diff --git a/installer/install.sh b/installer/install.sh index 83957d2a9d..9549c3339d 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -9,6 +9,8 @@ # This enables a user to install this project without manually installing conda and git. +cd "$(dirname "${BASH_SOURCE[0]}")" + echo "Installing InvokeAI.." echo "" @@ -34,6 +36,7 @@ export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" INSTALL_ENV_DIR="$(pwd)/installer_files/env" MICROMAMBA_DOWNLOAD_URL="https://micro.mamba.pm/api/micromamba/${OS_NAME}-${OS_ARCH}/latest" REPO_URL="https://github.com/cmdr2/InvokeAI.git" +umamba_exists="F" # figure out whether git and conda needs to be installed if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi @@ -43,10 +46,12 @@ PACKAGES_TO_INSTALL="" if ! hash "conda" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL conda"; fi if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi +if "$MAMBA_ROOT_PREFIX/micromamba" --version &>/dev/null; then umamba_exists="T"; fi + # (if necessary) install git and conda into a contained environment if [ "$PACKAGES_TO_INSTALL" != "" ]; then # download micromamba - if [ ! -e "$MAMBA_ROOT_PREFIX/micromamba" ]; then + if [ "$umamba_exists" == "F" ]; then echo "Downloading micromamba from $MICROMAMBA_DOWNLOAD_URL to $MAMBA_ROOT_PREFIX/micromamba" mkdir -p "$MAMBA_ROOT_PREFIX" From bc7bfed0d327ef543e2b4504f9a8052c37ea0b95 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 21:16:40 +0530 Subject: [PATCH 50/57] Show the next steps to the user; Allow starting the command-line or web UI --- installer/install.bat | 7 ++----- installer/install.sh | 13 ++----------- invoke.bat | 16 +++++++++++++++- invoke.sh | 14 ++++++++++++-- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index b59c384391..5853512edc 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -88,11 +88,8 @@ call python scripts\preload_models.py @rem make the models dir mkdir models\ldm\stable-diffusion-v1 -@rem tell the user that they need to download the ckpt +@rem tell the user their next steps echo. -echo "Now you need to install the weights for the stable diffusion model." -echo "Please follow the steps at https://invoke-ai.github.io/InvokeAI/installation/INSTALL_WINDOWS/ to complete the installation" - -@rem it would be nice if the weights downloaded automatically, and didn't need the user to do this manually. +echo "You can now start generating images by double-clicking the 'invoke.bat' file (inside this folder) pause diff --git a/installer/install.sh b/installer/install.sh index 9549c3339d..83eff3513f 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -110,14 +110,5 @@ python scripts/preload_models.py # make the models dir mkdir models/ldm/stable-diffusion-v1 -# tell the user that they need to download the ckpt -WEIGHTS_DOC_URL="https://invoke-ai.github.io/InvokeAI/installation/INSTALL_LINUX/" -if [ "$OS_NAME" == "mac" ]; then - WEIGHTS_DOC_URL="https://invoke-ai.github.io/InvokeAI/installation/INSTALL_MAC/" -fi - -echo "" -echo "Now you need to install the weights for the stable diffusion model." -echo "Please follow the steps at $WEIGHTS_DOC_URL to complete the installation" - -# it would be nice if the weights downloaded automatically, and didn't need the user to do this manually. +# tell the user their next steps +echo "You can now start generating images by running invoke.sh (inside this folder), using ./invoke.sh" diff --git a/invoke.bat b/invoke.bat index b9fb7902de..617707d17d 100644 --- a/invoke.bat +++ b/invoke.bat @@ -5,6 +5,20 @@ set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scrip call conda activate invokeai -echo Ready to dream.. +echo Do you want to generate images using the +echo 1. command-line +echo 2. browser-based UI +set /P restore="Please enter 1 or 2: " +IF /I "%restore%" == "1" ( + echo Starting the InvokeAI command-line.. + python scripts\invoke.py +) ELSE IF /I "%restore%" == "2" ( + echo Starting the InvokeAI browser-based UI.. + python scripts\invoke.py --web +) ELSE ( + echo Invalid selection + pause + exit /b +) cmd /k diff --git a/invoke.sh b/invoke.sh index 6257aaefa2..ca703e14ec 100755 --- a/invoke.sh +++ b/invoke.sh @@ -1,5 +1,6 @@ #!/bin/bash +cd "$(dirname "${BASH_SOURCE[0]}")" if [ "$0" == "bash" ]; then INSTALL_ENV_DIR="$(pwd)/installer_files/env" @@ -10,7 +11,16 @@ if [ "$0" == "bash" ]; then conda activate invokeai - echo "Ready to dream.." + echo "Do you want to generate images using the" + echo "1. command-line" + echo "2. browser-based UI" + read -p "Please enter 1 or 2: " yn + case $yn in + 1 ) printf "\nStarting the InvokeAI command-line..\n"; python scripts/invoke.py; break;; + 2 ) printf "\nStarting the InvokeAI browser-based UI..\n"; python scripts/invoke.py --web; break;; + * ) echo "Invalid selection"; exit;; + esac else - bash --init-file invoke.sh + file_name=$(basename "${BASH_SOURCE[0]}") + bash --init-file "$file_name" fi From 91b491b7e74a685563c27aac3c41da052e33e3f5 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 23:07:48 +0530 Subject: [PATCH 51/57] Don't need to create the models folder using this script --- installer/install.bat | 3 --- installer/install.sh | 3 --- 2 files changed, 6 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index 5853512edc..508c9ced4f 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -85,9 +85,6 @@ call conda activate invokeai @rem preload the models call python scripts\preload_models.py -@rem make the models dir -mkdir models\ldm\stable-diffusion-v1 - @rem tell the user their next steps echo. echo "You can now start generating images by double-clicking the 'invoke.bat' file (inside this folder) diff --git a/installer/install.sh b/installer/install.sh index 83eff3513f..ea576ddda9 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -107,8 +107,5 @@ conda activate invokeai # preload the models python scripts/preload_models.py -# make the models dir -mkdir models/ldm/stable-diffusion-v1 - # tell the user their next steps echo "You can now start generating images by running invoke.sh (inside this folder), using ./invoke.sh" From 2b078c0d6ed10e9afbd9b6eec41e44da780f5255 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 23:14:58 +0530 Subject: [PATCH 52/57] Don't need break --- invoke.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/invoke.sh b/invoke.sh index ca703e14ec..631e020fea 100755 --- a/invoke.sh +++ b/invoke.sh @@ -16,8 +16,8 @@ if [ "$0" == "bash" ]; then echo "2. browser-based UI" read -p "Please enter 1 or 2: " yn case $yn in - 1 ) printf "\nStarting the InvokeAI command-line..\n"; python scripts/invoke.py; break;; - 2 ) printf "\nStarting the InvokeAI browser-based UI..\n"; python scripts/invoke.py --web; break;; + 1 ) printf "\nStarting the InvokeAI command-line..\n"; python scripts/invoke.py;; + 2 ) printf "\nStarting the InvokeAI browser-based UI..\n"; python scripts/invoke.py --web;; * ) echo "Invalid selection"; exit;; esac else From 4134e2e9dae71c3e1f8201dd3b5df50efb04390b Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 23:22:24 +0530 Subject: [PATCH 53/57] Refactored invoke.sh to open a dev console only if the user wants it --- invoke.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/invoke.sh b/invoke.sh index 631e020fea..695fccb625 100755 --- a/invoke.sh +++ b/invoke.sh @@ -2,25 +2,24 @@ cd "$(dirname "${BASH_SOURCE[0]}")" -if [ "$0" == "bash" ]; then - INSTALL_ENV_DIR="$(pwd)/installer_files/env" - if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi +INSTALL_ENV_DIR="$(pwd)/installer_files/env" +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi - CONDA_BASEPATH=$(conda info --base) - source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) +CONDA_BASEPATH=$(conda info --base) +source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script) - conda activate invokeai +conda activate invokeai +if [ "$0" != "bash" ]; then echo "Do you want to generate images using the" echo "1. command-line" echo "2. browser-based UI" - read -p "Please enter 1 or 2: " yn + echo "3. open the developer console" + read -p "Please enter 1, 2, or 3: " yn case $yn in 1 ) printf "\nStarting the InvokeAI command-line..\n"; python scripts/invoke.py;; 2 ) printf "\nStarting the InvokeAI browser-based UI..\n"; python scripts/invoke.py --web;; + 3 ) printf "\nDeveloper Console:\n"; file_name=$(basename "${BASH_SOURCE[0]}"); bash --init-file "$file_name";; * ) echo "Invalid selection"; exit;; esac -else - file_name=$(basename "${BASH_SOURCE[0]}") - bash --init-file "$file_name" fi From c49d9c26119e56c960f9ad3e280152270b77d927 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 23:26:21 +0530 Subject: [PATCH 54/57] Open the developer console on windows, and print some debugging info --- invoke.bat | 11 ++++++++--- invoke.sh | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/invoke.bat b/invoke.bat index 617707d17d..62a1adb7c6 100644 --- a/invoke.bat +++ b/invoke.bat @@ -8,17 +8,22 @@ call conda activate invokeai echo Do you want to generate images using the echo 1. command-line echo 2. browser-based UI -set /P restore="Please enter 1 or 2: " +echo 3. open the developer console +set /P restore="Please enter 1, 2 or 3: " IF /I "%restore%" == "1" ( echo Starting the InvokeAI command-line.. python scripts\invoke.py ) ELSE IF /I "%restore%" == "2" ( echo Starting the InvokeAI browser-based UI.. python scripts\invoke.py --web +) ELSE IF /I "%restore%" == "3" ( + echo Developer Console + call where python + call python --version + + cmd /k ) ELSE ( echo Invalid selection pause exit /b ) - -cmd /k diff --git a/invoke.sh b/invoke.sh index 695fccb625..22c754583c 100755 --- a/invoke.sh +++ b/invoke.sh @@ -22,4 +22,7 @@ if [ "$0" != "bash" ]; then 3 ) printf "\nDeveloper Console:\n"; file_name=$(basename "${BASH_SOURCE[0]}"); bash --init-file "$file_name";; * ) echo "Invalid selection"; exit;; esac +else + which python + python --version fi From 4b27d8821d3ee38274cffcb6db9bd985e908e16c Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 23:40:03 +0530 Subject: [PATCH 55/57] Script to create the installer zips --- installer/How to create the installers.md | 5 ----- installer/create_installers.sh | 20 ++++++++++++++++++++ installer/readme.txt | 11 +++++++++++ invoke.sh | 2 +- 4 files changed, 32 insertions(+), 6 deletions(-) delete mode 100644 installer/How to create the installers.md create mode 100644 installer/create_installers.sh create mode 100644 installer/readme.txt diff --git a/installer/How to create the installers.md b/installer/How to create the installers.md deleted file mode 100644 index 8030ff7790..0000000000 --- a/installer/How to create the installers.md +++ /dev/null @@ -1,5 +0,0 @@ -**Important:** These instructions are for the developers of this project, not for users! The users should use the pre-created zip files for installation. - -Just distribute the `install.bat` or `install.sh` file. - -Running that file will download the invokeAI repository into the same folder as the script, and install the required dependencies. diff --git a/installer/create_installers.sh b/installer/create_installers.sh new file mode 100644 index 0000000000..842b782131 --- /dev/null +++ b/installer/create_installers.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# make the installer zip for linux and mac +rm -rf invokeAI +mkdir -p invokeAI +cp install.sh invokeAI +cp readme.txt invokeAI + +zip -r invokeAI-linux.zip invokeAI +zip -r invokeAI-mac.zip invokeAI + +# make the installer zip for windows +rm -rf invokeAI +mkdir -p invokeAI +cp install.bat invokeAI +cp readme.txt invokeAI + +zip -r invokeAI-windows.zip invokeAI + +echo "The installer zips are ready to be distributed.." diff --git a/installer/readme.txt b/installer/readme.txt new file mode 100644 index 0000000000..a5b8537a39 --- /dev/null +++ b/installer/readme.txt @@ -0,0 +1,11 @@ +InvokeAI + +Project homepage: https://github.com/invoke-ai/InvokeAI + +Installation on Windows: + Please double-click the 'install.bat' file (while keeping it inside the invokeAI folder). + +Installation on Linux and Mac: + Please open the terminal, and run './install.sh' (while keeping it inside the invokeAI folder). + +After installation, please run the 'invoke.bat' file (on Windows) or 'invoke.sh' file (on Linux/Mac) to start InvokeAI. \ No newline at end of file diff --git a/invoke.sh b/invoke.sh index 22c754583c..55a0292e6e 100755 --- a/invoke.sh +++ b/invoke.sh @@ -22,7 +22,7 @@ if [ "$0" != "bash" ]; then 3 ) printf "\nDeveloper Console:\n"; file_name=$(basename "${BASH_SOURCE[0]}"); bash --init-file "$file_name";; * ) echo "Invalid selection"; exit;; esac -else +else # in developer console which python python --version fi From 09ee1b1877ca82c7355f8fe72b21ea275d3364e8 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 23:41:00 +0530 Subject: [PATCH 56/57] Run the installer create script inside its own directory --- installer/create_installers.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/installer/create_installers.sh b/installer/create_installers.sh index 842b782131..1b1d634ca6 100644 --- a/installer/create_installers.sh +++ b/installer/create_installers.sh @@ -1,5 +1,7 @@ #!/bin/bash +cd "$(dirname "${BASH_SOURCE[0]}")" + # make the installer zip for linux and mac rm -rf invokeAI mkdir -p invokeAI From 9c264b42c3c0f89f45a9ca2b349f1849e766ea6b Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 23:41:37 +0530 Subject: [PATCH 57/57] Make create_installers.sh executable --- installer/create_installers.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 installer/create_installers.sh diff --git a/installer/create_installers.sh b/installer/create_installers.sh old mode 100644 new mode 100755