Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refresh dev #2898

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cli/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
aiohttp
mediapipe
extcolors
colormap
filetype
albumentations
matplotlib
16 changes: 11 additions & 5 deletions installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'))):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand All @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion modules/postprocess/gfpgan_model.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions modules/textual_inversion/textual_inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 1 addition & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -30,7 +24,6 @@ resize-right
rich
safetensors
scipy
tb_nightly
tensordict==0.2.1
toml
torchdiffeq
Expand All @@ -40,7 +33,6 @@ scikit-image
fasteners
dctorch
pymatting
matplotlib
peft
orjson
httpx==0.24.1
Expand Down
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from ccc529 to 768eb2