ModelSurge / sd-webui-comfyui

An extension to integrate ComfyUI workflows into the Webui's pipeline
MIT License
507 stars 32 forks source link

Commit e4ed9b6b will cause error? Python 3.10.11 on Win10 #148

Closed gamert closed 1 year ago

gamert commented 1 year ago

It's ok When back to Commit d2ed1a98 by ljleb, 2023-08-10 上午09:36. So may be caused by Commit e4ed9b6b [by ljleb, 2023-08-11 上午02:24]. Start comfyui in subprocess instead of multiprocessing (#101)

Command log: ... Running on local URL: http://0.0.0.0:7862

To create a public link, set share=True in launch(). [sd-webui-comfyui] Started callback listeners for process webui Startup time: 11.8s (launcher: 1.6s, import torch: 3.0s, import gradio: 0.6s, setup paths: 0.3s, other imports: 0.6s, load scripts: 1.0s, create ui: 0.2s, gradio launch: 4.4s). Traceback (most recent call last): File "D:\sd.webui\webui\extensions\sd-webui-comfyui\lib_comfyui\comfyui\pre_main.py", line 7, in from lib_comfyui import ( ModuleNotFoundError: No module named 'lib_comfyui'

version: v1.5.1-1-g417f5914  •  python: 3.10.11  •  torch: 2.0.1+cu118  •  xformers: 0.0.20  •  gradio: 3.32.0  •  checkpoint: d725be5d18

gamert commented 1 year ago

Commit 7c32e696 [ by ljleb, 2023-08-06 上午11:21] will lose all nodes.

ComfyUI Revision: 1315 [01f4f819]

image

ljleb commented 1 year ago

That's really odd, the extension should patch the PYTHONPATH env var to add the extension folder.

Some questions:

And then try starting the extension again on the latest commit.

PladsElsker commented 1 year ago

To my knowledge, the last commit is a332cfa. I think the solution would be to update the extension to the latest commit.

ljleb commented 1 year ago

I'm not aware of changes that would create the issue on the given commit. In any case, maybe trying this first is a good idea.

gamert commented 1 year ago

I guess that the sys.path is a new one when lauched in subprocess( subprocess.Popen ?) ?

[AddNet] Updating model hashes... 100%|███████████████████████████████████████████████████████████████████████████████| 12/12 [00:00<00:00, 11992.29it/s] [AddNet] Updating model hashes... 100%|███████████████████████████████████████████████████████████████████████████████| 12/12 [00:00<00:00, 11986.58it/s] ['D:\sd.webui\webui\extensions\sd-webui-comfyui', 'D:\sd.webui\webui\repositories\k-diffusion', 'D:\sd.webui\webui', '', 'D:\sd.webui\system\.launcher', 'D:\sd.webui\system', 'D:\sd.webui\system\python\python310.zip', 'D:\sd.webui\system\python', 'D:\sd.webui\system\python\lib\site-packages', 'D:\sd.webui\system\python\lib\site-packages\win32', 'D:\sd.webui\system\python\lib\site-packages\win32\lib', 'D:\sd.webui\system\python\lib\site-packages\Pythonwin', 'D:\sd.webui\webui\repositories\stable-diffusion-stability-ai', 'D:\sd.webui\webui\repositories\CodeFormer', 'D:\sd.webui\webui\repositories\BLIP'] 2023-08-24 20:13:17,664 - ControlNet - INFO - ControlNet v1.1.311 ControlNet preprocessor location: D:\sd.webui\webui\extensions\sd-webui-controlnet\annotator\downloads 2023-08-24 20:13:17,768 - ControlNet - INFO - ControlNet v1.1.311 sd-webui-prompt-all-in-one background API service started successfully. == WD14 tagger /gpu:0, uname_result(system='Windows', node='txzPC', release='10', version='10.0.19045', machine='AMD64') == Loading weights [d725be5d18] from D:\sd.webui\webui\models\Stable-diffusion\revAnimated_v11.safetensors Creating model from config: D:\sd.webui\webui\configs\v1-inference.yaml LatentDiffusion: Running in eps-prediction mode DiffusionWrapper has 859.52 M params. Loading VAE weights specified in settings: D:\sd.webui\webui\models\VAE\vae-ft-mse-840000-ema-pruned.safetensors Applying attention optimization: xformers... done. Model loaded in 2.9s (load weights from disk: 0.5s, create model: 0.5s, apply weights to model: 0.7s, apply half(): 0.5s, load VAE: 0.1s, move model to device: 0.6s). Running on local URL: http://0.0.0.0:7862

To create a public link, set share=True in launch(). INFO - [AgentScheduler] Task queue is empty INFO - [AgentScheduler] Registering APIs [sd-webui-comfyui] Started callback listeners for process webui ['', 'D:\sd.webui\system\.launcher', 'D:\sd.webui\system', 'D:\sd.webui\system\python\python310.zip', 'D:\sd.webui\system\python', 'D:\sd.webui\system\python\lib\site-packages', 'D:\sd.webui\system\python\lib\site-packages\win32', 'D:\sd.webui\system\python\lib\site-packages\win32\lib', 'D:\sd.webui\system\python\lib\site-packages\Pythonwin'] Traceback (most recent call last): File "D:\sd.webui\webui\extensions\sd-webui-comfyui\lib_comfyui\comfyui\pre_main.py", line 8, in from lib_comfyui import ( ModuleNotFoundError: No module named 'lib_comfyui' Startup time: 18.2s (launcher: 5.7s, import torch: 3.4s, import gradio: 0.4s, setup paths: 0.3s, other imports: 0.6s, load scripts: 2.4s, create ui: 0.6s, gradio launch: 4.5s, app_started_callback: 0.2s).

ljleb commented 1 year ago

Yes a new PYTHONPATH env var is created. I tried to make the code compose it so that it is as if comfyui was started from the command line manually. The paths to the extension dir and comfyui should both be in there, but they are not. If you know how to debug code, this is where the path should be altered:

https://github.com/ModelSurge/sd-webui-comfyui/blob/b6e60fcffa895592c3443ca68840307e00f997b7/lib_comfyui/comfyui_process.py#L66

Either the line is never reached for some reason (which would not make any sense), or the paths are not taken into consideration for some reason. Maybe we need to make a copy of a venv before passing it to popen?

ljleb commented 1 year ago

AFAIK this problem should be resolved. I would like to know if anybody else is able to verify this, as I was not able to reproduce the initial problem on my system.

ljleb commented 1 year ago

I'm closing this for tidying reasons, but please le me know if you run into this problem again.