From 80b834054b7628df81fd5a16351fd9f5e8df4a01 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Tue, 1 Aug 2023 02:51:50 +0300 Subject: [PATCH 01/21] CPU offload mode check & Enable compile for IPEX --- modules/processing_diffusers.py | 1 + modules/sd_models.py | 6 ++++++ modules/shared.py | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index 7c80909de..8ee247f9c 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -211,6 +211,7 @@ def process_diffusers(p: StableDiffusionProcessing, seeds, prompts, negative_pro if shared.opts.diffusers_move_refiner and not shared.sd_refiner.has_accelerate: shared.log.debug('Diffusers: Moving refiner model to CPU') shared.sd_refiner.to(devices.cpu) + devices.torch_gc() else: results = output.images diff --git a/modules/sd_models.py b/modules/sd_models.py index 72dacf3bf..fa7002ec0 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -655,6 +655,12 @@ def load_diffuser(checkpoint_info=None, already_loaded_state_dict=None, timer=No elif "Kandinsky" in sd_model.__class__.__name__: sd_model.scheduler.name = 'DDIM' + if (shared.opts.diffusers_model_cpu_offload or shared.cmd_opts.medvram) and (shared.opts.diffusers_seq_cpu_offload or shared.cmd_opts.lowvram): + shared.log.warning(f'Diffusers {op}: Model CPU offload (--medvram) and Sequential CPU offload (--lowvram) are not compatible') + shared.log.debug(f'Diffusers {op}: disable model CPU offload and --medvram') + shared.opts.diffusers_model_cpu_offload=False + shared.cmd_opts.medvram=False + if hasattr(sd_model, "watermark"): sd_model.watermark = NoWatermark() sd_model.has_accelerate = False diff --git a/modules/shared.py b/modules/shared.py index 6c888819c..63f5549b4 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -384,8 +384,8 @@ options_templates.update(options_section(('cuda', "Compute Settings"), { "cudnn_benchmark": OptionInfo(False, "Enable full-depth cuDNN benchmark feature"), "cuda_allow_tf32": OptionInfo(True, "Allow TF32 math ops"), "cuda_allow_tf16_reduced": OptionInfo(True, "Allow TF16 reduced precision math ops"), - "cuda_compile": OptionInfo(False, "Enable model compile (experimental)"), - "cuda_compile_mode": OptionInfo("none", "Model compile mode (experimental)", gr.Radio, lambda: {"choices": ['none', 'inductor', 'reduce-overhead', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'ipex']}), + "cuda_compile": OptionInfo(True if devices.backend == "ipex" else False, "Enable model compile (experimental)"), + "cuda_compile_mode": OptionInfo("ipex" if devices.backend == "ipex" else "none", "Model compile mode (experimental)", gr.Radio, lambda: {"choices": ['none', 'inductor', 'reduce-overhead', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'ipex']}), "cuda_compile_fullgraph": OptionInfo(False, "Model compile fullgraph"), "cuda_compile_verbose": OptionInfo(False, "Model compile verbose mode"), "cuda_compile_errors": OptionInfo(True, "Model compile suppress errors"), From 1524365284f225e58831d15365992ae40029b85c Mon Sep 17 00:00:00 2001 From: Seunghoon Lee Date: Wed, 2 Aug 2023 02:32:11 +0900 Subject: [PATCH 02/21] Update Korean localization & DirectML bug fix. --- html/locale_ko.json | 120 ++++++++++++++++++++--------------------- modules/dml/backend.py | 2 +- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/html/locale_ko.json b/html/locale_ko.json index f91f7759c..b49ddbf84 100644 --- a/html/locale_ko.json +++ b/html/locale_ko.json @@ -16,9 +16,9 @@ {"id":"","label":"Negative prompt","localized":"네거티브 프롬프트","hint":"생성되지 않았으면 하는 이미지의 설명"} ], "common keywords": [ - {"id":"","label":"fp16","localized":"반정밀도(16비트)","hint":"수를 16비트 부동소수점으로 표현"}, - {"id":"","label":"fp32","localized":"단정밀도(32비트)","hint":"수를 32비트 부동소수점으로 표현"}, - {"id":"","label":"bf16","localized":"혼합 정밀도(16비트 bfloat)","hint":"수를 16비트 혼합 정밀도로 표현"}, + {"id":"","label":"fp16","localized":"반정밀도(16비트)","hint":"수를 16비트 부동소수점으로 표현한다."}, + {"id":"","label":"fp32","localized":"단정밀도(32비트)","hint":"수를 32비트 부동소수점으로 표현한다."}, + {"id":"","label":"bf16","localized":"혼합 정밀도(16비트 bfloat)","hint":"수를 16비트 혼합 정밀도로 표현한다."}, {"id":"","label":"Run","localized":"실행","hint":""}, {"id":"","label":"all","localized":"전체","hint":""}, {"id":"","label":"none","localized":"없음","hint":""}, @@ -55,18 +55,18 @@ {"id":"","label":"UI card preview lazy loading","localized":"UI 카드 프리뷰를 늦게 로드","hint":""}, {"id":"","label":"UI card size (px)","localized":"UI 카드 크기 (px, 픽셀)","hint":""}, {"id":"","label":"UI disable variable aspect ratio","localized":"","hint":""}, - {"id":"","label":"UI image contain method","localized":"","hint":""}, + {"id":"","label":"UI image contain method","localized":"UI 이미지 표시 방식","hint":""}, {"id":"","label":"Do not automatically build extra network pages","localized":"자동으로 엑스트라 네트워크 페이지를 만들지 않음","hint":""}, {"id":"","label":"Use LyCoris handler for all Lora types","localized":"모든 Lora 종류에 LyCoris 핸들러 사용","hint":""}, {"id":"","label":"Disable built-in Lora handler","localized":"내장 Lora 핸들러 비활성화","hint":""}, - {"id":"","label":"Use Kohya method for handling multiple Loras","localized":"","hint":""}, - {"id":"","label":"Multiplier for extra networks","localized":"엑스트라 네트워크 배율","hint":"하이퍼 네트워크 또는 Lora를 프롬프트에 추가할 때 사용할 배율."}, + {"id":"","label":"Use Kohya method for handling multiple Loras","localized":"여러 Lora를 다룰 때 Kohya의 방법 사용","hint":""}, + {"id":"","label":"Multiplier for extra networks","localized":"엑스트라 네트워크 배율","hint":"하이퍼 네트워크 또는 Lora를 프롬프트에 추가할 때 사용할 배율이다."}, {"id":"","label":"Add hypernetwork to prompt","localized":"프롬프트에 하이퍼 네트워크 추가","hint":""}, {"id":"","label":"Add Lora to prompt","localized":"프롬프트에 Lora 추가","hint":""}, {"id":"","label":"shuffle tags by ',' when creating prompts.","localized":"프롬프트를 생성할 때 ','에 따라 태그 섞기","hint":""}, - {"id":"","label":"extra text to add before <...> when adding extra network to prompt","localized":"","hint":""}, + {"id":"","label":"extra text to add before <...> when adding extra network to prompt","localized":"엑스트라 네트워크를 프롬프트에 추가할 때 <...> 이전에 추가할 텍스트","hint":""}, {"id":"","label":"When adding to prompt, refer to Lora by","localized":"","hint":""}, - {"id":"","label":"add lora hashes to infotext","localized":"","hint":""}, + {"id":"","label":"add lora hashes to infotext","localized":"infotext에 Lora 해시 정보 포함","hint":""}, {"id":"","label":"Checkpoints","localized":"체크포인트","hint":""}, {"id":"","label":"Lora","localized":"","hint":""}, {"id":"","label":"LyCORIS","localized":"","hint":""}, @@ -83,9 +83,9 @@ {"id":"","label":"delete","localized":"삭제","hint":"이미지를 삭제한다."}, {"id":"","label":"➠ text","localized":"➠ 텍스트","hint":"이미지를 이미지➠텍스트 탭으로 옮긴다."}, {"id":"","label":"➠ image","localized":"➠ 이미지","hint":"이미지를 이미지➠이미지 탭으로 옮긴다."}, - {"id":"","label":"➠ inpaint","localized":"","hint":"Transfer image to inpaint interface"}, - {"id":"","label":"➠ sketch","localized":"","hint":"Transfer image to sketch interface"}, - {"id":"","label":"➠ inpaint sketch","localized":"","hint":"Transfer image to inpaint sketch interface"}, + {"id":"","label":"➠ inpaint","localized":"➠ 인페인트","hint":"이미지를 인페인트 화면으로 옮긴다."}, + {"id":"","label":"➠ sketch","localized":"➠ 스케치","hint":"이미지를 스케치 화면으로 옮긴다."}, + {"id":"","label":"➠ inpaint sketch","localized":"➠ 인페인트 스케치","hint":"이미지를 인페인트 스케치 탭으로 옮긴다."}, {"id":"","label":"➠ process","localized":"➠ 이미지 정보","hint":"이미지를 이미지 정보 탭으로 옮긴다."} ], "extensions": [ @@ -102,24 +102,24 @@ {"id":"","label":"Apply changes & restart server","localized":"변경 사항을 저장하고 서버를 재시작","hint":"모든 변경 사항을 적용하고 서버를 재시작한다."}, {"id":"","label":"install","localized":"설치","hint":"이 확장을 설치한다."}, {"id":"","label":"uninstall","localized":"제거","hint":"이 확장을 제거한다."}, - {"id":"","label":"User interface defaults","localized":"사용자 인터페이스 기본값","hint":"Review and set current values as default values for the user interface"}, - {"id":"","label":"View changes","localized":"변경 사항 확인","hint":"Review changes between default user interface values and and current values"}, - {"id":"","label":"Set new defaults","localized":"새 기본값 설정","hint":"Set current values as default values for the user interface"}, + {"id":"","label":"User interface defaults","localized":"유저 인터페이스 기본값","hint":"Review and set current values as default values for the user interface"}, + {"id":"","label":"View changes","localized":"변경 사항 확인","hint":"기본값과 현재 값 간의 변경 사항을 확인한다."}, + {"id":"","label":"Set new defaults","localized":"새 기본값 설정","hint":"현재 UI 설정을 기본값으로 저장한다."}, {"id":"","label":"Restore system defaults","localized":"시스템 기본값 복원","hint":"유저 인터페이스 기본값을 복원한다."} ], "txt2img tab": [ {"id":"","label":"Sampling method","localized":"샘플링 방법(샘플러)","hint":"이미지 생성 시 사용할 알고리즘을 지정한다."}, {"id":"","label":"Sampling steps","localized":"샘플링 스탭 수","hint":"이미지를 생성 과정을 얼마나 많이 반복할지 지정한다. 높을 수록 생성이 길어지고 낮을 수록 결과물 퀄리티가 낮아진다."}, - {"id":"","label":"Restore faces","localized":"얼굴 복원","hint":"Use a pre-trained model to correct the generated faces. See GFPGAN or Codeformer."}, + {"id":"","label":"Restore faces","localized":"얼굴 복원","hint":"생성된 이미지의 얼굴을 GFPGAN 또는 CodeFormer로 고친다."}, {"id":"","label":"Tiling","localized":"타일링","hint":"Produce an image that can be tiled"}, {"id":"","label":"Hires fix","localized":"생성 후 업스케일(Hires fix)","hint":"최종 이미지를 생성하기 전에 업스케일한다."}, - {"id":"","label":"Denoising strength","localized":"디노이즈 강도","hint":"Determines how little respect the algorithm should have for image's content. At 0, nothing will change, and at 1 you'll get an unrelated image. With values below 1.0, processing will take less steps than the Sampling Steps slider specifies"}, + {"id":"","label":"Denoising strength","localized":"디노이즈 강도","hint":"기존 이미지의 특징을 얼마나 남길지 정한다. 만약 0이라면 이전 이미지가 그대로 생성되고 1이라면 이전 이미지와 전혀 무관한 이미지가 생성된다. With values below 1.0, processing will take less steps than the Sampling Steps slider specifies"}, {"id":"","label":"Denoise start","localized":"","hint":"Override denoise strength by stating how early base model should finish and when refiner should start. Only applicable to refiner usage. If set to 0 or 1, denoising strength will be used"}, - {"id":"","label":"Hires steps","localized":"업스케일 스탭 수","hint":"Number of sampling steps for upscaled picture. If 0, uses same as for original"}, - {"id":"","label":"Upscaler","localized":"업스케일러","hint":"Which pre-tarined model to use for the upscaling process."}, - {"id":"","label":"Upscale by","localized":"업스케일 배율","hint":"Adjusts the size of the image by multiplying the original width and height by the selected value. Ignored if either Resize width to or Resize height to are non-zero"}, - {"id":"","label":"Resize width to","localized":"너비","hint":"이 너비로 이미지를 리사이즈한다. If 0, width is inferred from either of two nearby sliders"}, - {"id":"","label":"Resize height to","localized":"높이","hint":"이 높이로 이미지를 리사이즈한다. If 0, height is inferred from either of two nearby sliders"}, + {"id":"","label":"Hires steps","localized":"업스케일 스탭 수","hint":"업스케일 시 샘플링 스탭 수이다. If 0, uses same as for original"}, + {"id":"","label":"Upscaler","localized":"업스케일러","hint":"업스케일 시 사용할 모델이다."}, + {"id":"","label":"Upscale by","localized":"업스케일 배율","hint":"기존 이미지의 너비와 높이에 이 값을 곱한다. 너비와 높이가 0이 아니라면 무시된다."}, + {"id":"","label":"Resize width to","localized":"너비","hint":"이 너비로 이미지를 리사이즈한다. 0이라면 높이에서 추론한다."}, + {"id":"","label":"Resize height to","localized":"높이","hint":"이 높이로 이미지를 리사이즈한다. 0이라면 너비에서 추론한다."}, {"id":"","label":"Secondary sampler","localized":"2단계 샘플러","hint":"Use specific sampler as fallback sampler if primary is not supported for specific operation"}, {"id":"","label":"Secondary steps","localized":"2단계 스탭 수","hint":"Number of steps to use for second pass"}, {"id":"","label":"Secondary CFG Scale","localized":"2단계 CFG 스케일","hint":"CFG scale used for refiner pass"}, @@ -132,24 +132,24 @@ {"id":"","label":"Batch size","localized":"배치 사이즈","hint":"How many image to create in a single batch (생성 시 성능에 영향을 주고 VRAM을 더 사용함)"}, {"id":"","label":"CFG Scale","localized":"CFG 스케일","hint":"Classifier Free Guidance scale: how strongly the image should conform to prompt. Lower values produce more creative results, higher values make it follow the prompt more strictly; recommended values between 5-10"}, {"id":"","label":"CLIP skip","localized":"클립(CLIP) 스킵","hint":"Clip skip is a feature that allows users to control the level of specificity of the prompt, the higher the CLIP skip value, the less deep the prompt will be interpreted. CLIP Skip 1 is typical while some anime models produce better results at CLIP skip 2"}, - {"id":"","label":"Seed","localized":"시드","hint":"Random Number Generator의 결과를 결정하는 값. 같은 설정 값과 시드를 사용하면 같은 결과를 얻는다."}, + {"id":"","label":"Seed","localized":"시드","hint":"난수 생성기의 결과를 결정하는 값. 같은 설정 값과 시드를 사용하면 같은 결과를 얻는다."}, {"id":"","label":"Extra","localized":"기타","hint":"추가 설정을 본다."}, - {"id":"","label":"Variation seed","localized":"","hint":"Seed of a different picture to be mixed into the generation"}, - {"id":"","label":"Variation strength","localized":"","hint":"How strong of a variation to produce. At 0, there will be no effect. At 1, you will get the complete picture with variation seed (except for ancestral samplers, where you will just get something)"}, + {"id":"","label":"Variation seed","localized":"다양성 시드","hint":"Seed of a different picture to be mixed into the generation"}, + {"id":"","label":"Variation strength","localized":"다양성 강도","hint":"How strong of a variation to produce. At 0, there will be no effect. At 1, you will get the complete picture with variation seed (except for ancestral samplers, where you will just get something)"}, {"id":"","label":"Resize seed from width","localized":"","hint":"Make an attempt to produce a picture similar to what would have been produced with same seed at specified resolution"}, {"id":"","label":"Resize seed from height","localized":"","hint":"Make an attempt to produce a picture similar to what would have been produced with same seed at specified resolution"}, {"id":"","label":"Override settings","localized":"설정 덮어쓰기","hint":"If you read in generation parameters through 'Process Image tab' and individual generation parameters should deviate from your system settings, this box will be populated with those settings to override your system configuration for this workflow"} ], "process tab": [ - {"id":"","label":"Single Image","localized":"단일 이미지","hint":"Process single image"}, - {"id":"","label":"Process Batch","localized":"배치 생성","hint":"Process batch of images"}, - {"id":"","label":"Process Folder","localized":"폴더 생성","hint":"Process all images in a folder"}, - {"id":"","label":"Scale by","localized":"리사이즈(배율)","hint":"Use this tab to resize the source image(s) by a chosen factor"}, - {"id":"","label":"Scale to","localized":"리사이즈","hint":"Use this tab to resize the source image(s) to a chosen target size"}, + {"id":"","label":"Single Image","localized":"단일 이미지","hint":"단일 이미지에 대해 작업을 수행한다."}, + {"id":"","label":"Process Batch","localized":"배치 생성","hint":"이미지 배치를 생성한다."}, + {"id":"","label":"Process Folder","localized":"폴더","hint":"폴더 내 모든 이미지를 대상으로 작업을 수행한다."}, + {"id":"","label":"Scale by","localized":"이미지 크기 변경(배율)","hint":"이 배율만큼 이미지 크기를 바꾼다."}, + {"id":"","label":"Scale to","localized":"이미지 크기 변경","hint":"특정 크기로 이미지 크기를 바꾼다."}, {"id":"","label":"Input directory","localized":"입력 위치","hint":"Folder where the images are that you want to process"}, {"id":"","label":"Output directory","localized":"출력 위치","hint":"Folder where the processed images should be saved to"}, {"id":"","label":"Show result images","localized":"결과 이미지 보기","hint":"Enable to show the processed images in the image pane"}, - {"id":"","label":"Resize","localized":"리사이즈 배율","hint":"Factor for resizing 1x mean no upscale, 4x means 4 times upscale, high values might lead to memory issues on small graphics cards"}, + {"id":"","label":"Resize","localized":"이미지 크기 변경 배율","hint":"Factor for resizing 1x mean no upscale, 4x means 4 times upscale, high values might lead to memory issues on small graphics cards"}, {"id":"","label":"Crop to fit","localized":"","hint":"If the dimensions of your source image (e.g. 512x510) deviate from your target dimensions (e.g. 1024x768) this function will fit your upscaled image into your target size image. Excess will be cropped"}, {"id":"","label":"Secondary Upscaler","localized":"2단계 업스케일러","hint":"Select secondary upscaler to run after initial upscaler"}, {"id":"","label":"Upscaler 2 visibility","localized":"","hint":"Strength of the secondary upscaler"}, @@ -163,8 +163,8 @@ {"id":"shutdown_submit","label":"Shutdown server","localized":"서버 종료","hint":"서버를 종료한다."}, {"id":"settings_preview_theme","label":"Preview theme","localized":"테마 미리보기","hint":"테마 미리보기 탭을 연다."}, {"id":"defaults_submit","label":"Restore defaults","localized":"기본값 복원","hint":"기본 설정을 불러온다."}, - {"id":"sett_unload_sd_model","label":"Unload checkpoint","localized":"체크포인트 언로드","hint":"현재 로드된 모델을 언로드한다."}, - {"id":"sett_reload_sd_model","label":"Reload checkpoint","localized":"체크포인트 다시 불러오기","hint":"현재 로드된 모델을 다시 불러온다."} + {"id":"sett_unload_sd_model","label":"Unload checkpoint","localized":"체크포인트 언로드","hint":"현재 모델을 메모리에서 해제한다."}, + {"id":"sett_reload_sd_model","label":"Reload checkpoint","localized":"체크포인트 다시 불러오기","hint":"현재 모델을 다시 불러온다."} ], "settings sections": [ {"id":"","label":"Stable Diffusion","localized":"","hint":""}, @@ -189,11 +189,11 @@ ], "img2img tabs": [ {"id":"","label":"Image","localized":"이미지","hint":""}, - {"id":"","label":"Sketch","localized":"","hint":""}, - {"id":"","label":"Inpaint","localized":"","hint":""}, - {"id":"","label":"Inpaint sketch","localized":"","hint":""}, - {"id":"","label":"Inpaint upload","localized":"","hint":""}, - {"id":"","label":"Batch","localized":"","hint":""} + {"id":"","label":"Sketch","localized":"스케치","hint":""}, + {"id":"","label":"Inpaint","localized":"인페인트","hint":""}, + {"id":"","label":"Inpaint sketch","localized":"인페인트 스케치","hint":""}, + {"id":"","label":"Inpaint upload","localized":"인페인트 업로드","hint":""}, + {"id":"","label":"Batch","localized":"배치","hint":""} ], "img2img tab": [ {"id":"","label":"Inpaint batch input directory","localized":"","hint":""}, @@ -259,7 +259,7 @@ {"id":"","label":"Name","localized":"이름","hint":""}, {"id":"","label":"Initialization text","localized":"","hint":"If the number of tokens is more than the number of vectors, some may be skipped.\nLeave the textbox empty to start with zeroed out vectors"}, {"id":"","label":"Number of vectors per token","localized":"","hint":""}, - {"id":"","label":"Overwrite Old Embedding","localized":"","hint":""}, + {"id":"","label":"Overwrite Old Embedding","localized":"기존 임베딩 덮어쓰기","hint":""}, {"id":"","label":"Enter hypernetwork layer structure","localized":"","hint":""}, {"id":"","label":"Select activation function of hypernetwork","localized":"","hint":"Recommended : Swish / Linear(none)"}, {"id":"","label":"Select Layer weights initialization","localized":"","hint":"Recommended: Kaiming for relu-like, Xavier for sigmoid-like, Normal otherwise"}, @@ -342,8 +342,8 @@ {"id":"","label":"InvokeAI's","localized":"","hint":""}, {"id":"","label":"Sub-quadratic","localized":"","hint":""}, {"id":"","label":"Split attention","localized":"","hint":""}, - {"id":"","label":"xFormers enable flash Attention","localized":"","hint":""}, - {"id":"","label":"SDP disable memory attention","localized":"","hint":""}, + {"id":"","label":"xFormers enable flash Attention","localized":"xFormers Flash Attention 활성화","hint":""}, + {"id":"","label":"SDP disable memory attention","localized":"SDP Memory Attention 비활성화","hint":""}, {"id":"","label":"Sub-quadratic cross-attention query chunk size","localized":"Sub-quadratic 크로스 어텐션 쿼리 청크 크기","hint":""}, {"id":"","label":"Sub-quadratic cross-attention kv chunk size","localized":"Sub-quadratic 크로스 어텐션 kv 청크 크기","hint":""}, {"id":"","label":"Sub-quadratic cross-attention chunking threshold","localized":"Sub-quadratic 크로스 어텐션 청크 분할 임계값","hint":""}, @@ -363,16 +363,16 @@ {"id":"","label":"FP32","localized":"","hint":""}, {"id":"","label":"FP16","localized":"","hint":""}, {"id":"","label":"BF16","localized":"","hint":""}, - {"id":"","label":"Use full precision for model (--no-half)","localized":"모델에 단정밀도 사용 (--no-half)","hint":"Uses FP32 for the model. May produce better results while using more VRAM and slower generation"}, - {"id":"","label":"Use full precision for VAE (--no-half-vae)","localized":"VAE에 단정밀도 사용 (--no-half-vae)","hint":"Uses FP32 for the VAE. May produce better results while using more VRAM and slower generation"}, - {"id":"","label":"Enable upcast sampling","localized":"","hint":"Usually produces similar results to --no-half with better performance while using less memory"}, - {"id":"","label":"Enable upcast cross attention layer","localized":"","hint":""}, - {"id":"","label":"Disable NaN check in produced images/latent spaces","localized":"","hint":""}, - {"id":"","label":"Attempt VAE roll back when produced NaN values (experimental)","localized":"","hint":"Requires Torch 2.1 and NaN check enabled"}, - {"id":"","label":"Use channels last as torch memory format","localized":"","hint":""}, - {"id":"","label":"Enable full-depth cuDNN benchmark feature","localized":"","hint":""}, - {"id":"","label":"Allow TF32 math ops","localized":"TF32 단정밀도 연산 허용","hint":""}, - {"id":"","label":"Allow TF16 reduced precision math ops","localized":"TF16 반정밀도 연산 허용","hint":""}, + {"id":"","label":"Use full precision for model (--no-half)","localized":"모델에 단정밀도 사용 (--no-half)","hint":"모델을 단정밀도 부동소수점(FP32)으로 불러온다. VRAM을 많이 사용하고 생성 속도가 느려지지만 더 좋은 결과물을 얻을 수도 있다."}, + {"id":"","label":"Use full precision for VAE (--no-half-vae)","localized":"VAE에 단정밀도 사용 (--no-half-vae)","hint":"VAE를 단정밀도 부동소수점(FP32)으로 불러온다. VRAM을 많이 사용하고 생성 속도가 느려지지만 더 좋은 결과물을 얻을 수도 있다."}, + {"id":"","label":"Enable upcast sampling","localized":"Upcast sampling 활성화","hint":"메모리를 덜 사용하고 좋은 성능을 내면서도 --no-half를 사용할 때와 비슷한 결과물을 얻을 수 있다."}, + {"id":"","label":"Enable upcast cross attention layer","localized":"Upcast cross attention layer 활성화","hint":""}, + {"id":"","label":"Disable NaN check in produced images/latent spaces","localized":"생성된 이미지와 잠재 공간(latent space)에 대해 NaN 검사를 하지 않음","hint":""}, + {"id":"","label":"Attempt VAE roll back when produced NaN values (experimental)","localized":"NaN 값이 발견되었을 때 VAE 롤백 시도 (실험적)","hint":"Torch 2.1을 사용 중이고 NaN 검사가 활성화되어 있어야 한다."}, + {"id":"","label":"Use channels last as torch memory format","localized":"Channels last 메모리 형식 사용","hint":""}, + {"id":"","label":"Enable full-depth cuDNN benchmark feature","localized":"Full-depth cuDNN benchmark 기능 활성화","hint":""}, + {"id":"","label":"Allow TF32 math ops","localized":"TF32 연산 허용","hint":""}, + {"id":"","label":"Allow TF16 reduced precision math ops","localized":"TF16 연산 허용","hint":""}, {"id":"","label":"Enable model compile (experimental)","localized":"모델 컴파일 활성화 (실험적)","hint":""}, {"id":"","label":"inductor","localized":"","hint":""}, {"id":"","label":"cudagraphs","localized":"","hint":""}, @@ -381,7 +381,7 @@ {"id":"","label":"ipex","localized":"","hint":""}, {"id":"","label":"Model compile verbose mode","localized":"","hint":""}, {"id":"","label":"Model compile suppress errors","localized":"모델 컴파일 시 오류 억제","hint":""}, - {"id":"","label":"Disable Torch memory garbage collection","localized":"Torch 메모리 정리 비활성화","hint":"Disable Torch memory garbage collection on each generation. CG will still run before & after model load as well when low GPU memory threshold is reached."}, + {"id":"","label":"Disable Torch memory garbage collection","localized":"Torch 메모리 정리 비활성화","hint":"이미지 생성 시 메모리 정리를 하지 않는다. CG will still run before & after model load as well when low GPU memory threshold is reached."}, {"id":"","label":"Directory for temporary images; leave empty for default","localized":"임시 이미지 저장 위치 (비워 놓으면 기본값)","hint":""}, {"id":"","label":"Cleanup non-default temporary directory when starting webui","localized":"임시 위치가 기본값이 아닌 경우 WebUI 시작 시 비우기","hint":""}, {"id":"","label":"Path to directory with stable diffusion checkpoints","localized":"체크포인트 위치","hint":""}, @@ -402,8 +402,8 @@ {"id":"","label":"Path to directory with LyCORIS network(s)","localized":"LyCORIS 위치","hint":""}, {"id":"","label":"Path to user-defined styles file","localized":"프롬프트 스타일 위치","hint":""}, {"id":"","label":"Always save all generated images","localized":"항상 생성된 모든 이미지 저장","hint":""}, - {"id":"","label":"File format for generated images","localized":"생성된 이미지의 파일 포맷","hint":"Select file format for images"}, - {"id":"","label":"Include metadata in saved images","localized":"저장된 이미지에 메타데이터 포함","hint":"Save image create parameters as metadata tags inside image file"}, + {"id":"","label":"File format for generated images","localized":"생성된 이미지의 파일 형식","hint":"이미지 파일 형식을 선택한다."}, + {"id":"","label":"Include metadata in saved images","localized":"저장된 이미지에 메타데이터 포함","hint":"이미지 파일에 이미지 생성 파라미터를 메타데이터로 저장한다."}, {"id":"","label":"Images filename pattern","localized":"이미지 파일명 패턴","hint":"Use following tags to define how filenames for images are chosen:
seq, uuid
date, datetime, job_timestamp
generation_number, batch_number
model, model_shortname
model_hash, model_name
sampler, seed, steps, cfg
clip_skip, denoising
hasprompt, prompt, styles
prompt_hash, prompt_no_styles
prompt_spaces, prompt_words
height, width, image_hash
"}, {"id":"","label":"Add number to filename when saving","localized":"저장 시 파일명에 숫자 추가","hint":""}, {"id":"","label":"Always save all generated image grids","localized":"항상 생성된 모든 그리드 이미지 저장","hint":""}, @@ -457,8 +457,8 @@ {"id":"","label":"Send seed when sending prompt or image to other interface","localized":"","hint":""}, {"id":"","label":"Send size when sending prompt or image to another interface","localized":"","hint":""}, {"id":"","label":"Font for image grids that have text","localized":"","hint":""}, - {"id":"","label":"Ctrl+up/down precision when editing (attention:1.1)","localized":"","hint":""}, - {"id":"","label":"Ctrl+up/down precision when editing ","localized":"","hint":""}, + {"id":"","label":"Ctrl+up/down precision when editing (attention:1.1)","localized":"(attention:1.1) 수정 시 컨트롤+상/하 조절 정밀도","hint":""}, + {"id":"","label":"Ctrl+up/down precision when editing ","localized":" 수정 시 컨트롤+상/하 조절 정밀도","hint":""}, {"id":"","label":"Ctrl+up/down word delimiters","localized":"","hint":""}, {"id":"","label":"Quicksettings list","localized":"빠른 설정 목록","hint":"List of setting names, separated by commas, for settings that should go to the quick access bar at the top instead the setting tab"}, {"id":"","label":"Hidden UI tabs","localized":"숨긴 UI 탭","hint":""}, @@ -517,10 +517,10 @@ {"id":"","label":"logSNR","localized":"","hint":""}, {"id":"","label":"UniPC order (must be < sampling steps)","localized":"","hint":""}, {"id":"","label":"UniPC lower order final","localized":"","hint":""}, - {"id":"","label":"Enable addtional postprocessing operations","localized":"","hint":""}, - {"id":"","label":"Postprocessing operation order","localized":"","hint":""}, + {"id":"","label":"Enable addtional postprocessing operations","localized":"추가 후처리 작업","hint":""}, + {"id":"","label":"Postprocessing operation order","localized":"후처리 작업 순서","hint":""}, {"id":"","label":"Maximum number of images in upscaling cache","localized":"","hint":""}, - {"id":"","label":"Move VAE and CLIP to RAM when training if possible","localized":"","hint":""}, + {"id":"","label":"Move VAE and CLIP to RAM when training if possible","localized":"가능하다면 학습 시 VAE와 CLIP 모델을 램으로 이동","hint":""}, {"id":"","label":"Pin training dataset to memory","localized":"","hint":""}, {"id":"","label":"Save resumable optimizer state when training","localized":"","hint":""}, {"id":"","label":"Save training settings to a text file on training start","localized":"","hint":""}, @@ -565,9 +565,9 @@ {"id":"","label":"Select diffuser pipeline when loading from safetensors","localized":"safetensors 파일에서 로드할 때 사용할 파이프라인 선택","hint":""}, {"id":"","label":"Move base model to CPU when using refiner","localized":"리파이너를 사용 중일 때 base 모델을 CPU로 이동","hint":""}, {"id":"","label":"Move refiner model to CPU when not in use","localized":"사용 중이지 않을 때 리파이너 모델을 CPU로 이동","hint":""}, - {"id":"","label":"Move UNet to CPU while VAE decoding","localized":"","hint":""}, + {"id":"","label":"Move UNet to CPU while VAE decoding","localized":"VAE 디코딩 시 UNet을 CPU로 이동","hint":""}, {"id":"","label":"Use model EMA weights when possible","localized":"가능하다면 모델의 EMA 가중치 사용","hint":""}, - {"id":"","label":"Generator device","localized":"Generator 디바이스","hint":""}, + {"id":"","label":"Generator device","localized":"난수 생성 장치","hint":""}, {"id":"","label":"Enable sequential CPU offload","localized":"순차 CPU 오프로드 활성화","hint":"가중치를 CPU로 옮겨 GPU 메모리 사용률을 낮춘다. 속도가 약 10% 느려진다. Use with 어텐션 슬라이싱 활성화 for minimal memory consumption"}, {"id":"","label":"Enable model CPU offload","localized":"모델 CPU 오프로드 활성화","hint":"전체 모델을 GPU로 옮긴다. 여전히 GPU 메모리 사용률을 약간 낮춰주지만 생성 속도에는 무시할 수 있는 정도의 영향을 준다. 추가적인 메모리 절약을 위해서는 어텐션 슬라이싱과 함께 사용한다."}, {"id":"","label":"Enable VAE slicing","localized":"VAE 슬라이싱 활성화","hint":"Decodes batch latents one image at a time with limited VRAM. 여러 이미지를 다룰 때 VAE 해독 시 작은 성능 향상이 있다. 어텐션 슬라이싱과 함께 사용한다."}, diff --git a/modules/dml/backend.py b/modules/dml/backend.py index ef46f288a..90b2d0528 100644 --- a/modules/dml/backend.py +++ b/modules/dml/backend.py @@ -7,10 +7,10 @@ import modules.dml.amp as amp from .utils import rDevice, get_device from .device import device from .device_properties import DeviceProperties -from .memory_amd import AMDMemoryProvider from .memory import MemoryProvider def amd_mem_get_info(device: Optional[rDevice]=None) -> tuple[int, int]: + from .memory_amd import AMDMemoryProvider return AMDMemoryProvider.mem_get_info(get_device(device).index) def pdh_mem_get_info(device: Optional[rDevice]=None) -> tuple[int, int]: From 2cf40140400ff7ccf751a79b33aa60b6e1b37f1d Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 31 Jul 2023 11:36:51 +0200 Subject: [PATCH 03/21] refresh --- extensions-builtin/sd-webui-agent-scheduler | 2 +- .../stable-diffusion-webui-images-browser | 2 +- modules/ui_models.py | 14 ++++++++++++-- wiki | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/extensions-builtin/sd-webui-agent-scheduler b/extensions-builtin/sd-webui-agent-scheduler index 1bb04d1fb..1a5be3bf3 160000 --- a/extensions-builtin/sd-webui-agent-scheduler +++ b/extensions-builtin/sd-webui-agent-scheduler @@ -1 +1 @@ -Subproject commit 1bb04d1fbe00201cc28638fef09c25bea002b1e2 +Subproject commit 1a5be3bf3ae9b829681fcbe4614a1dc43a06d57e diff --git a/extensions-builtin/stable-diffusion-webui-images-browser b/extensions-builtin/stable-diffusion-webui-images-browser index b984cdd16..a3aeb93fd 160000 --- a/extensions-builtin/stable-diffusion-webui-images-browser +++ b/extensions-builtin/stable-diffusion-webui-images-browser @@ -1 +1 @@ -Subproject commit b984cdd1692f46006333ab92ef463cc35879f455 +Subproject commit a3aeb93fd7387cfe58aabf431b2dbbd1796bffed diff --git a/modules/ui_models.py b/modules/ui_models.py index d1afb8183..607dd069c 100644 --- a/modules/ui_models.py +++ b/modules/ui_models.py @@ -141,12 +141,22 @@ def create_ui(): model_checkhash_btn = gr.Button(value="Calculate hash for all models (may take a long time)", variant='primary') model_checkhash_btn.click(fn=sd_models.update_model_hashes, inputs=[], outputs=[models_outcome]) with gr.Row(): - model_table = gr.DataFrame(model_data, label = 'Model data', show_label = True, interactive = False, wrap = True, overflow_row_behaviour = 'paginate', max_rows = 10, headers = model_headers) + model_table = gr.DataFrame( + data = model_data, + headers = model_headers, + label = 'Model data', + show_label = True, + interactive = False, + wrap = True, + overflow_row_behaviour = 'paginate', + max_rows = 50, + ) def list_models(): total_size = 0 + model_data.clear() + txt = '' for m in sd_models.checkpoints_list.values(): - txt = '' try: stat = os.stat(m.filename) m_name = m.name.replace('.ckpt', '').replace('.safetensors', '') diff --git a/wiki b/wiki index ec18e358a..f76cc3a9a 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit ec18e358a4523567164170e38a90c74eb4deba0f +Subproject commit f76cc3a9ac124882f58f35ba3dfe930744109456 From 246989129f9583396dd9fe5e357ba6f46734a6d1 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 2 Aug 2023 08:27:16 +0200 Subject: [PATCH 04/21] ui settings logging --- modules/ui.py | 20 ++++++++++++-------- modules/ui_models.py | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/modules/ui.py b/modules/ui.py index 179c68a26..7ca1261ca 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -32,6 +32,7 @@ import modules.sd_samplers modules.errors.install() mimetypes.init() mimetypes.add_type('application/javascript', '.js') +log = modules.shared.log if not cmd_opts.share and not cmd_opts.listen: # fix gradio phoning home @@ -126,7 +127,7 @@ def process_interrogate(interrogation_function, mode, ii_input_files, ii_input_d images = [f.name for f in ii_input_files] else: if not os.path.isdir(ii_input_dir): - modules.shared.log.error(f"Input directory not found: {ii_input_dir}") + log.error(f"Input directory not found: {ii_input_dir}") return images = modules.shared.listfiles(ii_input_dir) if ii_output_dir != "": @@ -195,7 +196,7 @@ def connect_reuse_seed(seed: gr.Number, reuse_seed: gr.Button, generation_info: res = all_seeds[index if 0 <= index < len(all_seeds) else 0] except json.decoder.JSONDecodeError: if gen_info_string != '': - modules.shared.log.error(f"Error parsing JSON generation info: {gen_info_string}") + log.error(f"Error parsing JSON generation info: {gen_info_string}") return [res, gr_show(False)] reuse_seed.click(fn=copy_seed, _js="(x, y) => [x, selected_gallery_index()]", show_progress=False, inputs=[generation_info, dummy_component], outputs=[seed, dummy_component]) @@ -503,6 +504,7 @@ def create_ui(startup_timer = None): negative_token_button.click(fn=wrap_queued_call(update_token_counter), inputs=[txt2img_negative_prompt, steps], outputs=[negative_token_counter]) ui_extra_networks.setup_ui(extra_networks_ui, txt2img_gallery) + log.debug(f'UI interface: tab=txt2img batch={show_batch.value} seed={show_seed.value} advanced={show_advanced.value} second_pass={show_second_pass.value}') startup_timer.record("ui-txt2img") @@ -854,6 +856,8 @@ def create_ui(startup_timer = None): paste_button=img2img_paste, tabname="img2img", source_text_component=img2img_prompt, source_image_component=None, )) + log.debug(f'UI interface: tab=img2img seed={show_seed.value} resize={show_resize.value} batch={show_batch.value} denoise={show_denoise.value} advanced={show_advanced.value}') + startup_timer.record("ui-img2img") modules.scripts.scripts_current = None @@ -910,7 +914,7 @@ def create_ui(startup_timer = None): try: res = comp(label=info.label, value=fun(), elem_id=elem_id, **(args or {})) except Exception as e: - modules.shared.log.error(f'Error creating setting: {key} {e}') + log.error(f'Error creating setting: {key} {e}') res = None if res is not None and not is_quicksettings: @@ -955,9 +959,9 @@ def create_ui(startup_timer = None): directml_override_opts() try: opts.save(modules.shared.config_filename) - modules.shared.log.info(f'Settings changed: {len(changed)} {changed}') + log.info(f'Settings changed: {len(changed)} {changed}') except RuntimeError: - modules.shared.log.error(f'Settings change failed: {len(changed)} {changed}') + log.error(f'Settings change failed: {len(changed)} {changed}') return opts.dumpjson(), f'{len(changed)} Settings changed without save: {", ".join(changed)}' return opts.dumpjson(), f'{len(changed)} Settings changed{": " if len(changed) > 0 else ""}{", ".join(changed)}' @@ -969,7 +973,7 @@ def create_ui(startup_timer = None): if cmd_opts.use_directml: directml_override_opts() opts.save(modules.shared.config_filename) - modules.shared.log.debug(f'Setting changed: key={key}, value={value}') + log.debug(f'Setting changed: key={key}, value={value}') return get_value_for_setting(key), opts.dumpjson() with gr.Blocks(analytics_enabled=False) as settings_interface: @@ -1179,7 +1183,7 @@ def html_head(): head += f'\n' added.append(script.path) added = [a.replace(script_path, '').replace('\\', '/') for a in added] - # modules.shared.log.debug(f'Adding JS scripts: {added}') + # log.debug(f'Adding JS scripts: {added}') return head @@ -1209,7 +1213,7 @@ def html_css(): if os.path.exists(os.path.join(data_path, "user.css")): head += stylesheet(os.path.join(data_path, "user.css")) added = [a.replace(script_path, '').replace('\\', '/') for a in added] - # modules.shared.log.debug(f'Adding CSS stylesheets: {added}') + # log.debug(f'Adding CSS stylesheets: {added}') return head diff --git a/modules/ui_models.py b/modules/ui_models.py index 607dd069c..54b24bfea 100644 --- a/modules/ui_models.py +++ b/modules/ui_models.py @@ -142,7 +142,7 @@ def create_ui(): model_checkhash_btn.click(fn=sd_models.update_model_hashes, inputs=[], outputs=[models_outcome]) with gr.Row(): model_table = gr.DataFrame( - data = model_data, + value = model_data, headers = model_headers, label = 'Model data', show_label = True, From a293e3cdcb44bd446847b06dc9fb5a6713d89b5e Mon Sep 17 00:00:00 2001 From: Disty0 Date: Thu, 3 Aug 2023 16:29:56 +0300 Subject: [PATCH 05/21] Torch 2.0 for IPEX --- installer.py | 2 +- modules/ipex_specific/__init__.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/installer.py b/installer.py index cbb60c7fd..62510d303 100644 --- a/installer.py +++ b/installer.py @@ -323,7 +323,7 @@ def check_torch(): os.environ.setdefault('NEOReadDebugKeys', '1') os.environ.setdefault('ClDeviceGlobalMemSizeAvailablePercent', '100') os.environ.setdefault('TENSORFLOW_PACKAGE', 'tensorflow==2.12.0 intel-extension-for-tensorflow[gpu]') - torch_command = os.environ.get('TORCH_COMMAND', 'torch==1.13.0a0+git6c9b55e torchvision==0.14.1a0 intel_extension_for_pytorch==1.13.120+xpu -f https://developer.intel.com/ipex-whl-stable-xpu') + torch_command = os.environ.get('TORCH_COMMAND', 'torch==2.0.1a0 torchvision==0.15.2a0 intel_extension_for_pytorch==2.0.110+xpu -f https://developer.intel.com/ipex-whl-stable-xpu') else: machine = platform.machine() if sys.platform == 'darwin': diff --git a/modules/ipex_specific/__init__.py b/modules/ipex_specific/__init__.py index 042777928..4bba9052c 100644 --- a/modules/ipex_specific/__init__.py +++ b/modules/ipex_specific/__init__.py @@ -1,4 +1,5 @@ import os +import contextlib import torch import intel_extension_for_pytorch as ipex from modules import shared @@ -16,6 +17,9 @@ def ipex_no_cuda(orig_func, *args, **kwargs): # pylint: disable=redefined-outer- orig_func(*args, **kwargs) torch.cuda.is_available = torch.xpu.is_available +def return_null_context(*args, **kwargs): + return contextlib.nullcontext() + def ipex_init(): #Fix functions with ipex torch.cuda.is_available = torch.xpu.is_available @@ -27,6 +31,7 @@ def ipex_init(): torch._utils._get_available_device_type = lambda: "xpu" # pylint: disable=protected-access torch.cuda.set_device = torch.xpu.set_device torch.cuda.synchronize = torch.xpu.synchronize + torch.backends.cuda.sdp_kernel = return_null_context torch.Tensor.cuda = torch.Tensor.xpu torch.nn.DataParallel = DummyDataParallel From 4535a99fff3d9b95e10e0fa9efe6b14078f89264 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Thu, 3 Aug 2023 17:25:15 +0300 Subject: [PATCH 06/21] Model compile support for IPEX --- modules/sd_hijack.py | 38 +++++++++++++++++++++----------------- modules/sd_models.py | 12 ++++++++---- modules/shared.py | 5 +++-- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/modules/sd_hijack.py b/modules/sd_hijack.py index 362285f4a..67826cb91 100644 --- a/modules/sd_hijack.py +++ b/modules/sd_hijack.py @@ -174,27 +174,31 @@ class StableDiffusionModelHijack: if m.cond_stage_key == "edit": sd_hijack_unet.hijack_ddpm_edit() + if opts.ipex_optimize and shared.backend == shared.Backend.ORIGINAL: + try: + import intel_extension_for_pytorch as ipex # pylint: disable=import-error, unused-import + m.model.training = False + m.model = ipex.optimize(m.model, dtype=devices.dtype_unet, inplace=True, weights_prepack=False) # pylint: disable=attribute-defined-outside-init + shared.log.info("Applied IPEX Optimize.") + except Exception as err: + shared.log.warning(f"IPEX Optimize not supported: {err}") + if opts.cuda_compile and opts.cuda_compile_mode != 'none' and shared.backend == shared.Backend.ORIGINAL: try: import logging shared.log.info(f"Compiling pipeline={m.model.__class__.__name__} mode={opts.cuda_compile_mode}") - if opts.cuda_compile_mode == 'ipex': - import intel_extension_for_pytorch as ipex # pylint: disable=import-error, unused-import - m.model.training = False - m.model = ipex.optimize(m.model, dtype=devices.dtype_unet, inplace=True, weights_prepack=False) # pylint: disable=attribute-defined-outside-init - else: - import torch._dynamo # pylint: disable=unused-import,redefined-outer-name - log_level = logging.WARNING if opts.cuda_compile_verbose else logging.CRITICAL # pylint: disable=protected-access - if hasattr(torch, '_logging'): - torch._logging.set_logs(dynamo=log_level, aot=log_level, inductor=log_level) # pylint: disable=protected-access - torch._dynamo.config.verbose = opts.cuda_compile_verbose # pylint: disable=protected-access - torch._dynamo.config.suppress_errors = opts.cuda_compile_errors # pylint: disable=protected-access - torch.backends.cudnn.benchmark = True - if opts.cuda_compile_mode == 'hidet': - import hidet - hidet.torch.dynamo_config.use_tensor_core(True) - hidet.torch.dynamo_config.search_space(2) - m.model = torch.compile(m.model, mode="default", backend=opts.cuda_compile_mode, fullgraph=opts.cuda_compile_fullgraph, dynamic=False) + import torch._dynamo # pylint: disable=unused-import,redefined-outer-name + log_level = logging.WARNING if opts.cuda_compile_verbose else logging.CRITICAL # pylint: disable=protected-access + if hasattr(torch, '_logging'): + torch._logging.set_logs(dynamo=log_level, aot=log_level, inductor=log_level) # pylint: disable=protected-access + torch._dynamo.config.verbose = opts.cuda_compile_verbose # pylint: disable=protected-access + torch._dynamo.config.suppress_errors = opts.cuda_compile_errors # pylint: disable=protected-access + torch.backends.cudnn.benchmark = True + if opts.cuda_compile_mode == 'hidet': + import hidet + hidet.torch.dynamo_config.use_tensor_core(True) + hidet.torch.dynamo_config.search_space(2) + m.model = torch.compile(m.model, mode="default", backend=opts.cuda_compile_mode, fullgraph=opts.cuda_compile_fullgraph, dynamic=False) shared.log.info("Model complilation done.") except Exception as err: shared.log.warning(f"Model compile not supported: {err}") diff --git a/modules/sd_models.py b/modules/sd_models.py index fa7002ec0..b9a64b870 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -708,7 +708,7 @@ def load_diffuser(checkpoint_info=None, already_loaded_state_dict=None, timer=No sd_model.unet.to(memory_format=torch.channels_last) base_sent_to_cpu=False - if shared.opts.cuda_compile and torch.cuda.is_available(): + if (shared.opts.cuda_compile or shared.opts.ipex_optimize) and torch.cuda.is_available(): if op == 'refiner' and not sd_model.has_accelerate: gpu_vram = memory_stats().get('gpu', {}) free_vram = gpu_vram.get('total', 0) - gpu_vram.get('used', 0) @@ -731,11 +731,15 @@ def load_diffuser(checkpoint_info=None, already_loaded_state_dict=None, timer=No elif not sd_model.has_accelerate: sd_model.to(devices.device) try: - shared.log.info(f"Compiling pipeline={sd_model.__class__.__name__} shape={8 * sd_model.unet.config.sample_size} mode={shared.opts.cuda_compile_mode}") - if shared.opts.cuda_compile_mode == 'ipex': + if shared.opts.ipex_optimize: sd_model.unet.training = False sd_model.unet = torch.xpu.optimize(sd_model.unet, dtype=devices.dtype_unet, inplace=True, weights_prepack=False) # pylint: disable=attribute-defined-outside-init - else: + shared.log.info("Applied IPEX Optimize.") + except Exception as err: + shared.log.warning(f"IPEX Optimize not supported: {err}") + try: + if shared.opts.cuda_compile: + shared.log.info(f"Compiling pipeline={sd_model.__class__.__name__} shape={8 * sd_model.unet.config.sample_size} mode={shared.opts.cuda_compile_mode}") import torch._dynamo # pylint: disable=unused-import,redefined-outer-name log_level = logging.WARNING if shared.opts.cuda_compile_verbose else logging.CRITICAL # pylint: disable=protected-access if hasattr(torch, '_logging'): diff --git a/modules/shared.py b/modules/shared.py index 63f5549b4..fa9aab298 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -384,12 +384,13 @@ options_templates.update(options_section(('cuda', "Compute Settings"), { "cudnn_benchmark": OptionInfo(False, "Enable full-depth cuDNN benchmark feature"), "cuda_allow_tf32": OptionInfo(True, "Allow TF32 math ops"), "cuda_allow_tf16_reduced": OptionInfo(True, "Allow TF16 reduced precision math ops"), - "cuda_compile": OptionInfo(True if devices.backend == "ipex" else False, "Enable model compile (experimental)"), - "cuda_compile_mode": OptionInfo("ipex" if devices.backend == "ipex" else "none", "Model compile mode (experimental)", gr.Radio, lambda: {"choices": ['none', 'inductor', 'reduce-overhead', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'ipex']}), + "cuda_compile": OptionInfo(False, "Enable model compile (experimental)"), + "cuda_compile_mode": OptionInfo("none", "Model compile mode (experimental)", gr.Radio, lambda: {"choices": ['none', 'default', 'inductor', 'reduce-overhead', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'max-autotune', 'ipex']}), "cuda_compile_fullgraph": OptionInfo(False, "Model compile fullgraph"), "cuda_compile_verbose": OptionInfo(False, "Model compile verbose mode"), "cuda_compile_errors": OptionInfo(True, "Model compile suppress errors"), "disable_gc": OptionInfo(True, "Disable Torch memory garbage collection"), + "ipex_optimize": OptionInfo(True if devices.backend == "ipex" else False, "Enable IPEX Optimize for Intel GPUs"), "directml_memory_provider": OptionInfo(default_memory_provider, '[DirectML] Memory stats provider', gr.Dropdown, lambda: {"choices": memory_providers}), })) From 44b17b74186e03a1aa0c1662ba4bf94bd56390a8 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Thu, 3 Aug 2023 17:51:29 +0300 Subject: [PATCH 07/21] Add compile type option --- modules/sd_hijack.py | 2 +- modules/sd_models.py | 2 +- modules/shared.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/sd_hijack.py b/modules/sd_hijack.py index 67826cb91..f07cfef75 100644 --- a/modules/sd_hijack.py +++ b/modules/sd_hijack.py @@ -198,7 +198,7 @@ class StableDiffusionModelHijack: import hidet hidet.torch.dynamo_config.use_tensor_core(True) hidet.torch.dynamo_config.search_space(2) - m.model = torch.compile(m.model, mode="default", backend=opts.cuda_compile_mode, fullgraph=opts.cuda_compile_fullgraph, dynamic=False) + m.model = torch.compile(m.model, mode=opts.cuda_compile_type, backend=opts.cuda_compile_mode, fullgraph=opts.cuda_compile_fullgraph, dynamic=False) shared.log.info("Model complilation done.") except Exception as err: shared.log.warning(f"Model compile not supported: {err}") diff --git a/modules/sd_models.py b/modules/sd_models.py index b9a64b870..f581ebf6d 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -746,7 +746,7 @@ def load_diffuser(checkpoint_info=None, already_loaded_state_dict=None, timer=No torch._logging.set_logs(dynamo=log_level, aot=log_level, inductor=log_level) # pylint: disable=protected-access torch._dynamo.config.verbose = shared.opts.cuda_compile_verbose # pylint: disable=protected-access torch._dynamo.config.suppress_errors = shared.opts.cuda_compile_errors # pylint: disable=protected-access - sd_model.unet = torch.compile(sd_model.unet, mode=shared.opts.cuda_compile_mode, fullgraph=shared.opts.cuda_compile_fullgraph) # pylint: disable=attribute-defined-outside-init + sd_model.unet = torch.compile(sd_model.unet, mode=shared.opts.cuda_compile_type, backend=shared.opts.cuda_compile_mode, fullgraph=shared.opts.cuda_compile_fullgraph) # pylint: disable=attribute-defined-outside-init sd_model("dummy prompt") shared.log.info("Complilation done.") except Exception as err: diff --git a/modules/shared.py b/modules/shared.py index fa9aab298..721dff3da 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -385,7 +385,8 @@ options_templates.update(options_section(('cuda', "Compute Settings"), { "cuda_allow_tf32": OptionInfo(True, "Allow TF32 math ops"), "cuda_allow_tf16_reduced": OptionInfo(True, "Allow TF16 reduced precision math ops"), "cuda_compile": OptionInfo(False, "Enable model compile (experimental)"), - "cuda_compile_mode": OptionInfo("none", "Model compile mode (experimental)", gr.Radio, lambda: {"choices": ['none', 'default', 'inductor', 'reduce-overhead', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'max-autotune', 'ipex']}), + "cuda_compile_mode": OptionInfo("none", "Model compile mode (experimental)", gr.Radio, lambda: {"choices": ['none', 'inductor', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'ipex']}), + "cuda_compile_type": OptionInfo("default", "Model compile type (experimental)", gr.Radio, lambda: {"choices": ['default', 'reduce-overhead', 'max-autotune']}), "cuda_compile_fullgraph": OptionInfo(False, "Model compile fullgraph"), "cuda_compile_verbose": OptionInfo(False, "Model compile verbose mode"), "cuda_compile_errors": OptionInfo(True, "Model compile suppress errors"), From 6fbc9a53f8d15a0693406b374fa839eb0dd2fbfa Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 3 Aug 2023 17:46:53 +0200 Subject: [PATCH 08/21] update git flag --- extensions-builtin/sd-webui-agent-scheduler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions-builtin/sd-webui-agent-scheduler b/extensions-builtin/sd-webui-agent-scheduler index 1a5be3bf3..ea470d752 160000 --- a/extensions-builtin/sd-webui-agent-scheduler +++ b/extensions-builtin/sd-webui-agent-scheduler @@ -1 +1 @@ -Subproject commit 1a5be3bf3ae9b829681fcbe4614a1dc43a06d57e +Subproject commit ea470d75242ef7ae6fed6019b6ba227a4926b671 From d7ae6c61e1b974146ab6f173bad6054d0d5e09cd Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 3 Aug 2023 17:49:52 +0200 Subject: [PATCH 09/21] git autostash --- installer.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/installer.py b/installer.py index 62510d303..0e6a28ae8 100644 --- a/installer.py +++ b/installer.py @@ -234,14 +234,18 @@ def branch(folder): # update git repository def update(folder, current_branch = False): + try: + git('config rebase.Autostash true') + except Exception: + pass if current_branch: - git('pull --autostash --rebase --force', folder) + git('pull --rebase --force', folder) return b = branch(folder) if branch is None: - git('pull --autostash --rebase --force', folder) + git('pull --rebase --force', folder) else: - git(f'pull origin {b} --autostash --rebase --force', folder) + git(f'pull origin {b} --rebase --force', folder) # clone git repository From 434a1f967f41fcaabfa6af796106951be00851fd Mon Sep 17 00:00:00 2001 From: Disty0 Date: Thu, 3 Aug 2023 21:06:15 +0300 Subject: [PATCH 10/21] IPEX fixes --- html/locale_en.json | 1 + html/locale_ko.json | 1 + installer.py | 2 -- modules/ipex_specific/__init__.py | 57 ++++++++++++++++++++++++------- webui.sh | 4 --- 5 files changed, 47 insertions(+), 18 deletions(-) diff --git a/html/locale_en.json b/html/locale_en.json index 0d2a6cc20..925d935da 100644 --- a/html/locale_en.json +++ b/html/locale_en.json @@ -383,6 +383,7 @@ {"id":"","label":"Model compile suppress errors","localized":"","hint":""}, {"id":"","label":"Disable Torch memory garbage collection","localized":"","hint":"Disable Torch memory garbage collection on each generation. CG will still run before & after model load as well when low GPU memory threshold is reached."}, {"id":"","label":"Directory for temporary images; leave empty for default","localized":"","hint":""}, + {"id":"","label":"Enable IPEX Optimize for Intel GPUs","localized":"","hint":""}, {"id":"","label":"Cleanup non-default temporary directory when starting webui","localized":"","hint":""}, {"id":"","label":"Path to directory with stable diffusion checkpoints","localized":"","hint":""}, {"id":"","label":"Path to directory with stable diffusion diffusers","localized":"","hint":""}, diff --git a/html/locale_ko.json b/html/locale_ko.json index b49ddbf84..1dc3600e2 100644 --- a/html/locale_ko.json +++ b/html/locale_ko.json @@ -382,6 +382,7 @@ {"id":"","label":"Model compile verbose mode","localized":"","hint":""}, {"id":"","label":"Model compile suppress errors","localized":"모델 컴파일 시 오류 억제","hint":""}, {"id":"","label":"Disable Torch memory garbage collection","localized":"Torch 메모리 정리 비활성화","hint":"이미지 생성 시 메모리 정리를 하지 않는다. CG will still run before & after model load as well when low GPU memory threshold is reached."}, + {"id":"","label":"Enable IPEX Optimize for Intel GPUs","localized":"","hint":""}, {"id":"","label":"Directory for temporary images; leave empty for default","localized":"임시 이미지 저장 위치 (비워 놓으면 기본값)","hint":""}, {"id":"","label":"Cleanup non-default temporary directory when starting webui","localized":"임시 위치가 기본값이 아닌 경우 WebUI 시작 시 비우기","hint":""}, {"id":"","label":"Path to directory with stable diffusion checkpoints","localized":"체크포인트 위치","hint":""}, diff --git a/installer.py b/installer.py index 0e6a28ae8..a329c3d83 100644 --- a/installer.py +++ b/installer.py @@ -185,8 +185,6 @@ def install(package, friendly: str = None, ignore: bool = False): if args.reinstall or args.upgrade: global quick_allowed # pylint: disable=global-statement quick_allowed = False - if args.use_ipex and package == "pytorch_lightning==1.9.4": - package = "pytorch_lightning==1.8.6" if args.reinstall or not installed(package, friendly): pip(f"install --upgrade {package}", ignore=ignore) diff --git a/modules/ipex_specific/__init__.py b/modules/ipex_specific/__init__.py index 4bba9052c..19b0d8860 100644 --- a/modules/ipex_specific/__init__.py +++ b/modules/ipex_specific/__init__.py @@ -21,39 +21,72 @@ def return_null_context(*args, **kwargs): return contextlib.nullcontext() def ipex_init(): - #Fix functions with ipex - torch.cuda.is_available = torch.xpu.is_available + #Replace cuda with xpu: + torch.cuda.current_device = torch.xpu.current_device + torch.cuda.current_stream = torch.xpu.current_stream torch.cuda.device = torch.xpu.device torch.cuda.device_count = torch.xpu.device_count - torch.cuda.current_device = torch.xpu.current_device + torch.cuda.device_of = torch.xpu.device_of + torch.cuda.getDeviceIdListForCard = torch.xpu.getDeviceIdListForCard torch.cuda.get_device_name = torch.xpu.get_device_name torch.cuda.get_device_properties = torch.xpu.get_device_properties - torch._utils._get_available_device_type = lambda: "xpu" # pylint: disable=protected-access + torch.cuda.init = torch.xpu.init + torch.cuda.is_available = torch.xpu.is_available + torch.cuda.is_initialized = torch.xpu.is_initialized torch.cuda.set_device = torch.xpu.set_device + torch.cuda.stream = torch.xpu.stream torch.cuda.synchronize = torch.xpu.synchronize - torch.backends.cuda.sdp_kernel = return_null_context + torch.cuda.Event = torch.xpu.Event torch.Tensor.cuda = torch.Tensor.xpu - torch.nn.DataParallel = DummyDataParallel + torch.Tensor.is_cuda = torch.Tensor.is_xpu + torch.cuda.Stream = torch.xpu.Stream #Memory: - torch.xpu.empty_cache = torch.xpu.empty_cache if "WSL2" not in os.popen("uname -a").read() else lambda: None torch.cuda.empty_cache = torch.xpu.empty_cache - torch.cuda.ipc_collect = lambda: None torch.cuda.memory_stats = torch.xpu.memory_stats - torch.cuda.mem_get_info = lambda device=None: [(torch.xpu.get_device_properties(device).total_memory - torch.xpu.memory_allocated(device)), torch.xpu.get_device_properties(device).total_memory] + torch.cuda.memory_summary = torch.xpu.memory_summary + torch.cuda.memory_snapshot = torch.xpu.memory_snapshot torch.cuda.memory_allocated = torch.xpu.memory_allocated torch.cuda.max_memory_allocated = torch.xpu.max_memory_allocated + torch.cuda.memory_reserved = torch.xpu.memory_reserved + torch.cuda.max_memory_reserved = torch.xpu.max_memory_reserved torch.cuda.reset_peak_memory_stats = torch.xpu.reset_peak_memory_stats - torch.cuda.utilization = lambda: 0 + torch.cuda.memory_stats_as_nested_dict = torch.xpu.memory_stats_as_nested_dict + torch.cuda.reset_accumulated_memory_stats = torch.xpu.reset_accumulated_memory_stats + + #RNG: + torch.cuda.get_rng_state = torch.xpu.get_rng_state + torch.cuda.get_rng_state_all = torch.xpu.get_rng_state_all + torch.cuda.set_rng_state = torch.xpu.set_rng_state + torch.cuda.set_rng_state_all = torch.xpu.set_rng_state_all + torch.cuda.manual_seed = torch.xpu.manual_seed + torch.cuda.manual_seed_all = torch.xpu.manual_seed_all + torch.cuda.seed = torch.xpu.seed + torch.cuda.seed_all = torch.xpu.seed_all + torch.cuda.initial_seed = torch.xpu.initial_seed #Training: - torch.cuda.get_rng_state_all = torch.xpu.get_rng_state_all - torch.cuda.set_rng_state_all = torch.xpu.set_rng_state_all try: torch.cuda.amp.GradScaler = torch.xpu.amp.GradScaler except Exception: torch.cuda.amp.GradScaler = ipex.cpu.autocast._grad_scaler.GradScaler + #C + torch._C._cuda_getCurrentRawStream = ipex._C._getCurrentStream + ipex._C._DeviceProperties.major = 2023 + ipex._C._DeviceProperties.minor = 2 + + #Fix functions with ipex: + torch.cuda.mem_get_info = lambda device=None: [(torch.xpu.get_device_properties(device).total_memory - torch.xpu.memory_allocated(device)), torch.xpu.get_device_properties(device).total_memory] + torch._utils._get_available_device_type = lambda: "xpu" # pylint: disable=protected-access + torch.xpu.empty_cache = torch.xpu.empty_cache if "WSL2" not in os.popen("uname -a").read() else lambda: None + torch.cuda.get_device_properties.major = 2023 + torch.cuda.get_device_properties.minor = 2 + torch.backends.cuda.sdp_kernel = return_null_context + torch.nn.DataParallel = DummyDataParallel + torch.cuda.ipc_collect = lambda: None + torch.cuda.utilization = lambda: 0 + #Libraries that blindly uses cuda: #Adetailer: CondFunc('torch.Tensor.to', diff --git a/webui.sh b/webui.sh index dee18931f..0fe4108d2 100755 --- a/webui.sh +++ b/webui.sh @@ -96,10 +96,6 @@ if [[ ! -z "${ACCELERATE}" ]] && [ ${ACCELERATE}="True" ] && [ -x "$(command -v then echo "Launching accelerate launch.py..." exec accelerate launch --num_cpu_threads_per_process=6 launch.py "$@" -elif [[ -z "${first_launch}" ]] && [ -x "$(command -v ipexrun)" ] && [ -x "$(command -v numactl)" ] && [ -x "$(command -v sycl-ls)" ] -then - echo "Launching ipexrun launch.py..." - exec ipexrun launch.py "$@" else echo "Launching launch.py..." exec "${python_cmd}" launch.py "$@" From 5f5a564d4138a0fc984cecfdf89574571bd15709 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Thu, 3 Aug 2023 22:38:43 +0300 Subject: [PATCH 11/21] Update compile settings --- installer.py | 2 +- modules/sd_hijack.py | 8 ++++---- modules/sd_models.py | 6 +++--- modules/shared.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/installer.py b/installer.py index a329c3d83..d235bcc66 100644 --- a/installer.py +++ b/installer.py @@ -387,7 +387,7 @@ def check_torch(): pip('uninstall xformers --yes --quiet', ignore=True, quiet=True) except Exception as e: log.debug(f'Cannot install xformers package: {e}') - if opts.get('cuda_compile_mode', '') == 'hidet': + if opts.get('cuda_compile_backend', '') == 'hidet': install('hidet', 'hidet') if args.profile: print_profile(pr, 'Torch') diff --git a/modules/sd_hijack.py b/modules/sd_hijack.py index f07cfef75..a583d79d8 100644 --- a/modules/sd_hijack.py +++ b/modules/sd_hijack.py @@ -183,10 +183,10 @@ class StableDiffusionModelHijack: except Exception as err: shared.log.warning(f"IPEX Optimize not supported: {err}") - if opts.cuda_compile and opts.cuda_compile_mode != 'none' and shared.backend == shared.Backend.ORIGINAL: + if opts.cuda_compile and opts.cuda_compile_backend != 'none' and shared.backend == shared.Backend.ORIGINAL: try: import logging - shared.log.info(f"Compiling pipeline={m.model.__class__.__name__} mode={opts.cuda_compile_mode}") + shared.log.info(f"Compiling pipeline={m.model.__class__.__name__} mode={opts.cuda_compile_backend}") import torch._dynamo # pylint: disable=unused-import,redefined-outer-name log_level = logging.WARNING if opts.cuda_compile_verbose else logging.CRITICAL # pylint: disable=protected-access if hasattr(torch, '_logging'): @@ -194,11 +194,11 @@ class StableDiffusionModelHijack: torch._dynamo.config.verbose = opts.cuda_compile_verbose # pylint: disable=protected-access torch._dynamo.config.suppress_errors = opts.cuda_compile_errors # pylint: disable=protected-access torch.backends.cudnn.benchmark = True - if opts.cuda_compile_mode == 'hidet': + if opts.cuda_compile_backend == 'hidet': import hidet hidet.torch.dynamo_config.use_tensor_core(True) hidet.torch.dynamo_config.search_space(2) - m.model = torch.compile(m.model, mode=opts.cuda_compile_type, backend=opts.cuda_compile_mode, fullgraph=opts.cuda_compile_fullgraph, dynamic=False) + m.model = torch.compile(m.model, mode=opts.cuda_compile_mode, backend=opts.cuda_compile_backend, fullgraph=opts.cuda_compile_fullgraph, dynamic=False) shared.log.info("Model complilation done.") except Exception as err: shared.log.warning(f"Model compile not supported: {err}") diff --git a/modules/sd_models.py b/modules/sd_models.py index f581ebf6d..8e9d55042 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -739,16 +739,16 @@ def load_diffuser(checkpoint_info=None, already_loaded_state_dict=None, timer=No shared.log.warning(f"IPEX Optimize not supported: {err}") try: if shared.opts.cuda_compile: - shared.log.info(f"Compiling pipeline={sd_model.__class__.__name__} shape={8 * sd_model.unet.config.sample_size} mode={shared.opts.cuda_compile_mode}") + shared.log.info(f"Compiling pipeline={sd_model.__class__.__name__} shape={8 * sd_model.unet.config.sample_size} mode={shared.opts.cuda_compile_backend}") import torch._dynamo # pylint: disable=unused-import,redefined-outer-name log_level = logging.WARNING if shared.opts.cuda_compile_verbose else logging.CRITICAL # pylint: disable=protected-access if hasattr(torch, '_logging'): torch._logging.set_logs(dynamo=log_level, aot=log_level, inductor=log_level) # pylint: disable=protected-access torch._dynamo.config.verbose = shared.opts.cuda_compile_verbose # pylint: disable=protected-access torch._dynamo.config.suppress_errors = shared.opts.cuda_compile_errors # pylint: disable=protected-access - sd_model.unet = torch.compile(sd_model.unet, mode=shared.opts.cuda_compile_type, backend=shared.opts.cuda_compile_mode, fullgraph=shared.opts.cuda_compile_fullgraph) # pylint: disable=attribute-defined-outside-init + sd_model.unet = torch.compile(sd_model.unet, mode=shared.opts.cuda_compile_mode, backend=shared.opts.cuda_compile_backend, fullgraph=shared.opts.cuda_compile_fullgraph) # pylint: disable=attribute-defined-outside-init sd_model("dummy prompt") - shared.log.info("Complilation done.") + shared.log.info("Complilation done.") except Exception as err: shared.log.warning(f"Model compile not supported: {err}") diff --git a/modules/shared.py b/modules/shared.py index 721dff3da..3a3ce09f3 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -385,8 +385,8 @@ options_templates.update(options_section(('cuda', "Compute Settings"), { "cuda_allow_tf32": OptionInfo(True, "Allow TF32 math ops"), "cuda_allow_tf16_reduced": OptionInfo(True, "Allow TF16 reduced precision math ops"), "cuda_compile": OptionInfo(False, "Enable model compile (experimental)"), - "cuda_compile_mode": OptionInfo("none", "Model compile mode (experimental)", gr.Radio, lambda: {"choices": ['none', 'inductor', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'ipex']}), - "cuda_compile_type": OptionInfo("default", "Model compile type (experimental)", gr.Radio, lambda: {"choices": ['default', 'reduce-overhead', 'max-autotune']}), + "cuda_compile_backend": OptionInfo("none", "Model compile backend (experimental)", gr.Radio, lambda: {"choices": ['none', 'inductor', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'ipex']}), + "cuda_compile_mode": OptionInfo("default", "Model compile mode (experimental)", gr.Radio, lambda: {"choices": ['default', 'reduce-overhead', 'max-autotune']}), "cuda_compile_fullgraph": OptionInfo(False, "Model compile fullgraph"), "cuda_compile_verbose": OptionInfo(False, "Model compile verbose mode"), "cuda_compile_errors": OptionInfo(True, "Model compile suppress errors"), From b64fecf22e75780e1f53370537720871e7da75bf Mon Sep 17 00:00:00 2001 From: vladmandic Date: Fri, 4 Aug 2023 01:12:01 +0000 Subject: [PATCH 12/21] =?UTF-8?q?Deploying=20to=20master=20from=20@=20vlad?= =?UTF-8?q?mandic/automatic@5f5a564d4138a0fc984cecfdf89574571bd15709=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ce027cc4..d2afda669 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ General goals: ### **Sponsors**
-Allan GrantMichael HarrisBrent OzarToniXMatthew RunoHELLO WORLD SASSalad Technologies +Allan GrantMichael HarrisBrent OzarToniXMatthew RunoHELLO WORLD SASSalad TechnologiesGymDreams8

From fc3d96f6f6a0007edc5f1531f1244cf5034bf9da Mon Sep 17 00:00:00 2001 From: Disty0 Date: Fri, 4 Aug 2023 04:15:25 +0300 Subject: [PATCH 13/21] IPEX fix ControlNet PidiNet --- html/locale_en.json | 2 +- modules/ipex_specific/__init__.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/html/locale_en.json b/html/locale_en.json index 925d935da..c67068070 100644 --- a/html/locale_en.json +++ b/html/locale_en.json @@ -570,7 +570,7 @@ {"id":"","label":"Use model EMA weights when possible","localized":"","hint":""}, {"id":"","label":"Generator device","localized":"","hint":""}, {"id":"","label":"Enable sequential CPU offload","localized":"","hint":"Reduces GPU memory usage by transferring weights to the CPU. Increases inference time approximately 10%. Use with Enable Attention slicing for minimal memory consumption"}, - {"id":"","label":"Enable model CPU offload","localized":"","hint":"Transferring of entire models to the GPU, negligible impact on inference time while still providing some memory savings. Use with Enable Attention slicing for additional memory savings"}, + {"id":"","label":"Enable model CPU offload","localized":"","hint":"Transferring of entire models to the CPU, negligible impact on inference time while still providing some memory savings. Use with Enable Attention slicing for additional memory savings"}, {"id":"","label":"Enable VAE slicing","localized":"","hint":"Decodes batch latents one image at a time with limited VRAM. Small performance boost in VAE decode on multi-image batches. Use with Enable Attention slicing"}, {"id":"","label":"Enable VAE tiling","localized":"","hint":"Divide large images into overlapping tiles with limited VRAM. Might result in a minor increase in processing time. Use with Enable Attention Slicing"}, {"id":"","label":"Enable attention slicing","localized":"","hint":"Performs attention computation in steps instead of all at once. 10% slower inference times. Greatly reduces memory usage. Best used, period"}, diff --git a/modules/ipex_specific/__init__.py b/modules/ipex_specific/__init__.py index 19b0d8860..b71027b35 100644 --- a/modules/ipex_specific/__init__.py +++ b/modules/ipex_specific/__init__.py @@ -37,9 +37,10 @@ def ipex_init(): torch.cuda.stream = torch.xpu.stream torch.cuda.synchronize = torch.xpu.synchronize torch.cuda.Event = torch.xpu.Event + torch.cuda.Stream = torch.xpu.Stream + torch.cuda.FloatTensor = torch.xpu.FloatTensor torch.Tensor.cuda = torch.Tensor.xpu torch.Tensor.is_cuda = torch.Tensor.is_xpu - torch.cuda.Stream = torch.xpu.Stream #Memory: torch.cuda.empty_cache = torch.xpu.empty_cache From 668def0b9a09a6cc66d9007e94ca03281d578d36 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Fri, 4 Aug 2023 10:40:29 +0300 Subject: [PATCH 14/21] Add Windows packages for IPEX --- installer.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/installer.py b/installer.py index d235bcc66..bb19322f1 100644 --- a/installer.py +++ b/installer.py @@ -317,15 +317,18 @@ def check_torch(): os.environ.setdefault('TENSORFLOW_PACKAGE', 'tensorflow-rocm') torch_command = os.environ.get('TORCH_COMMAND', 'torch==2.0.1 torchvision==0.15.2 --index-url https://download.pytorch.org/whl/rocm5.4.2') xformers_package = os.environ.get('XFORMERS_PACKAGE', 'none') - elif allow_ipex and (args.use_ipex or shutil.which('sycl-ls') is not None or os.environ.get('ONEAPI_ROOT') is not None or os.path.exists('/opt/intel/oneapi')): + 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 log.info('Intel OneAPI Toolkit detected') - if shutil.which('sycl-ls') is None: - log.error('Intel OneAPI Toolkit is not activated! Start the WebUI with --use-ipex or activate OneAPI manually') + if shutil.which('sycl-ls') is None and shutil.which('sycl-ls.exe') is None: + log.error('Intel OneAPI Toolkit is not activated! Activate OneAPI manually!') os.environ.setdefault('NEOReadDebugKeys', '1') os.environ.setdefault('ClDeviceGlobalMemSizeAvailablePercent', '100') - os.environ.setdefault('TENSORFLOW_PACKAGE', 'tensorflow==2.12.0 intel-extension-for-tensorflow[gpu]') - torch_command = os.environ.get('TORCH_COMMAND', 'torch==2.0.1a0 torchvision==0.15.2a0 intel_extension_for_pytorch==2.0.110+xpu -f https://developer.intel.com/ipex-whl-stable-xpu') + if "linux" in sys.platform: + torch_command = os.environ.get('TORCH_COMMAND', 'torch==2.0.1a0 torchvision==0.15.2a0 intel_extension_for_pytorch==2.0.110+xpu -f https://developer.intel.com/ipex-whl-stable-xpu') + os.environ.setdefault('TENSORFLOW_PACKAGE', 'tensorflow==2.13.0 intel-extension-for-tensorflow[gpu]') + else: + torch_command = os.environ.get('TORCH_COMMAND', 'torch==2.0.0a0 torchvision intel_extension_for_pytorch==2.0.110+gitba7f6c1 -f https://developer.intel.com/ipex-whl-stable-xpu') else: machine = platform.machine() if sys.platform == 'darwin': From f1741a43320088c27d9866612df20eea609bb1c1 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Fri, 4 Aug 2023 11:11:30 +0300 Subject: [PATCH 15/21] Re-add ipexrun --- webui.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webui.sh b/webui.sh index 0fe4108d2..55bcab98b 100755 --- a/webui.sh +++ b/webui.sh @@ -96,6 +96,10 @@ if [[ ! -z "${ACCELERATE}" ]] && [ ${ACCELERATE}="True" ] && [ -x "$(command -v then echo "Launching accelerate launch.py..." exec accelerate launch --num_cpu_threads_per_process=6 launch.py "$@" +elif [[ -z "${first_launch}" ]] && [ -x "$(command -v ipexrun)" ] && [ -x "$(command -v numactl)" ] && [ -x "$(command -v sycl-ls)" ] +then + echo "Launching ipexrun launch.py..." + exec ipexrun --latency-mode launch.py "$@" else echo "Launching launch.py..." exec "${python_cmd}" launch.py "$@" From b7fcf4a41e8d7a8a46ba379927a1e90eb9e11346 Mon Sep 17 00:00:00 2001 From: vladmandic Date: Fri, 4 Aug 2023 13:15:57 +0000 Subject: [PATCH 16/21] =?UTF-8?q?Deploying=20to=20master=20from=20@=20vlad?= =?UTF-8?q?mandic/automatic@f1741a43320088c27d9866612df20eea609bb1c1=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d2afda669..73b78ebed 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ General goals: ### **Sponsors**
-Allan GrantMichael HarrisBrent OzarToniXMatthew RunoHELLO WORLD SASSalad TechnologiesGymDreams8 +Allan GrantMichael HarrisBrent OzarToniXMatthew RunoHELLO WORLD SASSalad TechnologiesGym Dreams • GymDreams8

From a12c9117e698a3380b7bcb6e6e50bde4b879542d Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Fri, 4 Aug 2023 11:23:22 +0200 Subject: [PATCH 17/21] add requirement check install flag --- TODO.md | 6 +++--- extensions-builtin/sd-dynamic-thresholding | 2 +- installer.py | 3 ++- modules/sd_models.py | 12 ++++++++---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/TODO.md b/TODO.md index f84b578b0..08c7e4655 100644 --- a/TODO.md +++ b/TODO.md @@ -12,12 +12,11 @@ Stuff to be fixed, in no particular order... Stuff to be added, in no particular order... - Diffusers: - - Add SD-XL Lora + - Add Hires + - Add Lora/Lyco mixer - Add ControlNet - Fix SD-XL Img2img/Inpaint - Add SD and SD-XL Pix2Pix - - Add VAE direct load from safetensors - - Fix Kandinsky 2.2 model - Fix DeepFloyd IF model - Redo Prompt parser for diffusers - Add unCLIP model @@ -54,6 +53,7 @@ Stuff to be added, in no particular order... - Templates for SD-XL training - Lora train UI - Redesign + - Extensions reporting framework - New UI - New inpainting canvas controls (move from backend to purely frontend) - New image browser (move from backend to purely frontend) diff --git a/extensions-builtin/sd-dynamic-thresholding b/extensions-builtin/sd-dynamic-thresholding index 639e40970..5349f0087 160000 --- a/extensions-builtin/sd-dynamic-thresholding +++ b/extensions-builtin/sd-dynamic-thresholding @@ -1 +1 @@ -Subproject commit 639e40970f9b88c019866a6babb34f3294465d39 +Subproject commit 5349f008721480a572ab9a917533afdd0dae7b9e diff --git a/installer.py b/installer.py index bb19322f1..b1b5d1520 100644 --- a/installer.py +++ b/installer.py @@ -588,7 +588,7 @@ def install_requirements(): if args.profile: pr = cProfile.Profile() pr.enable() - if args.skip_requirements: + if args.skip_requirements and not args.requirements: return log.info('Verifying requirements') with open('requirements.txt', 'r', encoding='utf8') as f: @@ -751,6 +751,7 @@ def add_args(parser): 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('--requirements', default = False, action='store_true', help = "Force re-check of requirements, default: %(default)s") group.add_argument('--quick', default = False, action='store_true', help = "Run with startup sequence only, default: %(default)s") group.add_argument("--use-ipex", default = False, action='store_true', help="Use Intel OneAPI XPU backend, default: %(default)s") group.add_argument('--use-directml', default = False, action='store_true', help = "Use DirectML if no compatible GPU is detected, default: %(default)s") diff --git a/modules/sd_models.py b/modules/sd_models.py index 8e9d55042..d010ffd6b 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -67,9 +67,11 @@ class CheckpointInfo: else: # maybe a diffuser repo = [r for r in modelloader.diffuser_repos if filename == r['filename']] if len(repo) == 0: - error_message = f'Cannot find diffuser model: {filename}' - shared.log.error(error_message) - raise ValueError(error_message) + if filename.lower() != 'none': + shared.log.error(f'Cannot find diffuser model: {filename}') + else: + shared.log.info(f'Skipping model load: {filename}') + return self.name = repo[0]['name'] self.hash = repo[0]['hash'][:8] self.sha256 = repo[0]['hash'] @@ -532,6 +534,8 @@ def change_backend(): def load_diffuser(checkpoint_info=None, already_loaded_state_dict=None, timer=None, op='model'): # pylint: disable=unused-argument + if op != 'model' and checkpoint_info is None and (shared.cmd_opts.ckpt is None or shared.cmd_opts.ckpt.lower() == 'none'): + return import torch # pylint: disable=reimported,redefined-outer-name devices.set_cuda_params() if timer is None: @@ -570,7 +574,7 @@ def load_diffuser(checkpoint_info=None, already_loaded_state_dict=None, timer=No sd_model = None try: - if shared.cmd_opts.ckpt is not None and model_data.initial: # initial load + if shared.cmd_opts.ckpt is not None and model_data.initial: # initial load\ ckpt_basename = os.path.basename(shared.cmd_opts.ckpt) model_name = modelloader.find_diffuser(ckpt_basename) if model_name is not None: From ef25cf9678a31a8adaba60d56187eeb5d5afa4ab Mon Sep 17 00:00:00 2001 From: tcmaps Date: Fri, 4 Aug 2023 15:00:30 +0200 Subject: [PATCH 18/21] opencv-headless --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 79d52cb80..e3ab89323 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,7 +24,7 @@ lmdb lpips omegaconf open-clip-torch -opencv-contrib-python +opencv-contrib-python-headless piexif psutil pyyaml @@ -48,7 +48,7 @@ antlr4-python3-runtime==4.9.3 requests==2.31.0 tqdm==4.65.0 accelerate==0.20.3 -opencv-python==4.7.0.72 +opencv-python-headless==4.7.0.72 diffusers==0.19.3 einops==0.4.1 gradio==3.32.0 From 81cfb4440dc59acd4158ccc634343b3731b725ad Mon Sep 17 00:00:00 2001 From: Disty0 Date: Fri, 4 Aug 2023 16:55:15 +0300 Subject: [PATCH 19/21] IPEX fix double starting ipexrun --- webui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webui.sh b/webui.sh index 55bcab98b..dee18931f 100755 --- a/webui.sh +++ b/webui.sh @@ -99,7 +99,7 @@ then elif [[ -z "${first_launch}" ]] && [ -x "$(command -v ipexrun)" ] && [ -x "$(command -v numactl)" ] && [ -x "$(command -v sycl-ls)" ] then echo "Launching ipexrun launch.py..." - exec ipexrun --latency-mode launch.py "$@" + exec ipexrun launch.py "$@" else echo "Launching launch.py..." exec "${python_cmd}" launch.py "$@" From 0611b1e4d92c4f3f7f408c0348d4e8b4bb4f1bac Mon Sep 17 00:00:00 2001 From: Marcin Dzierwa Date: Fri, 4 Aug 2023 18:58:47 +0200 Subject: [PATCH 20/21] added /sdapi/v1/sd-vae endpoint --- modules/api/api.py | 7 +++++++ modules/api/models.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/modules/api/api.py b/modules/api/api.py index c4bc4d49b..0a35a8fcf 100644 --- a/modules/api/api.py +++ b/modules/api/api.py @@ -9,10 +9,12 @@ from fastapi import FastAPI, APIRouter, Depends from fastapi.security import HTTPBasic, HTTPBasicCredentials from fastapi.exceptions import HTTPException from PIL import PngImagePlugin,Image + import piexif import piexif.helper import gradio as gr from modules import errors, shared, sd_samplers, deepbooru, sd_hijack, images, scripts, ui, postprocessing +from modules.sd_vae import vae_dict from modules.api import models from modules.processing import StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img, process_images from modules.textual_inversion.textual_inversion import create_embedding, train_embedding @@ -132,6 +134,7 @@ class Api: self.add_api_route("/sdapi/v1/prompt-styles", self.get_prompt_styles, methods=["GET"], response_model=List[models.PromptStyleItem]) self.add_api_route("/sdapi/v1/embeddings", self.get_embeddings, methods=["GET"], response_model=models.EmbeddingsResponse) self.add_api_route("/sdapi/v1/refresh-checkpoints", self.refresh_checkpoints, methods=["POST"]) + self.add_api_route("/sdapi/v1/sd-vae", self.get_sd_vaes, methods=["GET"], response_model=List[models.SDVaeItem]) self.add_api_route("/sdapi/v1/refresh-vaes", self.refresh_vaes, methods=["POST"]) self.add_api_route("/sdapi/v1/create/embedding", self.create_embedding, methods=["POST"], response_model=models.CreateResponse) self.add_api_route("/sdapi/v1/create/hypernetwork", self.create_hypernetwork, methods=["POST"], response_model=models.CreateResponse) @@ -445,6 +448,10 @@ class Api: def get_samplers(self): return [{"name": sampler[0], "aliases":sampler[2], "options":sampler[3]} for sampler in sd_samplers.all_samplers] + + def get_sd_vaes(self): + return [{"model_name": x, "filename": vae_dict[x]} for x in vae_dict.keys()] + def get_upscalers(self): return [ diff --git a/modules/api/models.py b/modules/api/models.py index 704ebfe92..a14d6d299 100644 --- a/modules/api/models.py +++ b/modules/api/models.py @@ -232,6 +232,10 @@ class SamplerItem(BaseModel): aliases: List[str] = Field(title="Aliases") options: Dict[str, str] = Field(title="Options") +class SDVaeItem(BaseModel): + model_name: str = Field(title="Model Name") + filename: str = Field(title="Filename") + class UpscalerItem(BaseModel): name: str = Field(title="Name") model_name: Optional[str] = Field(title="Model Name") From e925394b99ba4c4e6531a1997ecaeab589a4986a Mon Sep 17 00:00:00 2001 From: Disty0 Date: Fri, 4 Aug 2023 20:01:21 +0300 Subject: [PATCH 21/21] Disable ipexrun on WSL --- webui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webui.sh b/webui.sh index dee18931f..550008f2d 100755 --- a/webui.sh +++ b/webui.sh @@ -96,7 +96,7 @@ if [[ ! -z "${ACCELERATE}" ]] && [ ${ACCELERATE}="True" ] && [ -x "$(command -v then echo "Launching accelerate launch.py..." exec accelerate launch --num_cpu_threads_per_process=6 launch.py "$@" -elif [[ -z "${first_launch}" ]] && [ -x "$(command -v ipexrun)" ] && [ -x "$(command -v numactl)" ] && [ -x "$(command -v sycl-ls)" ] +elif [[ -z "${first_launch}" ]] && [[ $(uname -a) != *WSL2* ]] && [ -x "$(command -v ipexrun)" ] && [ -x "$(command -v numactl)" ] && [ -x "$(command -v sycl-ls)" ] then echo "Launching ipexrun launch.py..." exec ipexrun launch.py "$@"