From 32719e3ad1a4e49f88b6cf0f3baa5d4f5abda40f Mon Sep 17 00:00:00 2001 From: lllyasviel Date: Tue, 19 Sep 2023 12:11:41 -0700 Subject: [PATCH] fix vram problems (#437) --- fooocus_version.py | 2 +- launch.py | 19 +------------------ modules/launch_util.py | 11 ++++++++--- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/fooocus_version.py b/fooocus_version.py index e1274470..e6e36dd5 100644 --- a/fooocus_version.py +++ b/fooocus_version.py @@ -1 +1 @@ -version = '2.0.65' +version = '2.0.66' diff --git a/launch.py b/launch.py index ef13bee5..fe32c4d6 100644 --- a/launch.py +++ b/launch.py @@ -33,23 +33,6 @@ def prepare_environment(): if REINSTALL_ALL or not is_installed("torch") or not is_installed("torchvision"): run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True) - import torch - - def detect_gpu_type(): - if torch.cuda.is_available(): - gpu_name = torch.cuda.get_device_name(0) - if "NVIDIA" in gpu_name: - return "NVIDIA GPU" - elif "Radeon" in gpu_name: - return "AMD GPU" - else: - return "Unknown GPU Type" - else: - return "No GPU Available" - - gpu_type = detect_gpu_type() - print("Detected GPU Type:", gpu_type) - if REINSTALL_ALL or not is_installed("xformers"): if platform.system() == "Windows": if platform.python_version().startswith("3.10"): @@ -60,7 +43,7 @@ def prepare_environment(): "You can also check this and build manually: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Xformers#building-xformers-on-windows-by-duckness") if not is_installed("xformers"): exit(0) - elif platform.system() == "Linux" and gpu_type == 'NVIDIA GPU': + elif platform.system() == "Linux": run_pip(f"install -U -I --no-deps {xformers_package}", "xformers") if REINSTALL_ALL or not requirements_met(requirements_file): diff --git a/modules/launch_util.py b/modules/launch_util.py index 16cf48e2..71a64ff6 100644 --- a/modules/launch_util.py +++ b/modules/launch_util.py @@ -91,9 +91,14 @@ def run(command, desc=None, errdesc=None, custom_env=None, live: bool = default_ def run_pip(command, desc=None, live=default_command_live): - index_url_line = f' --index-url {index_url}' if index_url != '' else '' - return run(f'"{python}" -m pip {command} --prefer-binary{index_url_line}', desc=f"Installing {desc}", - errdesc=f"Couldn't install {desc}", live=live) + try: + index_url_line = f' --index-url {index_url}' if index_url != '' else '' + return run(f'"{python}" -m pip {command} --prefer-binary{index_url_line}', desc=f"Installing {desc}", + errdesc=f"Couldn't install {desc}", live=live) + except Exception as e: + print(e) + print(f'CMD Failed {desc}: {command}') + return None re_requirement = re.compile(r"\s*([-_a-zA-Z0-9]+)\s*(?:==\s*([-+_.a-zA-Z0-9]+))?\s*")