AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
140.07k stars 26.52k forks source link

[Bug]: AttributeError: module 'tensorflow' has no attribute 'Tensor' - after recent update #6212

Closed Harvester62 closed 1 year ago

Harvester62 commented 1 year ago

Is there an existing issue for this?

What happened?

After recently updates of the SD Web UI via Git Pull, I am no longer able to generate an image, getting an error related to Tensor (see below). This also seems to prevent the upload of Dynamic Prompts extension.

Steps to reproduce the problem

Nothing special, simply added a prompt and then clicked on the Generate button.

What should have happened?

To properly generate an image.

Commit where the problem happens

fd4461d44c7256d56889f5b5ed9fb660a859172f

What platforms do you use to access UI ?

Windows

What browsers do you use to access the UI ?

Mozilla Firefox

Command Line Arguments

--xformers --opt-split-attention --disable-safe-unpickle --api --deepdanbooru --allow-code --administrator --medvram --ckptfix --theme dark --cors-allow-origins=http://localhost:5173,https://www.painthua.com

Additional information, context and logs

The following is the Traceback error displayed after clicking the Generate button (as a safety measure I deactivated all extensions but the Image Gallery).

errors_tensor_sdwebui

Nicoolodion commented 1 year ago

I have the exact same problem... I thaught the reason for it were the extensions that I installed but if you have the same problem...

Harvester62 commented 1 year ago

Hi @Nicoolodion , at the beginning I got an error with the Dynamic Prompts extension and I thought the problem was with that, in fact I submitted a bug report to the developer, but then I discovered that I couldn't generate any images, so I deactivated all the extenstions but the Image Gallery, and I realized that the issue was not of Dynamic Prompts but of SD Web UI itself. Let see if the developers will be able to find the source of this problem. I need to have all the extensions activated to properly translate the Web UI, the Scripts and the Extensions.

minemo commented 1 year ago

Same problem here. Everything worked fine before updating. Disabling most extentions did seem to fix it though. So maybe its not a WebUI problem and more of a compatibility issue.

Harvester62 commented 1 year ago

Hmmm, now things seem to get even worst. I re-activated all the Extensions and restarted Gradio, but soon after restart Gradio is hanging when the Web UI is loaded and the models list refreshed. Then the webserver restarts but the UI in unresponsive. These are the related error messages in the console (also some extensions won't load properly, probably because of these problems): Traceback (most recent call last): File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 321, in run_predict output = await app.blocks.process_api( File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1016, in process_api data = self.postprocess_data(fn_index, result["prediction"], state) File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 962, in postprocess_data prediction_value = block.postprocess(prediction_value) File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 581, in postprocess return self._round_to_precision(y, self.precision) File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 530, in _round_to_precision return float(num) ValueError: could not convert string to float: 'grad_min' Traceback (most recent call last): File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 321, in run_predict output = await app.blocks.process_api( File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1016, in process_api data = self.postprocess_data(fn_index, result["prediction"], state) File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 962, in postprocess_data prediction_value = block.postprocess(prediction_value) File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 581, in postprocess return self._round_to_precision(y, self.precision) File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 530, in _round_to_precision return float(num) ValueError: could not convert string to float: 'clip' Traceback (most recent call last): File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 321, in run_predict output = await app.blocks.process_api( File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1016, in process_api data = self.postprocess_data(fn_index, result["prediction"], state) File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 962, in postprocess_data prediction_value = block.postprocess(prediction_value) File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 581, in postprocess return self._round_to_precision(y, self.precision) File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 530, in _round_to_precision return float(num) ValueError: could not convert string to float: 'mp4' Error completing request Arguments: () {} Traceback (most recent call last): File "C:\stable-diffusion-webui\modules\call_queue.py", line 45, in f res = list(func(*args, **kwargs)) TypeError: install_extension_from_url() missing 2 required positional arguments: 'dirname' and 'url'

Traceback (most recent call last): File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 321, in run_predict output = await app.blocks.process_api( File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1015, in process_api result = await self.call_function(fn_index, inputs, iterator, request) File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 856, in call_function prediction = await anyio.to_thread.run_sync( File "C:\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "C:\stable-diffusion-webui\venv\lib\site-packages\anyio_backends_asyncio.py", line 937, in run_sync_in_worker_thread return await future File "C:\stable-diffusion-webui\venv\lib\site-packages\anyio_backends_asyncio.py", line 867, in run result = context.run(func, *args) TypeError: create_ui..() missing 1 required positional argument: 'value' Traceback (most recent call last): File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 321, in run_predict output = await app.blocks.process_api( File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1016, in process_api data = self.postprocess_data(fn_index, result["prediction"], state) File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 956, in postprocess_data prediction_value = postprocess_update_dict( File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 421, in postprocess_update_dict update_dict = block.get_specific_update(update_dict) File "C:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 256, in get_specific_update generic_update = cls.update(**generic_update) TypeError: Textbox.update() got an unexpected keyword argument 'choices'

Hopefully, these problems will be soon resolved. We must be patient.

rektobot commented 1 year ago

same exact issue with dynamic prompts due to gradio issue and i suspect some tensor or pytorch tomfoolery. got img2img to finally work but it shits the bed on most samplers so i just gave up. did a clean install prior to all the gradio issues and still nothing, same errors with flood of txt in the cell. on top of that the new karras scheduling apparently killed all my seeds i was working on the last two weeks and everything looks entirely different from when i went to bed the other night. i dont even know where to begin to get that work back because everything was done on SDE and the other M karras samplers aside from a few runs on DDIM, but if the seeds are rekt theyre rekt. fug. i know this shit is all WIP and not ready for prime time etc, but damn, losing all that work is a nut punch.

andreamoreto commented 1 year ago

Same issue here, the tensor related, commit 251ecee6 . I disabled all extension and the problem disappeared. So, after some selective extensions enabling, it seems that dreambooth was the source of the problem. Now dreambooth is disabled, all other extensions enabled, and it's working.

Harvester62 commented 1 year ago

I know that these kind of problems might be a little frustrating, but that's the nature of the development process, we've to be patient. One thing that can be done is to revert the latest updates to a previous version of the repository using Git, but I would prefer to wait for @AUTOMATIC1111 to look into this issue and find a solution, so to keep the program up to date. Hopefully it will be fixed soon and we can continue to enjoy using SD Web UI.

Nicoolodion commented 1 year ago

it seems that dreambooth was the source of the problem. Now dreambooth is disabled, all other extensions enabled, and it's working. Disabled it now too and it works again! Looks like a dreambooth bug

Nicoolodion commented 1 year ago

Noticed now that even with dreambooth disabled that many other extensions often put out the same warning...

MrMondragon commented 1 year ago

Same here. Disabled both dreambooth and dynamic prompts and still no go.

While loading, I get RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback): module 'tensorflow' has no attribute 'data'

And while trying to generate I get the on OP mentioned: 'tensorflow' has no attribute 'data'

rektobot commented 1 year ago

yeah i disabled everything, another clean install without migrating settings files (csv, json, webui.sh, etc) but still get the same tensors issues spit out when i try to generate. just from my limited experience, since like freakin august lol, but gradio comes off comped af and this seems relevant maybe:

https://github.com/huggingface/safetensors

also how exactly can i revert back to an earlier version through git, never done it before? i edited some of the requirements.txt to push gradio back to 3.9 then 3.13

dgrimes112 commented 1 year ago

im getting the same issue as well, even the interrogate in img2img doesnt work

Nicoolodion commented 1 year ago

Just used git pull again and now it works again! Looks like the new "update" fixed it. I have to test it out with dreambooth enabled next!

RocketMobster commented 1 year ago

I have my bat file set to do a git pull every time I load the UI but I am still getting the same error. Tried with and without extensions enabled to no avail. I cannot generate images at all. I could yesterday afternoon.

Harvester62 commented 1 year ago

This is frustrating. I was able to get the SD Web UI working again and re-activated almost all the Extestions, apart from a few that are giving me hard times, with the backend restarting in a loop, or hanging up. The initial source of the problem was Dreambooth and the arguments that were inside the webui-user.bat. Other Extension with problems are Config-Preset, Scripts-Random, Dreambooth, Prompt Gallery, Hypernetwork Monkey Patch, Dynamic Prompts (possibly fixed, I have to check it) but these might be corrected by their respective developers in the next days. Anyway, I just did a git pull et voilà! Gradio is no longer working and the Web UI is hanging again. I shall take a break and wait a few days until this storm has passed.

dgrimes112 commented 1 year ago

Just used git pull again and now it works again! Looks like the new "update" fixed it. I have to test it out with dreambooth enabled next!

just git pulled today and its still not working :(

Nicoolodion commented 1 year ago

just git pulled today and its still not working :(

Ok thats weird... Dreambooth is also working for me now.

MrMondragon commented 1 year ago

Decided to test the extensions I use individually, in order to compile a small list of what is working and what is not. This list is by no means complete or comprehensive. Fell free to add to the (small) pile.

Some extensions which won't stop web-ui from generating images:

Harvester62 commented 1 year ago

Interesting, thank you @MrMondragon

slavoisard commented 1 year ago

Very strange, I have two installations, one for 1.5 and one for 2.1. The 1.5 is broken, but not the 2.1. Both have updated... And can't understand the difference (excepted models used of course)....

MrMondragon commented 1 year ago

Decided to give it a go and try to generate something with dreambooth on and V2.1 models. Still the same error reported above

MrMondragon commented 1 year ago

Hi again. Went on to check the dreambooth github issue for the same problem and found a solution that got me back up and running: Delete de VEnv folder and restart SD, so that it forces a re-install of everything. dephtmap2mask is running again and I can generate images with dreambooth on. Dynamic Prompts is still a dealbreaker, though

dgrimes112 commented 1 year ago

Hi again. Went on to check the dreambooth github issue for the same problem and found a solution that got me back up and running: Delete de VEnv folder and restart SD, so that it forces a re-install of everything. dephtmap2mask is running again and I can generate images with dreambooth on. Dynamic Prompts is still a dealbreaker, though

ive been using dynamic prompting as a script instead of an extension bc im too lazy to swap over. Would that cause a problem? or only the extension?

dgrimes112 commented 1 year ago

happy to report deleting the venv worked for me thank you!!!

Mrroot3r commented 1 year ago

Confirming that deleting venv worked for me as well. Thanks!

Harvester62 commented 1 year ago

So, these issues are possibly due to some (which ones?) outdated or corrupted dependency libraries? I would like to know which are these libraries and perhaps uninstall and re-install them instead of wiping out the entire venv. I tend to optimize things due to my low bandwidth Internet connection. The same principle I follow when I symlink a checkpoint instead of re-downloading or copying it into another AI application (I have several of them installed and working on my notebook).

Obviously, without knowing what's wrong exactly, rebuilding the venv is the last resource and step to do. Thank you for reposrting that this solution fixed this issue.

MrMondragon commented 1 year ago

@Harvester62, if I were to guess, I'd say Torch and TorchVision booth good candidates.

Harvester62 commented 1 year ago

Thank you @MrMondragon , but at the end I decided that a clean re-installation of the venv would have been a good idea, considering the latest big changes, and it worked very well. Now it's time to re-activate all extensions and keep on the translation work and clean-up of the it_IT.json localization file. In case of any other strange things happening, I will report them here.

Relatively to this bug report, I would like to know if anybody else had "fixed" the problem with a complete reinstall of the venv, or with the uninstall/re-install of the two above mentioned libraries (Torch and TorchVision), it they were the source of the problem. Let me know, thank you.

MrMondragon commented 1 year ago

Hi again. Went on to check the dreambooth github issue for the same problem and found a solution that got me back up and running: Delete de VEnv folder and restart SD, so that it forces a re-install of everything. dephtmap2mask is running again and I can generate images with dreambooth on. Dynamic Prompts is still a dealbreaker, though

ive been using dynamic prompting as a script instead of an extension bc im too lazy to swap over. Would that cause a problem? or only the extension?

Didn't know it was still possible to use it without the extension. Guess not... But then again, it would be awesome if you could test and report. I, for one, would rollback to script only as well

Nicoolodion commented 1 year ago

Relatively to this bug report, I would like to know if anybody else had "fixed" the problem with a complete reinstall of the venv, or with the uninstall/re-install of the two above mentioned libraries (Torch and TorchVision), it they were the source of the problem. Let me know, thank you.

For me I didn't even have to reinstall anything at all... I just had to do a git pull and everything was fine again. Even with all the extensions enabled

Harvester62 commented 1 year ago

Thank you @Nicoolodion for the feedback and glad to know that you got your SD Web UI working again. Unfortunately, a git pull doesn't fix any dependency library in the venv, only align your local installation with the online SD Web UI repository, which doesn't include any dependency library. Possibly my venv needed a fresh installation (it was months old).

Nicoolodion commented 1 year ago

@Harvester62 Somehow my SD was working yesterday after the git pull, but today when I wanted to use it again (i changed nothing) it the error was back... reinstalled venv and that worked!

Froztwolf commented 1 year ago

Had the same issue, and resolved it by re-cloning git to a new folder.

Javitax47 commented 1 year ago

I have been dealing with this isue for a week but for me worked downgrading tensorflow from 2.11 to 2.10

Harvester62 commented 1 year ago

I found that there might be two things that can help sometimes to resolve these issues: one is to rebuild the venv from scratch, which in my case fixed several issues, and the other, perhaps to be done before rebuilding venv, is to delete the config.json file. If the source of the problem is an Extension, than removing it (moving away from the \extensions folder) might bring back SDWUI to a working state. The last time I had such problems I moved away all the scripts and extensions and, given that the SDWUI was working, I brought back them one at a time checking in the console and restarting the program every time. Time consuming for sure, but I didn't have other options.

Cyberbeing commented 1 year ago

I have been dealing with this isue for a week but for me worked downgrading tensorflow from 2.11 to 2.10

It's worth mentioning that TensorFlow dropped support for native Windows GPU after tensorflow-gpu 2.10.1. They now expect Windows GPU users to run Tensorflow 2.11+ via WSL: https://www.tensorflow.org/install/pip#system_requirements

It's also worth mentioning that the WebUI without any additional extensions does not require Tensorflow to run.

In fact, on my system uninstalling Tensorflow & Keras makes my SD inference speeds 6-10% Faster, so it seems more harmful than good unless you have something installed which actually requires it to run without any fallback.

ef1500 commented 1 year ago

Don't know how it happened but I had a similar issue after upgrading from an extremely old version. Worked the first day then the next it didn't. Disabling dynamic prompts and dreambooth, then recreating the venv (delete the folder, run webui-user.bat) worked for me.

Doris1337 commented 1 year ago

hi, had same issue, no f***** idea what I do , I did deleted the Venv folder. But for those who don't want delete or want to try another approach you can try this : C:\root folder\stable-diffusion-webui\venv\Scripts\python.exe -m pip install --upgrade pip Hope it fix something

ewebgh33 commented 1 year ago

This happened to me today, I think it was working yesterday, and I just installed "unprompted" and it's borked. Removed unprompted, but no go. Going to try reinstall of VENV.

Harvester62 commented 1 year ago

hi, had same issue, no f***** idea what I do , I did deleted the Venv folder. But for those who don't want delete or want to try another approach you can try this : C:\root folder\stable-diffusion-webui\venv\Scripts\python.exe -m pip install --upgrade pip Hope it fix something

Hi @Doris1337 , the command you referenced should only update the pip program, which is not a dependency but only the program to manage dependencies. You can still use an outdated pip version, in fact the messages related in the console are only warnings. Did the update of pip solved your issues?

Hi @EmmaWebGH , did the reinstallation of venv went fine and brought back SD Web UI to work? I have now definitely excluded "Unprompted" from the installed extensions on my local installation, as well as a few others (ABG_extension, DiffusionDefender, sd_auto_fix) which is a pity but I cannot risk to break my SDWUI.

Just for your information, guys and gals. As of today, and after the above mentioned venv restore, the current version of SDWUI (Commit hash: 0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8) seems to be stable and working with all my installed Extensions and Scripts, which doesn't trigger any error messages at startup in the console; it doesn't mean that all the Scripts and Extension are not possibly affected by some problems - I don't run them all, I only translate their UI - simply they don't prevent SDWUI to work. The only "fix" I had to apply recently to SDWUI to restore the capability to check for updates of the installed Extenstions is the one referenced here: https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/8118

If you want to know which Scripts and Extensions do I have installed, here follow a couple of screenshots:

immagine

immagine

and this is my SDWUI console after startup:

immagine

If you are interested to see what version of an Extension vs. SDWUI version is working, you can have a look at this link: https://github.com/ClashSAN/sd-webui-extension-records

I hope you might find these information useful in some way. Cheers!

ewebgh33 commented 1 year ago

@Harvester62 Yes reinstalling the venv was completely painless. Everything immediately worked. The downside is that it's now using xformers 0.016 or 0.017 (I forget) which means I need to git pull back to a certain hash if I want to try training again, as current xformers breaks training I think. But then there are youtube videos on what version to revert to, to do that. I think I will use 2 installls anyway, a dreambooth capable version with xformers 0.014 and a current one for image making.

Harvester62 commented 1 year ago

Thank you @EmmaWebGH for your feedback. Glad to hear that everything get back to a working state. Having two installations is probably the best option until those issues will be fixed.

Doris1337 commented 1 year ago

hi, had same issue, no f***** idea what I do , I did deleted the Venv folder. But for those who don't want delete or want to try another approach you can try this : C:\root folder\stable-diffusion-webui\venv\Scripts\python.exe -m pip install --upgrade pip Hope it fix something

Hi @Doris1337 , the command you referenced should only update the pip program, which is not a dependency but only the program to manage dependencies. You can still use an outdated pip version, in fact the messages related in the console are only warnings. Did the update of pip solved your issues?

Hi @EmmaWebGH , did the reinstallation of venv went fine and brought back SD Web UI to work? I have now definitely excluded "Unprompted" from the installed extensions on my local installation, as well as a few others (ABG_extension, DiffusionDefender, sd_auto_fix) which is a pity but I cannot risk to break my SDWUI.

Just for your information, guys and gals. As of today, and after the above mentioned venv restore, the current version of SDWUI (Commit hash: 0cc0ee1) seems to be stable and working with all my installed Extensions and Scripts, which doesn't trigger any error messages at startup in the console; it doesn't mean that all the Scripts and Extension are not possibly affected by some problems - I don't run them all, I only translate their UI - simply they don't prevent SDWUI to work. The only "fix" I had to apply recently to SDWUI to restore the capability to check for updates of the installed Extenstions is the one referenced here: #8118

If you want to know which Scripts and Extensions do I have installed, here follow a couple of screenshots:

immagine

immagine

and this is my SDWUI console after startup:

immagine

If you are interested to see what version of an Extension vs. SDWUI version is working, you can have a look at this link: https://github.com/ClashSAN/sd-webui-extension-records

I hope you might find these information useful in some way. Cheers!

Eventually I ended up reinstalling back Automatic111, I tried with Chatgpt to understand the problem... but easiest solution is reinstalling, I commented that because I thought it might help somebody. Just sharing my brainstorm, hehehe

Harvester62 commented 1 year ago

Thank you.

Harvester62 commented 1 year ago

After several weeks no longer experiencing this problem, especially after I reinstalled the venv, and noticing that even other users fixed it with a venv re-installation, I am therefore closing this bug report. If someone will be facing that same problem he/she should be able to retrieve this bug report and related comments doing a research within the bug reports. Thank you all for attending this discussion. Cheers!

zzzgithub commented 6 months ago

re installed venv.But does not work. EinopsError: Error while processing rearrange-reduction pattern "(b f) d c -> (b d) f c". Input tensor shape: torch.Size([38, 7381, 320]). Additional info: {'f': 16}. Shape mismatch, can't divide axis of length 38 in chunks of 16