mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
additional python 3.12 compatibility
This commit is contained in:
@@ -402,6 +402,8 @@ def check_python(supported_minors=[9, 10, 11, 12], reason=None):
|
||||
log.error(reason)
|
||||
if not args.ignore:
|
||||
sys.exit(1)
|
||||
if int(sys.version_info.minor) == 12:
|
||||
os.environ.setdefault('SETUPTOOLS_USE_DISTUTILS', 'local') # hack for python 3.11 setuptools
|
||||
if not args.skip_git:
|
||||
git_cmd = os.environ.get('GIT', "git")
|
||||
if shutil.which(git_cmd) is None:
|
||||
@@ -432,6 +434,7 @@ def check_onnx():
|
||||
|
||||
|
||||
def install_rocm_zluda(torch_command):
|
||||
check_python(supported_minors=[10,11], reason='RocM or Zluda backends require Python 3.10 or 3.11')
|
||||
is_windows = platform.system() == 'Windows'
|
||||
log.info('AMD ROCm toolkit detected')
|
||||
os.environ.setdefault('PYTORCH_HIP_ALLOC_CONF', 'garbage_collection_threshold:0.8,max_split_size_mb:512')
|
||||
@@ -539,6 +542,7 @@ def install_rocm_zluda(torch_command):
|
||||
|
||||
|
||||
def install_ipex(torch_command):
|
||||
check_python(supported_minors=[10,11], reason='IPEX backend requires Python 3.10 or 3.11')
|
||||
args.use_ipex = True # pylint: disable=attribute-defined-outside-init
|
||||
log.info('Intel OneAPI Toolkit detected')
|
||||
if os.environ.get("NEOReadDebugKeys", None) is None:
|
||||
@@ -579,6 +583,7 @@ def install_ipex(torch_command):
|
||||
|
||||
|
||||
def install_openvino(torch_command):
|
||||
check_python(supported_minors=[10,11], reason='IPEX backend requires Python 3.10 or 3.11')
|
||||
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')
|
||||
|
||||
+1
-1
@@ -235,7 +235,7 @@ def set_cuda_params():
|
||||
torch.use_deterministic_algorithms(shared.opts.cudnn_deterministic)
|
||||
log.debug(f'Torch mode: deterministic={shared.opts.cudnn_deterministic}')
|
||||
if shared.opts.cudnn_deterministic:
|
||||
os.environ['CUBLAS_WORKSPACE_CONFIG'] = ':4096:8'
|
||||
os.environ.setdefault('CUBLAS_WORKSPACE_CONFIG', ':4096:8')
|
||||
torch.backends.cudnn.benchmark = True
|
||||
if shared.opts.cudnn_benchmark:
|
||||
log.debug('Torch cuDNN: enable benchmark')
|
||||
|
||||
@@ -28,7 +28,6 @@ class UpscalerSD(Upscaler):
|
||||
shared.log.debug(f"Upscaler cached: type={scaler.name} model={path}")
|
||||
return self.models[path]
|
||||
else:
|
||||
devices.set_cuda_params()
|
||||
model = diffusers.DiffusionPipeline.from_pretrained(path, cache_dir=shared.opts.diffusers_dir, torch_dtype=devices.dtype)
|
||||
if hasattr(model, "set_progress_bar_config"):
|
||||
model.set_progress_bar_config(bar_format='Progress {rate_fmt}{postfix} {bar} {percentage:3.0f}% {n_fmt}/{total_fmt} {elapsed} {remaining} ' + '\x1b[38;5;71m' + 'Upscale', ncols=80, colour='#327fba')
|
||||
|
||||
@@ -78,7 +78,7 @@ def run_postprocessing(extras_mode, image, image_folder: List[tempfile.NamedTemp
|
||||
pp.image.info[k] = v
|
||||
if 'parameters' in items:
|
||||
info = items['parameters'] + ', '
|
||||
info = info + ", ".join([k if k == v else f'{k}: {info.quote(v)}' for k, v in pp.info.items() if v is not None])
|
||||
info = info + ", ".join([k if k == v else f'{k}: {infotext.quote(v)}' for k, v in pp.info.items() if v is not None])
|
||||
pp.image.info["postprocessing"] = info
|
||||
processed_images.append(pp.image)
|
||||
if save_output:
|
||||
|
||||
@@ -890,7 +890,6 @@ def load_diffuser(checkpoint_info=None, already_loaded_state_dict=None, timer=No
|
||||
timer = Timer()
|
||||
logging.getLogger("diffusers").setLevel(logging.ERROR)
|
||||
timer.record("diffusers")
|
||||
devices.set_cuda_params()
|
||||
diffusers_load_config = {
|
||||
"low_cpu_mem_usage": True,
|
||||
"torch_dtype": devices.dtype,
|
||||
@@ -1420,7 +1419,6 @@ def load_model(checkpoint_info=None, already_loaded_state_dict=None, timer=None,
|
||||
from modules import sd_hijack_inpainting
|
||||
sd_hijack_inpainting.do_inpainting_hijack()
|
||||
|
||||
devices.set_cuda_params()
|
||||
if already_loaded_state_dict is not None:
|
||||
state_dict = already_loaded_state_dict
|
||||
else:
|
||||
|
||||
@@ -32,7 +32,7 @@ class FaceRestorerYolo(FaceRestoration):
|
||||
|
||||
def dependencies(self):
|
||||
import installer
|
||||
installer.install('ultralytics', ignore=True)
|
||||
installer.install('ultralytics', ignore=True, quiet=True)
|
||||
|
||||
def predict(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user