Gourieff / sd-webui-reactor

Fast and Simple Face Swap Extension for StableDiffusion WebUI (A1111 SD WebUI, SD WebUI Forge, SD.Next, Cagliostro)
GNU Affero General Public License v3.0
2.55k stars 278 forks source link

VRAM is not released after generation #306

Closed root228 closed 10 months ago

root228 commented 10 months ago

First, confirm

What happened?

VRAM is not released after using this extension

vram

Steps to reproduce the problem

  1. Start generation using reactor

Sysinfo

sysinfo-2024-01-03-14-25.json

Relevant console log

Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.7.0
Commit hash: cf2772fab0af5573da775e7437e6acdca424f26e
ReActor preheating... Device: CUDA
Launching Web UI with arguments: --xformers --medvram --opt-split-attention --no-half-vae
Style database not found: D:\stablediff\mydream\new\stable-diffusion-webui\styles.csv
ControlNet preprocessor location: D:\stablediff\mydream\new\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads
2024-01-03 17:31:59,762 - ControlNet - INFO - ControlNet v1.1.426
2024-01-03 17:31:59,824 - ControlNet - INFO - ControlNet v1.1.426
17:32:00 - ReActor - STATUS - Running v0.6.0-a4
Loading weights [e5f3cbc5f7] from D:\stablediff\mydream\new\stable-diffusion-webui\models\Stable-diffusion\realisticVisionV60B1_v60B1VAE.safetensors
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Creating model from config: D:\stablediff\mydream\new\stable-diffusion-webui\configs\v1-inference.yaml
Startup time: 10.3s (prepare environment: 3.3s, import torch: 2.3s, import gradio: 0.7s, setup paths: 0.6s, initialize shared: 0.2s, other imports: 0.4s, setup codeformer: 0.2s, load scripts: 1.5s, create ui: 0.5s, gradio launch: 0.5s).
Applying attention optimization: xformers... done.
Model loaded in 4.5s (load weights from disk: 0.8s, create model: 0.3s, apply weights to model: 1.8s, apply half(): 0.4s, calculate empty prompt: 1.1s).
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:21<00:00,  1.09s/it]
17:32:31 - ReActor - STATUS - Working: source face index [0], target face index [0]████| 20/20 [00:20<00:00,  1.06s/it]
17:32:31 - ReActor - INFO - Source Image MD5 Hash = 97fa7f1f79fc82d088ee6d9b6336b43d
17:32:31 - ReActor - INFO - Source Image the Same? False
17:32:31 - ReActor - STATUS - Analyzing Source Image...
17:32:31 - ReActor - INFO - Applied Execution Provider: CUDAExecutionProvider
Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CUDAExecutionProvider': {'cudnn_conv_algo_search': 'EXHAUSTIVE', 'device_id': '0', 'cudnn_conv1d_pad_to_nc1d': '0', 'has_user_compute_stream': '0', 'gpu_external_alloc': '0', 'enable_cuda_graph': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'tunable_op_tuning_enable': '0', 'tunable_op_max_tuning_duration_ms': '0', 'enable_skip_layer_norm_strict_mode': '0'}, 'CPUExecutionProvider': {}}
find model: D:\stablediff\mydream\new\stable-diffusion-webui\models\insightface\models\buffalo_l\1k3d68.onnx landmark_3d_68 ['None', 3, 192, 192] 0.0 1.0
Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CUDAExecutionProvider': {'cudnn_conv_algo_search': 'EXHAUSTIVE', 'device_id': '0', 'cudnn_conv1d_pad_to_nc1d': '0', 'has_user_compute_stream': '0', 'gpu_external_alloc': '0', 'enable_cuda_graph': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'tunable_op_tuning_enable': '0', 'tunable_op_max_tuning_duration_ms': '0', 'enable_skip_layer_norm_strict_mode': '0'}, 'CPUExecutionProvider': {}}
find model: D:\stablediff\mydream\new\stable-diffusion-webui\models\insightface\models\buffalo_l\2d106det.onnx landmark_2d_106 ['None', 3, 192, 192] 0.0 1.0
Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CUDAExecutionProvider': {'cudnn_conv_algo_search': 'EXHAUSTIVE', 'device_id': '0', 'cudnn_conv1d_pad_to_nc1d': '0', 'has_user_compute_stream': '0', 'gpu_external_alloc': '0', 'enable_cuda_graph': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'tunable_op_tuning_enable': '0', 'tunable_op_max_tuning_duration_ms': '0', 'enable_skip_layer_norm_strict_mode': '0'}, 'CPUExecutionProvider': {}}
find model: D:\stablediff\mydream\new\stable-diffusion-webui\models\insightface\models\buffalo_l\det_10g.onnx detection [1, 3, '?', '?'] 127.5 128.0
Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CUDAExecutionProvider': {'cudnn_conv_algo_search': 'EXHAUSTIVE', 'device_id': '0', 'cudnn_conv1d_pad_to_nc1d': '0', 'has_user_compute_stream': '0', 'gpu_external_alloc': '0', 'enable_cuda_graph': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'tunable_op_tuning_enable': '0', 'tunable_op_max_tuning_duration_ms': '0', 'enable_skip_layer_norm_strict_mode': '0'}, 'CPUExecutionProvider': {}}
find model: D:\stablediff\mydream\new\stable-diffusion-webui\models\insightface\models\buffalo_l\genderage.onnx genderage ['None', 3, 96, 96] 0.0 1.0
Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CUDAExecutionProvider': {'cudnn_conv_algo_search': 'EXHAUSTIVE', 'device_id': '0', 'cudnn_conv1d_pad_to_nc1d': '0', 'has_user_compute_stream': '0', 'gpu_external_alloc': '0', 'enable_cuda_graph': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'tunable_op_tuning_enable': '0', 'tunable_op_max_tuning_duration_ms': '0', 'enable_skip_layer_norm_strict_mode': '0'}, 'CPUExecutionProvider': {}}
find model: D:\stablediff\mydream\new\stable-diffusion-webui\models\insightface\models\buffalo_l\w600k_r50.onnx recognition ['None', 3, 112, 112] 127.5 127.5
set det-size: (640, 640)
17:32:32 - ReActor - STATUS - Analyzing Target Image...
17:32:32 - ReActor - INFO - Applied Execution Provider: CUDAExecutionProvider
set det-size: (640, 640)
17:32:33 - ReActor - STATUS - Detecting Source Face, Index = 0
17:32:33 - ReActor - STATUS - Detected: -34- y.o. Female
Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CUDAExecutionProvider': {'cudnn_conv_algo_search': 'EXHAUSTIVE', 'device_id': '0', 'cudnn_conv1d_pad_to_nc1d': '0', 'has_user_compute_stream': '0', 'gpu_external_alloc': '0', 'enable_cuda_graph': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'tunable_op_tuning_enable': '0', 'tunable_op_max_tuning_duration_ms': '0', 'enable_skip_layer_norm_strict_mode': '0'}, 'CPUExecutionProvider': {}}
inswapper-shape: [1, 3, 128, 128]
17:32:34 - ReActor - STATUS - Detecting Target Face, Index = 0
17:32:34 - ReActor - STATUS - Detected: -23- y.o. Female
17:32:34 - ReActor - STATUS - Swapping Source into Target
17:32:36 - ReActor - STATUS - Restoring the face with CodeFormer
Total progress: 100%|██████████████████████████████████████████████████████████████████| 20/20 [00:29<00:00,  1.48s/it]
Total progress: 100%|██████████████████████████████████████████████████████████████████| 20/20 [00:29<00:00,  1.06s/it]

Additional information

No response

Gourieff commented 10 months ago

Приветствую, переключитесь на CPU, если вам не хватает VRAM Это особенности использования ORT-GPU, первый свап долгий, все последующие быстрые, как раз за счёт того, что модели не перезагружаются повторно, как и EP (Execution Provider) Модели легковесные (не более 0,9Gb суммарно), и для нормального кол-ва VRAM это никак не влияет на производительность Если у вас VRAM немного и +/- 900Мб играют роль, то переключите РеАктор на работу с CPU (вкладка Settings)