diff --git a/CHANGELOG.md b/CHANGELOG.md index 97b52f055..ef27b3d7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ For full list of changes, see full changelog. - disable fallback on models with custom loaders - refactor triggering of prompt parser and set secondary prompts when needed - refactor handling of seeds + - allow unsafe ssl context for downloads - **Fixes** - extension tab: update checker, date handling, formatting etc., thanks @awsr - controlnet with non-english ui locales diff --git a/cli/download.py b/cli/download.py index c7a34d4b3..3abef8c29 100755 --- a/cli/download.py +++ b/cli/download.py @@ -40,7 +40,6 @@ def download_urllib(args): fn = '' req = urllib.request.Request(args.url, headers=headers) res = urllib.request.urlopen(req) - res.getheader('content-length') content_length = int(res.getheader('content-length') or 0) fn = get_filename(args, res) print(f'downloading: url={args.url} file={fn} size={content_length if content_length > 0 else "unknown"} lib=urllib block={args.block}') diff --git a/installer.py b/installer.py index c3bfe2c71..36bb17215 100644 --- a/installer.py +++ b/installer.py @@ -781,20 +781,20 @@ def install_rocm_zluda(): zluda_installer.install() zluda_installer.set_default_agent(device) except Exception as e: - log.warning(f'Failed to install ZLUDA: {e}') + log.error(f'Install ZLUDA: {e}') try: zluda_installer.load() except Exception as e: - log.warning(f'Failed to load ZLUDA: {e}') + log.error(f'Load ZLUDA: {e}') else: # TODO rocm: switch to pytorch source when it becomes available if device is None: - log.warning('No ROCm agent was found. Please make sure that graphics driver is installed and up to date.') + log.error('ROCm: no agent found - make sure that graphics driver is installed and up to date') if isinstance(rocm.environment, rocm.PythonPackageEnvironment): - check_python(supported_minors=[11, 12, 13], reason='ROCm backend requires a Python version between 3.11 and 3.13') + check_python(supported_minors=[11, 12, 13], reason='ROCm: python==3.11/3.12/3.13 required') torch_command = os.environ.get('TORCH_COMMAND', f'torch torchvision --index-url https://rocm.nightlies.amd.com/{device.therock}') else: - check_python(supported_minors=[12], reason='ROCm Windows preview requires Python version 3.12') + check_python(supported_minors=[12], reason='ROCm: Windows preview python==3.12 required') torch_command = os.environ.get('TORCH_COMMAND', '--no-cache-dir https://repo.radeon.com/rocm/windows/rocm-rel-6.4.4/torch-2.8.0a0%2Bgitfc14c65-cp312-cp312-win_amd64.whl https://repo.radeon.com/rocm/windows/rocm-rel-6.4.4/torchvision-0.24.0a0%2Bc85f008-cp312-cp312-win_amd64.whl') else: #check_python(supported_minors=[10, 11, 12, 13, 14], reason='ROCm backend requires a Python version between 3.10 and 3.13') diff --git a/modules/modelloader.py b/modules/modelloader.py index 81138aebb..26cb228c7 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -274,13 +274,16 @@ def load_civitai(model: str, url: str): def download_url_to_file(url: str, dst: str): # based on torch.hub.download_url_to_file + import ssl import uuid import tempfile from urllib.request import urlopen, Request from rich.progress import Progress, TextColumn, BarColumn, TaskProgressColumn, TimeRemainingColumn, TimeElapsedColumn file_size = None req = Request(url, headers={"User-Agent": "sdnext"}) - u = urlopen(req) # pylint: disable=R1732 + + context = ssl._create_unverified_context() # pylint: disable=protected-access + u = urlopen(req, context=context) # pylint: disable=R1732 meta = u.info() if hasattr(meta, 'getheaders'): content_length = meta.getheaders("Content-Length") diff --git a/modules/processing_prompt.py b/modules/processing_prompt.py index 828839df9..81b713934 100644 --- a/modules/processing_prompt.py +++ b/modules/processing_prompt.py @@ -105,7 +105,6 @@ def set_prompt(p, prompts, negative_prompts, prompts_2, negative_prompts_2 = fix_prompt_batch(p, prompts, negative_prompts, prompts_2, negative_prompts_2) prompts, negative_prompts, prompts_2, negative_prompts_2 = fix_prompt_model(cls, prompts, negative_prompts, prompts_2, negative_prompts_2) - args = set_fallback_prompt(args, possible, prompts=None, negative_prompts=None, prompts_2=prompts_2, negative_prompts_2=negative_prompts_2) # we dont parse secondary prompts if prompt_parser_diffusers.embedder is not None: if 'prompt' in possible: @@ -127,6 +126,8 @@ def set_prompt(p, else: if 'prompt_embeds' in possible: args['prompt_embeds'] = prompt_embeds + else: + args = set_fallback_prompt(args, possible, prompts=prompts, negative_prompts=None, prompts_2=None, negative_prompts_2=None) if 'pooled_prompt_embeds' in possible: args['pooled_prompt_embeds'] = prompt_pooled_embeds if 'StableCascade' in cls: @@ -156,6 +157,8 @@ def set_prompt(p, else: if 'negative_prompt_embeds' in possible: args['negative_prompt_embeds'] = negative_embeds + else: + args = set_fallback_prompt(args, possible, prompts=None, negative_prompts=negative_prompts, prompts_2=None, negative_prompts_2=None) if 'negative_pooled_prompt_embeds' in possible: args['negative_pooled_prompt_embeds'] = negative_pooled_embeds if 'StableCascade' in cls: @@ -170,6 +173,9 @@ def set_prompt(p, args = set_fallback_prompt(args, possible, prompts=prompts, negative_prompts=negative_prompts, prompts_2=None, negative_prompts_2=None) prompt_attention = 'fixed' + if 'prompt_embeds' not in args and 'negative_prompt_embeds' not in args: # pass secondary prompts as-in + args = set_fallback_prompt(args, possible, prompts=None, negative_prompts=None, prompts_2=prompts_2, negative_prompts_2=negative_prompts_2) + if (prompt_parser_diffusers.embedder is not None) and (not prompt_parser_diffusers.embedder.scheduled_prompt): prompt_parser_diffusers.embedder = None # not scheduled so we dont need it anymore diff --git a/modules/ui_extensions.py b/modules/ui_extensions.py index 6beca9bf6..112591121 100644 --- a/modules/ui_extensions.py +++ b/modules/ui_extensions.py @@ -252,10 +252,12 @@ def update_extension(extension_path, search_text, sort_column): def refresh_extensions_list(search_text, sort_column): global extensions_list # pylint: disable=global-statement + import ssl import urllib.request try: shared.log.debug(f'Updating extensions list: url={extensions_index}') - with urllib.request.urlopen(extensions_index, timeout=3.0) as response: + context = ssl._create_unverified_context() # pylint: disable=protected-access + with urllib.request.urlopen(extensions_index, timeout=3.0, context=context) as response: text = response.read() extensions_list = json.loads(text) with open(os.path.join(paths.script_path, "html", "extensions.json"), "w", encoding="utf-8") as outfile: diff --git a/modules/zluda_installer.py b/modules/zluda_installer.py index 91b5d8b20..b5055b049 100644 --- a/modules/zluda_installer.py +++ b/modules/zluda_installer.py @@ -1,5 +1,6 @@ import os import sys +import ssl import site import ctypes import shutil @@ -84,14 +85,23 @@ def install(): args.use_nightly = True if args.use_nightly: platform = "nightly-" + platform - urllib.request.urlretrieve(f'https://github.com/lshqqytiger/ZLUDA/releases/download/rel.{commit}/ZLUDA-{platform}-rocm{rocm.version[0]}-amd64.zip', '_zluda') - with zipfile.ZipFile('_zluda', 'r') as archive: - infos = archive.infolist() - for info in infos: - if not info.is_dir(): - info.filename = os.path.basename(info.filename) - archive.extract(info, path) - os.remove('_zluda') + log.debug(f'Install ZLUDA: rocm={rocm.version} platform={platform} commit={commit}') + ssl._create_default_https_context = ssl._create_unverified_context # pylint: disable=protected-access + try: + urllib.request.urlretrieve(f'https://github.com/lshqqytiger/ZLUDA/releases/download/rel.{commit}/ZLUDA-{platform}-rocm{rocm.version[0]}-amd64.zip', '_zluda') + if not os.path.exists('_zluda'): + raise RuntimeError('ZLUDA download failed') + with zipfile.ZipFile('_zluda', 'r') as archive: + infos = archive.infolist() + for info in infos: + if not info.is_dir(): + info.filename = os.path.basename(info.filename) + archive.extract(info, path) + except Exception as e: + raise RuntimeError(f'Install ZLUDA: {e}') from e + finally: + if os.path.exists('_zluda'): + os.remove('_zluda') def uninstall():