mirror of
https://github.com/vladmandic/automatic
synced 2026-09-07 05:20:47 +02:00
cleanup installer
This commit is contained in:
@@ -13,7 +13,6 @@ except:
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description="Stable Diffusion", conflict_handler='resolve', formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=55, indent_increment=2, width=200))
|
||||
|
||||
|
||||
class Dot(dict): # dot notation access to dictionary attributes
|
||||
__getattr__ = dict.get
|
||||
__setattr__ = dict.__setitem__
|
||||
@@ -224,9 +223,9 @@ def check_torch():
|
||||
import torch
|
||||
log.info(f'Torch {torch.__version__}')
|
||||
if shared.cmd_opts.use_ipex:
|
||||
import intel_extension_for_pytorch as ipex
|
||||
log.info(f'Torch backend: Intel OneAPI {torch.__version__}')
|
||||
log.info(f'Torch detected GPU: {torch.xpu.get_device_name("xpu")} VRAM {round(torch.xpu.get_device_properties("xpu").total_memory / 1024 / 1024)}')
|
||||
import intel_extension_for_pytorch as ipex # pylint: disable=import-error, unused-import
|
||||
log.info(f'Torch backend: Intel OneAPI {torch.__version__}')
|
||||
log.info(f'Torch detected GPU: {torch.xpu.get_device_name("xpu")} VRAM {round(torch.xpu.get_device_properties("xpu").total_memory / 1024 / 1024)}')
|
||||
elif torch.cuda.is_available():
|
||||
if torch.version.cuda:
|
||||
log.info(f'Torch backend: nVidia CUDA {torch.version.cuda} cuDNN {torch.backends.cudnn.version() if torch.backends.cudnn.is_available() else "N/A"}')
|
||||
@@ -524,6 +523,7 @@ def add_args():
|
||||
group.add_argument('--debug', default = False, action='store_true', help = "Run installer with debug logging, default: %(default)s")
|
||||
group.add_argument('--reset', default = False, action='store_true', help = "Reset main repository to latest version, default: %(default)s")
|
||||
group.add_argument('--upgrade', default = False, action='store_true', help = "Upgrade main repository to latest version, default: %(default)s")
|
||||
group.add_argument("--use-ipex", action='store_true', help="Use Intel OneAPI XPU backend, default: %(default)s", default=False)
|
||||
group.add_argument('--no-directml', default = False, action='store_true', help = "Use CPU instead of DirectML if no compatible GPU is detected, default: %(default)s")
|
||||
group.add_argument('--skip-update', default = False, action='store_true', help = "Skip update of extensions and submodules, default: %(default)s")
|
||||
group.add_argument('--skip-requirements', default = False, action='store_true', help = "Skips checking and installing requirements, default: %(default)s")
|
||||
@@ -1,23 +1,24 @@
|
||||
### majority of this file is superflous, but used by some extensions as helpers during extension installation
|
||||
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
import shlex
|
||||
import logging
|
||||
import setup
|
||||
import modules.paths_internal
|
||||
import modules.cmd_args
|
||||
|
||||
setup.ensure_base_requirements()
|
||||
from rich import print # pylint: disable=redefined-builtin,wrong-import-order
|
||||
|
||||
### majority of this file is superflous, but used by some extensions as helpers during extension installation
|
||||
|
||||
commandline_args = os.environ.get('COMMANDLINE_ARGS', "")
|
||||
sys.argv += shlex.split(commandline_args)
|
||||
setup.add_args()
|
||||
setup.extensions_preload(force=False)
|
||||
setup.parse_args()
|
||||
|
||||
import installer
|
||||
installer.add_args()
|
||||
installer.ensure_base_requirements()
|
||||
installer.extensions_preload(force=False)
|
||||
installer.parse_args()
|
||||
|
||||
import modules.cmd_args
|
||||
args, _ = modules.cmd_args.parser.parse_known_args()
|
||||
|
||||
import modules.paths_internal
|
||||
script_path = modules.paths_internal.script_path
|
||||
extensions_dir = modules.paths_internal.extensions_dir
|
||||
git = os.environ.get('GIT', "git")
|
||||
@@ -41,6 +42,7 @@ def commit_hash():
|
||||
|
||||
def run(command, desc=None, errdesc=None, custom_env=None, live=False):
|
||||
if desc is not None:
|
||||
from rich import print # pylint: disable=redefined-builtin,wrong-import-order
|
||||
print(desc)
|
||||
if live:
|
||||
result = subprocess.run(command, check=False, shell=True, env=os.environ if custom_env is None else custom_env)
|
||||
@@ -62,7 +64,7 @@ def check_run(command):
|
||||
|
||||
|
||||
def is_installed(package):
|
||||
return setup.installed(package)
|
||||
return installer.installed(package)
|
||||
|
||||
|
||||
def repo_dir(name):
|
||||
@@ -85,20 +87,20 @@ def check_run_python(code):
|
||||
|
||||
|
||||
def git_clone(url, tgt, _name, commithash=None):
|
||||
setup.clone(url, tgt, commithash)
|
||||
installer.clone(url, tgt, commithash)
|
||||
|
||||
|
||||
def run_extension_installer(ext_dir):
|
||||
setup.run_extension_installer(ext_dir)
|
||||
installer.run_extension_installer(ext_dir)
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup.run_setup()
|
||||
setup.extensions_preload(force=True)
|
||||
setup.log.info(f"Server arguments: {sys.argv[1:]}")
|
||||
setup.log.debug('Starting WebUI')
|
||||
installer.run_setup()
|
||||
installer.extensions_preload(force=True)
|
||||
installer.log.info(f"Server arguments: {sys.argv[1:]}")
|
||||
installer.log.debug('Starting WebUI')
|
||||
logging.disable(logging.INFO)
|
||||
if args.test:
|
||||
setup.log.info("Test only")
|
||||
installer.log.info("Test only")
|
||||
import webui
|
||||
exit(0)
|
||||
import webui
|
||||
|
||||
+1
-2
@@ -27,7 +27,6 @@ group.add_argument("--allow-code", action='store_true', help="Allow custom scrip
|
||||
group.add_argument("--share", action='store_true', help="Enable UI accessible through Gradio site, default: %(default)s")
|
||||
group.add_argument("--insecure", action='store_true', help="Enable extensions tab regardless of other options, default: %(default)s")
|
||||
group.add_argument("--use-cpu", nargs='+', default=[], type=str.lower, help="Force use CPU for specified modules, default: %(default)s")
|
||||
group.add_argument("--use-ipex", action='store_true', help="Force use Intel OneAPI XPU backend, default: %(default)s", default=False)
|
||||
group.add_argument("--listen", action='store_true', help="Launch web server using public IP address, default: %(default)s")
|
||||
group.add_argument("--port", type=int, default=7860, help="Launch web server with given server port, default: %(default)s")
|
||||
group.add_argument("--freeze", action='store_true', help="Disable editing settings", default=False)
|
||||
@@ -97,6 +96,6 @@ def compatibility_args(opts, args):
|
||||
|
||||
group.add_argument("--lora-dir", help=argparse.SUPPRESS, default=opts.lora_dir)
|
||||
args = parser.parse_args()
|
||||
if 'lyco_dir' in args:
|
||||
if 'lyco_dir' in args: # pylint disable=unsupported-membership-test
|
||||
args.lyco_dir = opts.lyco_dir
|
||||
return args
|
||||
|
||||
+2
-2
@@ -12,11 +12,11 @@ import modules.devices as devices
|
||||
from modules import errors, ui_components, shared_items, cmd_args
|
||||
from modules.paths_internal import models_path, script_path, data_path, sd_configs_path, sd_default_config, sd_model_file, default_sd_model_file, extensions_dir, extensions_builtin_dir # pylint: disable=W0611
|
||||
import modules.paths_internal as paths
|
||||
from setup import log as setup_log # pylint: disable=E0611
|
||||
from installer import log as central_logger # pylint: disable=E0611
|
||||
|
||||
errors.install(gr)
|
||||
demo: gr.Blocks = None
|
||||
log = setup_log
|
||||
log = central_logger
|
||||
parser = cmd_args.parser
|
||||
url = 'https://github.com/vladmandic/automatic'
|
||||
if os.environ.get('IGNORE_CMD_ARGS_ERRORS', None) is None:
|
||||
|
||||
Reference in New Issue
Block a user