AUTOMATIC1111 / stable-diffusion-webui

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

[Bug]: error #5168

Closed bugdead closed 1 year ago

bugdead commented 1 year ago

Is there an existing issue for this?

What happened?

venv "D:\AIhuihua\buquan\stable-diffusion-webui\venv\Scripts\Python.exe" Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] Commit hash: 0b5dcb3d7ce397ad38312dbfc70febe7bb42dcc3 Fetching updates for Stable Diffusion... Checking out commit for Stable Diffusion with hash: 47b6b607fdd31875c9279cd2f4f16b92e4ea958e... Traceback (most recent call last): File "D:\AIhuihua\buquan\stable-diffusion-webui\launch.py", line 293, in prepare_enviroment() File "D:\AIhuihua\buquan\stable-diffusion-webui\launch.py", line 236, in prepare_enviroment git_clone(stable_diffusion_repo, repo_dir('stable-diffusion-stability-ai'), "Stable Diffusion", stable_diffusion_commit_hash) File "D:\AIhuihua\buquan\stable-diffusion-webui\launch.py", line 97, in git_clone run(f'"{git}" -C {dir} checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}") File "D:\AIhuihua\buquan\stable-diffusion-webui\launch.py", line 49, in run raise RuntimeError(message) RuntimeError: Couldn't checkout commit 47b6b607fdd31875c9279cd2f4f16b92e4ea958e for Stable Diffusion. Command: "git" -C repositories\stable-diffusion-stability-ai checkout 47b6b607fdd31875c9279cd2f4f16b92e4ea958e Error code: 128 stdout: stderr: fatal: reference is not a tree: 47b6b607fdd31875c9279cd2f4f16b92e4ea958e

Steps to reproduce the problem

1.Run webui-user.bat 2.See error in terminal

What should have happened?

Server should boot up

Commit where the problem happens

0b5dcb3d7ce397ad38312dbfc70febe7bb42dcc3

What platforms do you use to access UI ?

Windows

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

set COMMANDLINE_ARGS=--api --port 7860 --cors-allow-origins=https://www.painthua.com

Additional information, context and logs

No response

Gerschel commented 1 year ago

in your cmd, try going to this folder D:\AIhuihua\buquan\stable-diffusion-webui\repositories\stable-diffusion-stability-ai

Next, checkout main branch git checkout main

Update repo git pull

Check the log git log --oneline

See if the hash 47b6b607fdd31875c9279cd2f4f16b92e4ea958e is at the top, and if it is,

git checkout 47b6b607fdd31875c9279cd2f4f16b92e4ea958e

Now exit and running like normal.

CryptoSoltan commented 1 year ago

in your cmd, try going to this folder D:\AIhuihua\buquan\stable-diffusion-webui\repositories\stable-diffusion-stability-ai

Next, checkout main branch git checkout main

Update repo git pull

Check the log git log --oneline

See if the hash 47b6b607fdd31875c9279cd2f4f16b92e4ea958e is at the top, and if it is,

git checkout 47b6b607fdd31875c9279cd2f4f16b92e4ea958e

Now exit and running like normal.

thanks for the resolution but it didn't work for me I've recently tried to update the folder with git pull but it says to merge or stash ... I've done that and then I got this error:

error: Your local changes to the following files would be overwritten by merge: webui.py Please commit your changes or stash them before you merge. Aborting Updating ce049c4..8fba733 venv "C:\AI\stable-diffusion-webui\stable-diffusion-webui\venv\Scripts\Python.exe" Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] Commit hash: ce049c471b4a1d22f5a8fe8f527788edcf934eda Fetching updates for Stable Diffusion... Checking out commit for Stable Diffusion with hash: 47b6b607fdd31875c9279cd2f4f16b92e4ea958e... Traceback (most recent call last): File "C:\AI\stable-diffusion-webui\stable-diffusion-webui\launch.py", line 293, in prepare_enviroment() File "C:\AI\stable-diffusion-webui\stable-diffusion-webui\launch.py", line 236, in prepare_enviroment git_clone(stable_diffusion_repo, repo_dir('stable-diffusion-stability-ai'), "Stable Diffusion", stable_diffusion_commit_hash) File "C:\AI\stable-diffusion-webui\stable-diffusion-webui\launch.py", line 97, in git_clone run(f'"{git}" -C {dir} checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}") File "C:\AI\stable-diffusion-webui\stable-diffusion-webui\launch.py", line 49, in run raise RuntimeError(message) RuntimeError: Couldn't checkout commit 47b6b607fdd31875c9279cd2f4f16b92e4ea958e for Stable Diffusion. Command: "git" -C repositories\stable-diffusion-stability-ai checkout 47b6b607fdd31875c9279cd2f4f16b92e4ea958e Error code: 128 stdout: stderr: fatal: reference is not a tree: 47b6b607fdd31875c9279cd2f4f16b92e4ea958e

Press any key to continue . . .

please elaborate how to fix this

CryptoSoltan commented 1 year ago

I've have tried git log --oneline and this is the result

C:\AI\stable-diffusion-webui\stable-diffusion-webui>git checkout main
error: pathspec 'main' did not match any file(s) known to git

C:\AI\stable-diffusion-webui\stable-diffusion-webui>git log --oneline
3339a35 (HEAD -> master) removed merge conflicts
8fba733 (origin/master, origin/HEAD) Merge pull request #5286 from brkirch/launch-py-mac
60bd4d5 fix incorrect file extension filter for deepdanbooru models
4b0dc20 use modelloader for #4956
2a64915 Merge pull request #4956 from TiagoSantos81/offline_BLIP
0d21624 move #5216 to the extension
89e1df0 Merge remote-tracking branch 'wywywywy/autoencoder-hijack'
b6e5edd add built-in extension system add support for adding upscalers in extensions move LDSR, ScuNET and SwinIR to built-in extensions
46b0d23 add comment for #4407 and remove seemingly unnecessary cudnn.enabled
2651267 fix #4407 breaking UI entirely for card other than ones related to the PR
5ec8981 Revert most launch.py changes, add mac user script
ce049c4 Merge pull request #4368 from byzod/master
681c000 Merge pull request #4407 from yoinked-h/patch-1
37fc1fa Merge pull request #5229 from lolsuffocate/master
d2e5b4e Merge pull request #5251 from adieyal/bug/negative-prompt-infotext
5267414 Merge pull request #4271 from MarkovInequality/racecond_fix
c9a2cfd Merge branch 'master' into racecond_fix
5cd5a67 Merge pull request #4459 from kavorite/color-sketch-inpainting
a2feaa9 Merge pull request #5194 from brkirch/autocast-and-mps-randn-fixes
c7af672 more simple config option name plus mouseover hint for clip skip
c67d8bc Merge pull request #5304 from space-nuko/fix/clip-skip-application
28c79b8 Merge pull request #5328 from jcowens/fix-typo
eb0b8f9 Merge pull request #5331 from smirkingface/openaimodel_fix
bab6ea6 Merge pull request #5340 from PhytoEpidemic/master
b2f17dd prevent include_init_images from being passed to StableDiffusionProcessingImg2Img in API #4989
ae81b37 Merge pull request #5165 from klimaleksus/fix-sequential-vae
c377777 Merge pull request #5327 from smirkingface/master
119a945 Fix divide by 0 error
Gerschel commented 1 year ago

So. In your repository stable-diffusion-webui, there are other repositories.

Your first issue is in the folder repositories\stable-diffusion-stability-ai

This is where you would run the git commands to fix that repository. The error shows the command where it failed, and the command shows the folder.

RuntimeError: Couldn't checkout commit 47b6b607fdd31875c9279cd2f4f16b92e4ea958e for Stable Diffusion.
Command: "git" -C repositories\stable-diffusion-stability-ai checkout 47b6b607fdd31875c9279cd2f4f16b92e4ea958e
Error code: 128

Navigate to that folder.
cd C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai

git fetch --all

That grabs information from all the branches from the remote (aka origin). Then you can try your pull git pull

In the repo for stable-diffusion-stability-ai, they call their branch main

In your stable-diffusion-webui repo, they call their branch master

If at anytime you want to see the names of the branches, you can list them with git branch --list

If after you pull, and there are conflicts, and you don't have changes you are trying to keep, you can force the files to be overwritten from the remote. It'll only overwrite those files that are the same, extra files you have, such as custom scripts, wont be touched. It's like doing a pull.

git reset origin/master or git reset origin/main
origin = remote put the name of the branch you want to reset after origin If you don't specify origin, it does it from it local history.

There were two times I had to do a reset, one of the times the reset didn't resolve the issue, so I had to do a hard reset from remote.

git reset --hard origin/master

With reset, you are rewriting history, so read the status of the situation using git log, and git status, before making those moves.

CryptoSoltan commented 1 year ago

Thank you so much for the response, I really appreciate it🤍 I've tried this all and it still shows me the same hash error and in the stable-diffusion-stability-ai I've tried to check the branch and it showed me its master instead of main im really confused can it be because of using a VPN?

venv "C:\AI\stable-diffusion-webui\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 44c46f0ed395967cd3830dd481a2db759fda5b3b
Fetching updates for Stable Diffusion...
Checking out commit for Stable Diffusion with hash: 47b6b607fdd31875c9279cd2f4f16b92e4ea958e...
Traceback (most recent call last):
  File "C:\AI\stable-diffusion-webui\stable-diffusion-webui\launch.py", line 294, in <module>
    prepare_enviroment()
  File "C:\AI\stable-diffusion-webui\stable-diffusion-webui\launch.py", line 237, in prepare_enviroment
    git_clone(stable_diffusion_repo, repo_dir('stable-diffusion-stability-ai'), "Stable Diffusion", stable_diffusion_commit_hash)
  File "C:\AI\stable-diffusion-webui\stable-diffusion-webui\launch.py", line 97, in git_clone
    run(f'"{git}" -C {dir} checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}")
  File "C:\AI\stable-diffusion-webui\stable-diffusion-webui\launch.py", line 49, in run
    raise RuntimeError(message)
RuntimeError: Couldn't checkout commit 47b6b607fdd31875c9279cd2f4f16b92e4ea958e for Stable Diffusion.
Command: "git" -C repositories\stable-diffusion-stability-ai checkout 47b6b607fdd31875c9279cd2f4f16b92e4ea958e
Error code: 128
stdout: <empty>
stderr: fatal: reference is not a tree: 47b6b607fdd31875c9279cd2f4f16b92e4ea958e

Press any key to continue . . .
Gerschel commented 1 year ago

You are not doing it in the correct folder. Just run this, you can copy and paste it.

cd C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai &&
git checkout main &&
git fetch --all &&
git pull &&
git checkout 47b6b607fdd31875c9279cd2f4f16b92e4ea958e
CryptoSoltan commented 1 year ago
I've opened the CMD from the start as an administrator 
On the second line command `git checkout main` it showed me this error:

Microsoft Windows [Version 10.0.19044.2251]
(c) Microsoft Corporation. All rights reserved.

C:\Windows\system32>cd C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai

C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai>git checkout main
error: pathspec 'main' did not match any file(s) known to git

C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai>
Gerschel commented 1 year ago

You don't need administrator privileges to run these.

What do you get if you run git branch --list in that directory.

CryptoSoltan commented 1 year ago

Microsoft Windows [Version 10.0.19044.2251]
(c) Microsoft Corporation. All rights reserved.

C:\Users\DFMRendring>cd C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai

C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai>git branch --list
* master

C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai>
Gerschel commented 1 year ago

That's interesting. On mine it shows as main. Alright. Same commands, but with master instead of main

cd C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai &&
git checkout master &&
git fetch --all &&
git pull &&
git checkout 47b6b607fdd31875c9279cd2f4f16b92e4ea958e
CryptoSoltan commented 1 year ago

yea I think I should delete it and start from scratch on the last line:

Microsoft Windows [Version 10.0.19044.2251]
(c) Microsoft Corporation. All rights reserved.

C:\Users\DFMRendring>cd C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai

C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai>git checkout master
Already on 'master'
Your branch is up to date with 'origin/master'.

C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai>git fetch --all

C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai>git pull
Already up to date.

C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai>git checkout 47b6b607fdd31875c9279cd2f4f16b92e4ea958e
fatal: reference is not a tree: 47b6b607fdd31875c9279cd2f4f16b92e4ea958e

C:\AI\stable-diffusion-webui\stable-diffusion-webui\repositories\stable-diffusion-stability-ai>
CryptoSoltan commented 1 year ago

I don't know why mine got this bad and corrupted lol.

RubenFlorissen commented 1 year ago

I had this problem as well. I simply deleted the affected folder (/repositories/stable-diffusion-stability-ai) and launched the WebUI. This time git was able to pull the correct files from the repo.

CryptoSoltan commented 1 year ago

I had this problem as well. I simply deleted the affected folder (/repositories/stable-diffusion-stability-ai) and launched the WebUI. This time git was able to pull the correct files from the repo. Thank you it solved the problem and thank you @Gerschel too

soupie-62 commented 1 year ago

I had this same problem, shortly after I bough a new PC.

When moving data from the old PC, I Suspect the security permissions for the parent folder had a part to play.
So, under Security -> Advanced, I took ownership, disabled inheriting security, etc. After that, I deleted all sub-folders under repositories.

My system has finished with stable-diffusion-stability-ai, and is cloning "Taming Transformers" as I write this.
Before, it was an empty folder.

BillRaymond commented 1 year ago

Whenever I receive an error in Stable Diffusion UI (SDUI) like this: RuntimeError: Couldn't checkout commit [a bunch of numbers and text] for [CodeFormer, BLIP, K-Diffusion, etc], it seems SDUI is pulling repos in other repos. Those repos have commit numbers (or unique identifiers) that do not match in SDUI's launch.py.

For example, when I run webui.sh (I guess Windows users have a batch file?), it will run launch.py and give you the error message. Check for the repo it is referring to. Here is an example of one I received yesterday:

RuntimeError: Couldn't checkout commit c5b4593074ba6214284d6acd5f1719b6c5d739af for CodeFormer.

Here are the steps I took to resolve the problem:

  1. Go to the stable-diffusion-webui/repositories folder and delete the folder causing the problem. In my case, I delete the CodeFormer folder. The reason I delete this folder is because SDUI will always attempt to re-download the repo so if there was a problem, it will be resolved when you run the next step
  2. Re-run the webui.sh file. Either (a) it runs and you are done or (b) You the same (or a similar) message, but this time stable-diffusion-webui/repositories/CodeFormer is likely back. Check to make sure that is the case and move to the next step
  3. Now that SDUI downloaded the new CodeFormer repo, using shell (with Git installed of course), type:
    
    # In this case, I am using the CodeFormer example, but it could be for any other folder contained within Repositories
    cd stable-diffusion-webui/repositories/CodeFormer
    git rev-parse HEAD

The result will look something like this:

4724c90b6b9d5183da383f2bdae6ddf9b0bf045d


4. Copy the resulting unique identifier
5. Open the file `stability-diffusion-ui/launch.py`, and locate the COMMIT_HAS line. In my CodeFormer example, it looks like this:

stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf")


6. Remove the old commit hash and paste in your new one. In my case, it will look like the following line because that is what I copied/pasted from the `git rev-parse HEAD` command:

stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "4724c90b6b9d5183da383f2bdae6ddf9b0bf045d")



Re-run `webui.sh`

Note: This can happen multiple times, so if you get an error, make sure it is not for the same Repository. At first I thought I made a mistake, but it turns out I had to modify a bunch of these to get them right.
maundytime commented 1 year ago

Check where the error commit is, /modules/launch_utils.py or /launch.py, and try

sed -i -e 's/checkout {commithash}/checkout --force {commithash}/g' /yourpath/stable-diffusion-webui/modules/launch_utils.py

or

sed -i -e 's/checkout {commithash}/checkout --force {commithash}/g' /yourpath/stable-diffusion-webui/launch.py
GpointChen commented 1 year ago

During a fresh installation on Colab, I encountered the following errors when attempting to run the command !python launch.py --share --xformers --enable-insecure-extension-access --theme light:

/content/drive/MyDrive/sd-webui-files/stable-diffusion-webui
Python 3.10.12 (main, Jun  7 2023, 12:45:35) [GCC 9.4.0]
Version: v1.3.2
Commit hash: baf6946e06249c5af9851c60171692c44ef633e0
Cloning CodeFormer into /content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/repositories/CodeFormer...
Traceback (most recent call last):
  File "/content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/launch.py", line 38, in <module>
    main()
  File "/content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/launch.py", line 29, in main
    prepare_environment()
  File "/content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/modules/launch_utils.py", line 291, in prepare_environment
    git_clone(codeformer_repo, repo_dir('CodeFormer'), "CodeFormer", codeformer_commit_hash)
  File "/content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/modules/launch_utils.py", line 150, in git_clone
    run(f'"{git}" -C "{dir}" checkout {commithash}', None, "Couldn't checkout {name}'s hash: {commithash}")
  File "/content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/modules/launch_utils.py", line 101, in run
    raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't checkout {name}'s hash: {commithash}.
Command: "git" -C "/content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/repositories/CodeFormer" checkout c5b4593074ba6214284d6acd5f1719b6c5d739af
Error code: 1
stderr: error: Your local changes to the following files would be overwritten by checkout:
    basicsr/data/ffhq_blind_dataset.py
    basicsr/data/ffhq_blind_joint_dataset.py
    basicsr/data/gaussian_kernels.py
    options/CodeFormer_colorization.yml
    options/CodeFormer_inpainting.yml
    options/CodeFormer_stage2.yml
    options/CodeFormer_stage3.yml
    options/VQGAN_512_ds32_nearest_stage1.yml
    scripts/crop_align_face.py
Please commit your changes or stash them before you switch branches.
Aborting

Despite attempting to reinstall and remove the CodeFormer package, the issues persisted.

Fortunately, I had previously installed different versions of Stable Diffusion webui on two other machines, on April 9th and April 12th respectively, and encountered no issues. As a result, I decided to replace the latest version of CodeFormer with the older version (c5b4593074ba6214284d6acd5f1719b6c5d739af) that had worked reliably in those cases. This solution resolved the problems I was facing.

romilandc commented 10 months ago

in your cmd, try going to this folder D:\AIhuihua\buquan\stable-diffusion-webui\repositories\stable-diffusion-stability-ai

Next, checkout main branch git checkout main

Update repo git pull

Check the log git log --oneline

See if the hash 47b6b607fdd31875c9279cd2f4f16b92e4ea958e is at the top, and if it is,

git checkout 47b6b607fdd31875c9279cd2f4f16b92e4ea958e

Now exit and running like normal.

This fixed it for me. When initially building run.bat from new install, I had the 'checkout repositories\stable-diffusion-stability-ai' error. Going to this path via cmd and checking out the main for '~\stable-diffusion-webui\repositories\stable-diffusion-stability-ai' fixed the run.bat.

I then however also had a checkout error with '~\stable-diffusion-webui\repositories\k-diffusion' checkout. Using 'git checkout master' works in this case, NOT main. Re-run the run.bat after this and should finish the install successfully. If there are any other checkout errors, try similar method.