From d6906c1bb7bb93f35c71b42a8293fcc6e85e1c04 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 22 Feb 2024 14:09:01 -0500 Subject: [PATCH 1/3] update git action --- .github/workflows/on_pull_request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on_pull_request.yaml b/.github/workflows/on_pull_request.yaml index 546c3a552..7abade093 100644 --- a/.github/workflows/on_pull_request.yaml +++ b/.github/workflows/on_pull_request.yaml @@ -21,7 +21,7 @@ jobs: python -m pip install --upgrade pip pip install pylint - name: pre-commit - uses: pre-commit-ci/lite-action@v1.0.1 + uses: pre-commit-ci/lite-action@v1.0.2 if: always() with: msg: apply code formatting and linting auto-fixes From b63a7d455c7982bed76ec31f9e364486fbffc658 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 22 Feb 2024 20:30:59 -0500 Subject: [PATCH 2/3] fix installer and requirements --- cli/requirements.txt | 3 +++ installer.py | 16 +++++++++++----- modules/postprocess/gfpgan_model.py | 5 ++++- modules/textual_inversion/textual_inversion.py | 2 ++ requirements.txt | 10 +--------- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/cli/requirements.txt b/cli/requirements.txt index a63adae95..4918412d5 100644 --- a/cli/requirements.txt +++ b/cli/requirements.txt @@ -1,4 +1,7 @@ +aiohttp mediapipe +extcolors colormap filetype albumentations +matplotlib diff --git a/installer.py b/installer.py index a2f857cc9..cfb322cf5 100644 --- a/installer.py +++ b/installer.py @@ -9,7 +9,7 @@ import cProfile try: - import pkg_resources # python 3.12 no longer packages it built-in + import pkg_resources # python 3.12 no longer has it built-in except ImportError: stdout = subprocess.run(f'"{sys.executable}" -m pip install setuptools', shell=True, check=False, env=os.environ, stdout=subprocess.PIPE, stderr=subprocess.PIPE) import pkg_resources @@ -405,13 +405,16 @@ def check_torch(): log.debug(f'Torch allowed: cuda={allow_cuda} rocm={allow_rocm} ipex={allow_ipex} diml={allow_directml} openvino={allow_openvino}') torch_command = os.environ.get('TORCH_COMMAND', '') xformers_package = os.environ.get('XFORMERS_PACKAGE', 'none') + def is_rocm_available(): if not allow_rocm: return False if platform.system() == 'Windows': hip_path = os.environ.get('HIP_PATH', None) return hip_path is not None and os.path.exists(os.path.join(hip_path, 'bin')) - return shutil.which('rocminfo') is not None or os.path.exists('/opt/rocm/bin/rocminfo') or os.path.exists('/dev/kfd') + else: + return shutil.which('rocminfo') is not None or os.path.exists('/opt/rocm/bin/rocminfo') or os.path.exists('/dev/kfd') + if torch_command != '': pass elif allow_cuda and (shutil.which('nvidia-smi') is not None or args.use_xformers or os.path.exists(os.path.join(os.environ.get('SystemRoot') or r'C:\Windows', 'System32', 'nvidia-smi.exe'))): @@ -439,7 +442,7 @@ def is_rocm_available(): amd_gpus = [x for x in amd_gpus if x and x != 'gfx000'] log.debug(f'ROCm agents detected: {amd_gpus}') except Exception as e: - log.debug(f'Run rocm_agent_enumerator failed: {e}') + log.debug(f'ROCm agent enumerator failed: {e}') amd_gpus = [] hip_visible_devices = [] # use the first available amd gpu by default @@ -481,6 +484,9 @@ def is_rocm_available(): torch_command = os.environ.get('TORCH_COMMAND', 'torch torchvision --index-url https://download.pytorch.org/whl/rocm5.5') if rocm_ver is not None: install(os.environ.get('ONNXRUNTIME_PACKAGE', get_onnxruntime_source_for_rocm(arr)), "onnxruntime-training built with ROCm", ignore=True) + else: + log.info('Using CPU-only Torch') + torch_command = os.environ.get('TORCH_COMMAND', 'torch torchvision') xformers_package = os.environ.get('XFORMERS_PACKAGE', 'none') elif allow_ipex and (args.use_ipex or shutil.which('sycl-ls') is not None or shutil.which('sycl-ls.exe') is not None or os.environ.get('ONEAPI_ROOT') is not None or os.path.exists('/opt/intel/oneapi') or os.path.exists("C:/Program Files (x86)/Intel/oneAPI") or os.path.exists("C:/oneAPI")): args.use_ipex = True # pylint: disable=attribute-defined-outside-init @@ -517,7 +523,7 @@ def is_rocm_available(): log.info('Using OpenVINO') torch_command = os.environ.get('TORCH_COMMAND', 'torch==2.2.0 torchvision==0.17.0 --index-url https://download.pytorch.org/whl/cpu') install(os.environ.get('OPENVINO_PACKAGE', 'openvino==2023.3.0'), 'openvino') - install('onnxruntime-openvino', 'onnxruntime-openvino', ignore=True) # TODO openvino: numpy version conflicts with tensorflow and doesn't support Python 3.11 + install('onnxruntime-openvino', 'onnxruntime-openvino', ignore=True) install('nncf==2.8.1', 'nncf') os.environ.setdefault('PYTORCH_TRACING_MODE', 'TORCHFX') os.environ.setdefault('NEOReadDebugKeys', '1') @@ -536,7 +542,7 @@ def is_rocm_available(): log.info('Using CPU-only Torch') torch_command = os.environ.get('TORCH_COMMAND', 'torch torchvision') if 'torch' in torch_command and not args.version: - # log.info('Installing torch - this may take a while') + log.debug(f'Installing torch: {torch_command}') install(torch_command, 'torch torchvision') else: try: diff --git a/modules/postprocess/gfpgan_model.py b/modules/postprocess/gfpgan_model.py index 98326e378..ee412012d 100644 --- a/modules/postprocess/gfpgan_model.py +++ b/modules/postprocess/gfpgan_model.py @@ -1,6 +1,6 @@ import os -import modules.face_restoration +from installer import install from modules import paths, shared, devices, modelloader, errors model_dir = "GFPGAN" @@ -72,8 +72,11 @@ def setup_model(dirname): except Exception: pass try: + install('basicsr') + install('gfpgan') import gfpgan import facexlib + import modules.face_restoration global user_path # pylint: disable=global-statement global have_gfpgan # pylint: disable=global-statement diff --git a/modules/textual_inversion/textual_inversion.py b/modules/textual_inversion/textual_inversion.py index fdf2342d4..d775cc722 100644 --- a/modules/textual_inversion/textual_inversion.py +++ b/modules/textual_inversion/textual_inversion.py @@ -9,6 +9,7 @@ import safetensors.torch import numpy as np from PIL import Image, PngImagePlugin +from installer import install from modules import shared, devices, processing, sd_models, images, errors import modules.textual_inversion.dataset from modules.textual_inversion.learn_schedule import LearnRateScheduler @@ -432,6 +433,7 @@ def write_loss(log_directory, filename, step, epoch_len, values): def tensorboard_setup(log_directory): + install('tensorboard') from torch.utils.tensorboard import SummaryWriter os.makedirs(os.path.join(log_directory, "tensorboard"), exist_ok=True) return SummaryWriter( diff --git a/requirements.txt b/requirements.txt index 1efe927cc..0415f98a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,12 @@ setuptools patch-ng -addict -aenum -aiohttp anyio -appdirs +addict astunparse blendmodes clean-fid -easydev -extcolors filetype future -gdown GitPython httpcore inflection @@ -30,7 +24,6 @@ resize-right rich safetensors scipy -tb_nightly tensordict==0.2.1 toml torchdiffeq @@ -40,7 +33,6 @@ scikit-image fasteners dctorch pymatting -matplotlib peft orjson httpx==0.24.1 From e0e4e41e6661442a3f6285d980618cd9fbcfd4bd Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 22 Feb 2024 20:31:17 -0500 Subject: [PATCH 3/3] update wiki --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index ccc5298bf..768eb2558 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit ccc5298bf570be6804d63eafe8c20a9791cd91aa +Subproject commit 768eb25585aa15610bad358ba1adb66aa987f9f6