mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-22 08:07:56 +01:00
Better error handling during install/update
This commit is contained in:
parent
85f45cafa1
commit
822ba7fcbb
14
one_click.py
14
one_click.py
@ -25,6 +25,7 @@ else:
|
|||||||
|
|
||||||
flags = f"{' '.join([flag for flag in sys.argv[1:] if flag != '--update'])} {CMD_FLAGS}"
|
flags = f"{' '.join([flag for flag in sys.argv[1:] if flag != '--update'])} {CMD_FLAGS}"
|
||||||
|
|
||||||
|
|
||||||
def is_linux():
|
def is_linux():
|
||||||
return sys.platform.startswith("linux")
|
return sys.platform.startswith("linux")
|
||||||
|
|
||||||
@ -87,12 +88,12 @@ def check_env():
|
|||||||
conda_exist = run_cmd("conda", environment=True, capture_output=True).returncode == 0
|
conda_exist = run_cmd("conda", environment=True, capture_output=True).returncode == 0
|
||||||
if not conda_exist:
|
if not conda_exist:
|
||||||
print("Conda is not installed. Exiting...")
|
print("Conda is not installed. Exiting...")
|
||||||
sys.exit()
|
sys.exit(1)
|
||||||
|
|
||||||
# Ensure this is a new environment and not the base environment
|
# Ensure this is a new environment and not the base environment
|
||||||
if os.environ["CONDA_DEFAULT_ENV"] == "base":
|
if os.environ["CONDA_DEFAULT_ENV"] == "base":
|
||||||
print("Create an environment for this project and activate it. Exiting...")
|
print("Create an environment for this project and activate it. Exiting...")
|
||||||
sys.exit()
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def clear_cache():
|
def clear_cache():
|
||||||
@ -126,8 +127,8 @@ def run_cmd(cmd, assert_success=False, environment=False, capture_output=False,
|
|||||||
|
|
||||||
# Assert the command ran successfully
|
# Assert the command ran successfully
|
||||||
if assert_success and result.returncode != 0:
|
if assert_success and result.returncode != 0:
|
||||||
print("Command '" + cmd + "' failed with exit status code '" + str(result.returncode) + "'. Exiting...")
|
print("Command '" + cmd + "' failed with exit status code '" + str(result.returncode) + "'.\n\nExiting now.\nTry running the start/update script again.")
|
||||||
sys.exit()
|
sys.exit(1)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -138,6 +139,7 @@ def install_webui():
|
|||||||
choice = os.environ["GPU_CHOICE"].upper()
|
choice = os.environ["GPU_CHOICE"].upper()
|
||||||
print_big_message(f"Selected GPU choice \"{choice}\" based on the GPU_CHOICE environment variable.")
|
print_big_message(f"Selected GPU choice \"{choice}\" based on the GPU_CHOICE environment variable.")
|
||||||
else:
|
else:
|
||||||
|
print()
|
||||||
print("What is your GPU?")
|
print("What is your GPU?")
|
||||||
print()
|
print()
|
||||||
print("A) NVIDIA")
|
print("A) NVIDIA")
|
||||||
@ -166,7 +168,7 @@ def install_webui():
|
|||||||
install_pytorch = "python -m pip install torch==2.0.1+rocm5.4.2 torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.4.2"
|
install_pytorch = "python -m pip install torch==2.0.1+rocm5.4.2 torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.4.2"
|
||||||
else:
|
else:
|
||||||
print("AMD GPUs are only supported on Linux. Exiting...")
|
print("AMD GPUs are only supported on Linux. Exiting...")
|
||||||
sys.exit()
|
sys.exit(1)
|
||||||
elif is_linux() and (choice == "C" or choice == "N"):
|
elif is_linux() and (choice == "C" or choice == "N"):
|
||||||
install_pytorch = "python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu"
|
install_pytorch = "python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu"
|
||||||
elif choice == "D":
|
elif choice == "D":
|
||||||
@ -314,7 +316,7 @@ if __name__ == "__main__":
|
|||||||
# Check if a model has been downloaded yet
|
# Check if a model has been downloaded yet
|
||||||
if '--model-dir' in flags:
|
if '--model-dir' in flags:
|
||||||
# Splits on ' ' or '=' while maintaining spaces within quotes
|
# Splits on ' ' or '=' while maintaining spaces within quotes
|
||||||
flags_list = re.split(' +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)|=',flags)
|
flags_list = re.split(' +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)|=', flags)
|
||||||
model_dir = [flags_list[(flags_list.index(flag)+1)] for flag in flags_list if flag == '--model-dir'][0].strip('"\'')
|
model_dir = [flags_list[(flags_list.index(flag)+1)] for flag in flags_list if flag == '--model-dir'][0].strip('"\'')
|
||||||
else:
|
else:
|
||||||
model_dir = 'models'
|
model_dir = 'models'
|
||||||
|
@ -23,7 +23,4 @@ source "$CONDA_ROOT_PREFIX/etc/profile.d/conda.sh" # otherwise conda complains a
|
|||||||
conda activate "$INSTALL_ENV_DIR"
|
conda activate "$INSTALL_ENV_DIR"
|
||||||
|
|
||||||
# update installer env
|
# update installer env
|
||||||
python one_click.py --update
|
python one_click.py --update && echo -e "\nDone!"
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Done!"
|
|
||||||
|
@ -23,7 +23,4 @@ source "$CONDA_ROOT_PREFIX/etc/profile.d/conda.sh" # otherwise conda complains a
|
|||||||
conda activate "$INSTALL_ENV_DIR"
|
conda activate "$INSTALL_ENV_DIR"
|
||||||
|
|
||||||
# update installer env
|
# update installer env
|
||||||
python one_click.py --update
|
python one_click.py --update && echo -e "\nDone!"
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Done!"
|
|
||||||
|
@ -28,10 +28,10 @@ set "CUDA_HOME=%CUDA_PATH%"
|
|||||||
call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Miniconda hook not found. && goto end )
|
call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Miniconda hook not found. && goto end )
|
||||||
|
|
||||||
@rem update installer env
|
@rem update installer env
|
||||||
call python one_click.py --update
|
call python one_click.py --update && (
|
||||||
|
echo.
|
||||||
echo.
|
echo Done!
|
||||||
echo Done!
|
)
|
||||||
|
|
||||||
:end
|
:end
|
||||||
pause
|
pause
|
||||||
|
Loading…
Reference in New Issue
Block a user