mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-10-01 01:26:03 -04:00
Merge pull request #4029 from jllllll/one-click
Various one-click-installer updates and fixes
This commit is contained in:
commit
84b5a519cb
@ -4,6 +4,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
|
|||||||
|
|
||||||
if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
|
if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
|
||||||
|
|
||||||
|
# deactivate existing conda envs as needed to avoid conflicts
|
||||||
|
{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null
|
||||||
|
|
||||||
# config
|
# config
|
||||||
CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda"
|
CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda"
|
||||||
INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
||||||
|
@ -4,8 +4,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
|
|||||||
|
|
||||||
if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
|
if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
|
||||||
|
|
||||||
# deactivate existing env if needed
|
# deactivate existing conda envs as needed to avoid conflicts
|
||||||
conda deactivate 2> /dev/null
|
{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null
|
||||||
|
|
||||||
# config
|
# config
|
||||||
CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda"
|
CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda"
|
||||||
|
@ -10,6 +10,9 @@ echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniconda which c
|
|||||||
set TMP=%cd%\installer_files
|
set TMP=%cd%\installer_files
|
||||||
set TEMP=%cd%\installer_files
|
set TEMP=%cd%\installer_files
|
||||||
|
|
||||||
|
@rem deactivate existing conda envs as needed to avoid conflicts
|
||||||
|
(conda deactivate && conda deactivate && conda deactivate) 2>null
|
||||||
|
|
||||||
@rem config
|
@rem config
|
||||||
set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
|
set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
|
||||||
set INSTALL_ENV_DIR=%cd%\installer_files\env
|
set INSTALL_ENV_DIR=%cd%\installer_files\env
|
||||||
|
@ -4,6 +4,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
|
|||||||
|
|
||||||
if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
|
if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
|
||||||
|
|
||||||
|
# deactivate existing conda envs as needed to avoid conflicts
|
||||||
|
{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null
|
||||||
|
|
||||||
OS_ARCH=$(uname -m)
|
OS_ARCH=$(uname -m)
|
||||||
case "${OS_ARCH}" in
|
case "${OS_ARCH}" in
|
||||||
x86_64*) OS_ARCH="x86_64";;
|
x86_64*) OS_ARCH="x86_64";;
|
||||||
|
@ -4,6 +4,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
|
|||||||
|
|
||||||
if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
|
if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
|
||||||
|
|
||||||
|
# deactivate existing conda envs as needed to avoid conflicts
|
||||||
|
{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null
|
||||||
|
|
||||||
# M Series or Intel
|
# M Series or Intel
|
||||||
OS_ARCH=$(uname -m)
|
OS_ARCH=$(uname -m)
|
||||||
case "${OS_ARCH}" in
|
case "${OS_ARCH}" in
|
||||||
|
@ -17,6 +17,9 @@ set SPCHARMESSAGE=
|
|||||||
set TMP=%cd%\installer_files
|
set TMP=%cd%\installer_files
|
||||||
set TEMP=%cd%\installer_files
|
set TEMP=%cd%\installer_files
|
||||||
|
|
||||||
|
@rem deactivate existing conda envs as needed to avoid conflicts
|
||||||
|
(conda deactivate && conda deactivate && conda deactivate) 2>null
|
||||||
|
|
||||||
@rem config
|
@rem config
|
||||||
set INSTALL_DIR=%cd%\installer_files
|
set INSTALL_DIR=%cd%\installer_files
|
||||||
set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
|
set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
|
||||||
|
@ -4,6 +4,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
|
|||||||
|
|
||||||
if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
|
if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
|
||||||
|
|
||||||
|
# deactivate existing conda envs as needed to avoid conflicts
|
||||||
|
{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null
|
||||||
|
|
||||||
# config
|
# config
|
||||||
CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda"
|
CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda"
|
||||||
INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
||||||
|
@ -4,6 +4,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
|
|||||||
|
|
||||||
if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
|
if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
|
||||||
|
|
||||||
|
# deactivate existing conda envs as needed to avoid conflicts
|
||||||
|
{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null
|
||||||
|
|
||||||
# config
|
# config
|
||||||
CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda"
|
CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda"
|
||||||
INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
||||||
|
@ -10,6 +10,9 @@ echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniconda which c
|
|||||||
set TMP=%cd%\installer_files
|
set TMP=%cd%\installer_files
|
||||||
set TEMP=%cd%\installer_files
|
set TEMP=%cd%\installer_files
|
||||||
|
|
||||||
|
@rem deactivate existing conda envs as needed to avoid conflicts
|
||||||
|
(conda deactivate && conda deactivate && conda deactivate) 2>null
|
||||||
|
|
||||||
@rem config
|
@rem config
|
||||||
set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
|
set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
|
||||||
set INSTALL_ENV_DIR=%cd%\installer_files\env
|
set INSTALL_ENV_DIR=%cd%\installer_files\env
|
||||||
|
23
webui.py
23
webui.py
@ -2,6 +2,7 @@ import argparse
|
|||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import site
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
script_dir = os.getcwd()
|
script_dir = os.getcwd()
|
||||||
@ -77,6 +78,16 @@ def clear_cache():
|
|||||||
run_cmd("conda clean -a -y", environment=True)
|
run_cmd("conda clean -a -y", environment=True)
|
||||||
run_cmd("python -m pip cache purge", environment=True)
|
run_cmd("python -m pip cache purge", environment=True)
|
||||||
|
|
||||||
|
def is_installed():
|
||||||
|
for sitedir in site.getsitepackages():
|
||||||
|
if "site-packages" in sitedir and conda_env_path in sitedir:
|
||||||
|
site_packages_path = sitedir
|
||||||
|
break
|
||||||
|
|
||||||
|
if site_packages_path:
|
||||||
|
return os.path.isfile(os.path.join(site_packages_path, 'torch', '__init__.py'))
|
||||||
|
else:
|
||||||
|
return os.path.isdir(conda_env_path)
|
||||||
|
|
||||||
def install_dependencies():
|
def install_dependencies():
|
||||||
# Select your GPU or, choose to run in CPU mode
|
# Select your GPU or, choose to run in CPU mode
|
||||||
@ -117,7 +128,12 @@ def install_dependencies():
|
|||||||
|
|
||||||
|
|
||||||
def update_dependencies(initial_installation=False):
|
def update_dependencies(initial_installation=False):
|
||||||
# run_cmd("git pull", assert_success=True, environment=True) # TODO uncomment before merging (is there a better way?)
|
# Create .git directory if missing
|
||||||
|
if not os.path.isdir(os.path.join(script_dir, ".git")):
|
||||||
|
git_creation_cmd = 'git init -b main && git remote add origin https://github.com/oobabooga/text-generation-webui && git fetch && git remote set-head origin -a && git reset origin/HEAD && git branch --set-upstream-to=origin/HEAD'
|
||||||
|
run_cmd(git_creation_cmd, environment=True, assert_success=True)
|
||||||
|
|
||||||
|
run_cmd("git pull --autostash", assert_success=True, environment=True) # TODO is there a better way?
|
||||||
|
|
||||||
# Install the extensions dependencies (only on the first install)
|
# Install the extensions dependencies (only on the first install)
|
||||||
if initial_installation:
|
if initial_installation:
|
||||||
@ -230,13 +246,12 @@ if __name__ == "__main__":
|
|||||||
update_dependencies()
|
update_dependencies()
|
||||||
else:
|
else:
|
||||||
# If webui has already been installed, skip and run
|
# If webui has already been installed, skip and run
|
||||||
# if not os.path.exists("text-generation-webui/"):
|
if not is_installed():
|
||||||
if True: # TODO implement a new installation check
|
|
||||||
install_dependencies()
|
install_dependencies()
|
||||||
os.chdir(script_dir)
|
os.chdir(script_dir)
|
||||||
|
|
||||||
# Check if a model has been downloaded yet
|
# Check if a model has been downloaded yet
|
||||||
if len([item for item in glob.glob('text-generation-webui/models/*') if not item.endswith(('.txt', '.yaml'))]) == 0:
|
if len([item for item in glob.glob('models/*') if not item.endswith(('.txt', '.yaml'))]) == 0:
|
||||||
print_big_message("WARNING: You haven't downloaded any model yet.\nOnce the web UI launches, head over to the \"Model\" tab and download one.")
|
print_big_message("WARNING: You haven't downloaded any model yet.\nOnce the web UI launches, head over to the \"Model\" tab and download one.")
|
||||||
|
|
||||||
# Workaround for llama-cpp-python loading paths in CUDA env vars even if they do not exist
|
# Workaround for llama-cpp-python loading paths in CUDA env vars even if they do not exist
|
||||||
|
32
wsl.sh
32
wsl.sh
@ -15,11 +15,15 @@ read -n1 -p "Continue the installer anyway? [y,n]" EXIT_PROMPT
|
|||||||
if ! [[ $EXIT_PROMPT == "Y" || $EXIT_PROMPT == "y" ]]; then exit; fi
|
if ! [[ $EXIT_PROMPT == "Y" || $EXIT_PROMPT == "y" ]]; then exit; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# deactivate any currently active conda env
|
# deactivate existing conda envs as needed to avoid conflicts
|
||||||
conda deactivate 2> /dev/null
|
{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null
|
||||||
|
|
||||||
# config unlike other scripts, can't use current directory due to file IO bug in WSL, needs to be in virtual drive
|
# config unlike other scripts, can't use current directory due to file IO bug in WSL, needs to be in virtual drive
|
||||||
INSTALL_DIR="$HOME/text-gen-install"
|
INSTALL_DIR_PREFIX="$HOME/text-gen-install"
|
||||||
|
if [[ ! $(realpath "$(pwd)/..") = /mnt/* ]]; then
|
||||||
|
INSTALL_DIR_PREFIX="$(realpath "$(pwd)/..")" && INSTALL_INPLACE=1
|
||||||
|
fi
|
||||||
|
INSTALL_DIR="$INSTALL_DIR_PREFIX/text-generation-webui"
|
||||||
CONDA_ROOT_PREFIX="$INSTALL_DIR/installer_files/conda"
|
CONDA_ROOT_PREFIX="$INSTALL_DIR/installer_files/conda"
|
||||||
INSTALL_ENV_DIR="$INSTALL_DIR/installer_files/env"
|
INSTALL_ENV_DIR="$INSTALL_DIR/installer_files/env"
|
||||||
MINICONDA_DOWNLOAD_URL="https://repo.anaconda.com/miniconda/Miniconda3-py310_23.3.1-0-Linux-x86_64.sh"
|
MINICONDA_DOWNLOAD_URL="https://repo.anaconda.com/miniconda/Miniconda3-py310_23.3.1-0-Linux-x86_64.sh"
|
||||||
@ -66,11 +70,9 @@ if [ "$conda_exists" == "F" ]; then
|
|||||||
"$CONDA_ROOT_PREFIX/bin/conda" --version
|
"$CONDA_ROOT_PREFIX/bin/conda" --version
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $INSTALL_DIR
|
|
||||||
|
|
||||||
# create the installer env
|
# create the installer env
|
||||||
if [ ! -e "$INSTALL_ENV_DIR" ]; then
|
if [ ! -e "$INSTALL_ENV_DIR" ]; then
|
||||||
"$CONDA_ROOT_PREFIX/bin/conda" create -y -k --prefix "$INSTALL_ENV_DIR" python=3.10
|
"$CONDA_ROOT_PREFIX/bin/conda" create -y -k --prefix "$INSTALL_ENV_DIR" python=3.10 git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if conda environment was actually created
|
# check if conda environment was actually created
|
||||||
@ -83,6 +85,24 @@ fi
|
|||||||
source "$CONDA_ROOT_PREFIX/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script)
|
source "$CONDA_ROOT_PREFIX/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script)
|
||||||
conda activate "$INSTALL_ENV_DIR"
|
conda activate "$INSTALL_ENV_DIR"
|
||||||
|
|
||||||
|
# copy webui.py and CMD_FLAGS.txt to install dir to allow edits within Windows
|
||||||
|
if [[ $INSTALL_INPLACE != 1 ]]; then
|
||||||
|
cp -u "./webui.py" "$INSTALL_DIR"
|
||||||
|
if [ -f "./CMD_FLAGS.txt" ]; then cp -u "./CMD_FLAGS.txt" "$INSTALL_DIR"; fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $INSTALL_DIR
|
||||||
|
|
||||||
|
if [ ! -f "./server.py" ]; then
|
||||||
|
git init -b main
|
||||||
|
git remote add origin https://github.com/oobabooga/text-generation-webui
|
||||||
|
git fetch
|
||||||
|
git remote set-head origin -a
|
||||||
|
git reset origin/HEAD --hard
|
||||||
|
git branch --set-upstream-to=origin/HEAD
|
||||||
|
git restore -- . :!./webui.py :!./CMD_FLAGS.txt
|
||||||
|
fi
|
||||||
|
|
||||||
# setup installer env update env if called with 'wsl.sh update'
|
# setup installer env update env if called with 'wsl.sh update'
|
||||||
case "$1" in
|
case "$1" in
|
||||||
("update") python webui.py --update;;
|
("update") python webui.py --update;;
|
||||||
|
Loading…
Reference in New Issue
Block a user