Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"RuntimeError: Couldn't determine Stable Diffusion's hash" when installing #1888

Open
HeavenlyChorus opened this issue Oct 7, 2022 · 35 comments
Labels
asking-for-help-with-local-system-issues This issue is asking for help related to local system; please offer assistance

Comments

@HeavenlyChorus
Copy link

Getting stuck at this when trying to setup everything with webui-user.bat.
Any idea what's potentially causing it?

Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: <none>
Traceback (most recent call last):
  File "D:\GitHub Desktop Files\stable-diffusion-webui\launch.py", line 130, in <module>
    git_clone("https://github.com/CompVis/stable-diffusion.git", repo_dir('stable-diffusion'), "Stable Diffusion", stable_diffusion_commit_hash)
  File "D:\GitHub Desktop Files\stable-diffusion-webui\launch.py", line 93, in git_clone
    current_hash = run(f'"{git}" -C {dir} rev-parse HEAD', None, f"Couldn't determine {name}'s hash: {commithash}").strip()
  File "D:\GitHub Desktop Files\stable-diffusion-webui\launch.py", line 55, in run
    raise RuntimeError(message)
RuntimeError: Couldn't determine Stable Diffusion's hash: 69ae4b35e0a0f6ee1af8bb9a5d0016ccb27e36dc.
Command: "git" -C repositories\stable-diffusion rev-parse HEAD
Error code: 1
stdout: 69ae4b35e0a0f6ee1af8bb9a5d0016ccb27e36dc

stderr: ϵͳҲָ·
@HeavenlyChorus HeavenlyChorus added the bug-report Report of a bug, yet to be confirmed label Oct 7, 2022
@theunit187
Copy link

theunit187 commented Oct 7, 2022

I have a similar issue. Everything worked fine yesterday. I've tried a clean install of the repo, but it didn't help.

venv "C:\Files\StableDiffusion\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: <none>
Traceback (most recent call last):
  File "C:\Files\StableDiffusion\stable-diffusion-webui\launch.py", line 129, in <module>
    git_clone("https://github.com/CompVis/stable-diffusion.git", repo_dir('stable-diffusion'), "Stable Diffusion", stable_diffusion_commit_hash)
  File "C:\Files\StableDiffusion\stable-diffusion-webui\launch.py", line 92, in git_clone
    current_hash = run(f'"{git}" -C {dir} rev-parse HEAD', None, f"Couldn't determine {name}'s hash: {commithash}").strip()
  File "C:\Files\StableDiffusion\stable-diffusion-webui\launch.py", line 54, in run
    raise RuntimeError(message)
RuntimeError: Couldn't determine Stable Diffusion's hash: 69ae4b35e0a0f6ee1af8bb9a5d0016ccb27e36dc.
Command: ";C:\Program Files\Git\bin\git.exe;C:\Program Files\Git\cmd" -C repositories\stable-diffusion rev-parse HEAD
Error code: 1
stdout: <empty>
stderr: ⠪᪠ 訡   䠩,    ⪥ ⮬.

@ClashSAN
Copy link
Collaborator

ClashSAN commented Oct 7, 2022

I installed from scratch just now, couldn't reproduce. Do custom models work?

@HeavenlyChorus
Copy link
Author

HeavenlyChorus commented Oct 7, 2022

I installed from scratch just now, couldn't reproduce. Do custom models work?

its working fine if i manually install everything and run with python webui.py --precision full --no-half --medvram
just a bit less convenient (having to type everything) and also wondering why this happens :P

@theunit187
Copy link

I installed from scratch just now, couldn't reproduce. Do custom models work?

It doesn't even get to loading models, it breaks right after you launch "webui" file.
Another curious thing is when I run "python webui.py" I get the following error:

C:\Files\StableDiffusion\stable-diffusion-webui_>python webui.py
Traceback (most recent call last):
  File "C:\Files\StableDiffusion\stable-diffusion-webui_\webui.py", line 10, in <module>
    from modules import devices, sd_samplers
  File "C:\Files\StableDiffusion\stable-diffusion-webui_\modules\devices.py", line 3, in <module>
    import torch
ModuleNotFoundError: No module named 'torch'

But if I launch "webui-user" file, everything works fine, and I can generate images as usual.

@HeavenlyChorus
Copy link
Author

ModuleNotFoundError: No module named 'torch'

make sure you are in the venv when doing python webui.py
for example, open a python file inside the directory in vscode and select the right python interpreter (bottom right) for it to take effect

@ClashSAN
Copy link
Collaborator

ClashSAN commented Oct 7, 2022

But if I launch "webui-user" file, everything works fine, and I can generate images as usual.

That's what you're supposed to do, thats what everybody does usually.

its working fine if i manually install everything and run with python webui.py --precision full --no-half --medvram
just a bit less convenient (having to type everything) and also wondering why this happens

If you set your python path in webui-user.bat will that allow you to run by clicking?

@theunit187
Copy link

theunit187 commented Oct 7, 2022

That's what you're supposed to do, thats what everybody does usually.

Oh, the documentation is somewhat confusing then, in wiki it says: "The installation is finished, to start the web ui, run: python webui.py", and I assumed we work with "webui" files. And it worked fine yesterday, but not today. I'll stick to "user" file then, thanks for clarifying.

make sure you are in the venv when doing

Ah, I see, thanks.

@HeavenlyChorus
Copy link
Author

If you set your python path in webui-user.bat will that allow you to run by clicking?

hmm no? the thing that's not working is that it's failing comparing the hashes from what i can tell.
and no adding the python path didn't do anything, still the same error.

@BrutalCrabbo
Copy link

BrutalCrabbo commented Oct 8, 2022

I've encountered this hash issue too(webui-user.bat updates taming-transformer even though it's already the latest and says its hash is unidentifiable), thus can't initiate the web-ui browser with webui-user.bat. The thing is, you can solve this problem just by reverting the launch.py to the previous version (2nd October).Generating images seems fine, but no guarantee it won't break something.

@Swah
Copy link

Swah commented Oct 9, 2022

I found out that for me the problem was my GIT environment variable wasn't defined, which wasn't a problem before as I manually installed dependencies. In webui-user.bat, I now have this line
set GIT=C:/Users//.conda/envs/qwe/Library/mingw64/libexec/git-core\git.exe

If you're not sure where your own GIT is installed, you can run "git --exec-path" and add "git.exe" at the end.

@BrutalCrabbo
Copy link

BrutalCrabbo commented Oct 9, 2022

I found out that for me the problem was my GIT environment variable wasn't defined, which wasn't a problem before as I manually installed dependencies. In webui-user.bat, I now have this line set GIT=C:/Users//.conda/envs/qwe/Library/mingw64/libexec/git-core\git.exe

If you're not sure where your own GIT is installed, you can run "git --exec-path" and add "git.exe" at the end.

venv "D:\Git\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: f7c787eb7c295c27439f4fbdf78c26b8389560be
Fetching updates for Taming Transformers...
Checking out commint for Taming Transformers with hash: 24268930bf1dce879235a7fddd0b2355b84d7ea6...
Traceback (most recent call last):
  File "D:\Git\stable-diffusion-webui\launch.py", line 130, in <module>
    git_clone("https://github.com/CompVis/taming-transformers.git", repo_dir('taming-transformers'), "Taming Transformers", taming_transformers_commit_hash)
  File "D:\Git\stable-diffusion-webui\launch.py", line 97, in git_clone
    run(f'"{git}" -C {dir} checkout {commithash}', f"Checking out commint for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}")
  File "D:\Git\stable-diffusion-webui\launch.py", line 54, in run
    raise RuntimeError(message)
RuntimeError: Couldn't checkout commit 24268930bf1dce879235a7fddd0b2355b84d7ea6 for Taming Transformers.
Command: "D:/Git/mingw64/libexec/git-core/git.exe" -C repositories\taming-transformers checkout 24268930bf1dce879235a7fddd0b2355b84d7ea6
Error code: 128
stdout: <empty>
stderr: fatal: reference is not a tree: 24268930bf1dce879235a7fddd0b2355b84d7ea6

Thanks for replying, but still cant get the latest version working.

@CryUshio
Copy link

CryUshio commented Oct 9, 2022

I tried to modify the launch.py and it works.

-   stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "69ae4b35e0a0f6ee1af8bb9a5d0016ccb27e36dc")
+   stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "45bf9a6264b3507473e02cc3f9aa36559f24aca2") # Use latest commit hash

@agarzon
Copy link

agarzon commented Oct 10, 2022

image

Having the same error

@Promisin
Copy link

In my case, after running launcher.py, I can find files in the corresponding directory. It seems the only problem is that the command can't get right returncode. So I just ignore this case by adding some code in launcher.py. Now everything just work fine. But you should make sure all the thing right except the returncode.

# you can find this code in line 24
if result.returncode != 0 and result.returncode != 1:

@Teale001
Copy link

maybe you can upgrade your git version to 2.39.0

@mezotaken mezotaken added asking-for-help-with-local-system-issues This issue is asking for help related to local system; please offer assistance and removed bug-report Report of a bug, yet to be confirmed labels Jan 16, 2023
@iAimFoxZ
Copy link

I just reinstalled Git (https://git-scm.com/download/win) here's a link, and it works just fine

@jmt33
Copy link

jmt33 commented Mar 3, 2023

modify the launch.py

def git_clone(url, dir, name, commithash=None):
# TODO clone into temporary dir and move if successful

# if os.path.exists(dir):
#     if commithash is None:
#         return

#     current_hash = run(f'"{git}" -C "{dir}" rev-parse HEAD', None, f"Couldn't determine {name}'s hash: {commithash}").strip()
#     if current_hash == commithash:
#         return

#     run(f'"{git}" -C "{dir}" fetch', f"Fetching updates for {name}...", f"Couldn't fetch {name}")
#     run(f'"{git}" -C "{dir}" checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}")
#     return

run(f'"{git}" clone "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}")

if commithash is not None:
    run(f'"{git}" -C "{dir}" checkout {commithash}', None, "Couldn't checkout {name}'s hash: {commithash}")

@za-wa-n-go
Copy link

za-wa-n-go commented Mar 8, 2023

I just reinstalled Git (https://git-scm.com/download/win) here's a link, and it works just fine

It's too much of a mystery, but this may have fixed it.

However, I also tweaked launch.py at the same time and was able to get the commit hash from none.
However, I was still unable to launch, so I reverted the launch.py changes, but for some reason, the commit hash was still available.
So it launched just fine.
It's a mystery.

@Foul-Tarnished
Copy link

Foul-Tarnished commented Mar 24, 2023

modify the launch.py

def git_clone(url, dir, name, commithash=None): # TODO clone into temporary dir and move if successful

# if os.path.exists(dir):
#     if commithash is None:
#         return

#     current_hash = run(f'"{git}" -C "{dir}" rev-parse HEAD', None, f"Couldn't determine {name}'s hash: {commithash}").strip()
#     if current_hash == commithash:
#         return

#     run(f'"{git}" -C "{dir}" fetch', f"Fetching updates for {name}...", f"Couldn't fetch {name}")
#     run(f'"{git}" -C "{dir}" checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}")
#     return

run(f'"{git}" clone "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}")

if commithash is not None:
    run(f'"{git}" -C "{dir}" checkout {commithash}', None, "Couldn't checkout {name}'s hash: {commithash}")

still have the issue


venv "F:\SD-WebUI\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.10 (tags/v3.10.10:aad5f6a, Feb  7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)]
Commit hash: <none>
Cloning Stable Diffusion into F:\SD-WebUI\stable-diffusion-webui\repositories\stable-diffusion-stability-ai...
Traceback (most recent call last):
  File "F:\SD-WebUI\stable-diffusion-webui\launch.py", line 380, in <module>
    prepare_environment()
  File "F:\SD-WebUI\stable-diffusion-webui\launch.py", line 315, in prepare_environment
    git_clone(stable_diffusion_repo, repo_dir('stable-diffusion-stability-ai'), "Stable Diffusion", stable_diffusion_commit_hash)
  File "F:\SD-WebUI\stable-diffusion-webui\launch.py", line 167, in git_clone
    run(f'"{git}" clone "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}")
  File "F:\SD-WebUI\stable-diffusion-webui\launch.py", line 113, in run
    raise RuntimeError(message)
RuntimeError: Couldn't clone Stable Diffusion.
Command: "C:\Program Files\Git\cmd\git.exe      " clone "https://github.com/Stability-AI/stablediffusion.git" "F:\SD-WebUI\stable-diffusion-webui\repositories\stable-diffusion-stability-ai"
Error code: 1
stdout: <empty>
stderr: La syntaxe du nom de fichier, de rpertoire ou de volume est incorrecte.

@Foul-Tarnished
Copy link

I changed git\cmd\git.exe to
git\git-cmd.exe

now it's stuck on

venv "F:\SD-WebUI\stable-diffusion-webui\venv\Scripts\Python.exe"

@NielsGx
Copy link

NielsGx commented Mar 24, 2023

I used git\cmd\git.exe

Should be git\git-cmd.exe

After a reinstall of git and changing that, plus a restart, it works

@Promisin
Copy link

A new resolution for me
Open a brand new Command Prompt, if you can see some error information such as "The system cannot find the path specified" without running any command, you should check Computer\HKEY_CURRENT_USER\Software\Microsoft\Command Processor item in regedit. Then disable or delete the value of Autorun.
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, env=os.environ if custom_env is None else custom_env)
shell=True will run the command with the default shell which specific by environment variable COMSPEC in windows, and usually this refers to the cmd.exe. Thus, subprocess.run will receive the error message of Autorun.

@dongxiaofu
Copy link

Can you get the latest hash when you run the command git -C repositories\stable-diffusion rev-parse HEAD directly?If not,mybe the version of your git is too low to support the command git -C.My git version is 1.8, and I came across the same error as yours.When I update my git to 2.19.0,it works well,no error.

@ElchWiesel
Copy link

Check in the properties of the folder under "security" if users have access. Worked for me after granting access.

@leeruibin
Copy link

leeruibin commented Apr 13, 2023

If someone tries to use pycharm to debug the launch.py and meet this issue again, here is a solution for me.
This script call "subprocess.run()" to run the git command. I check the subprocess.run() with git command and find this error may be caused by the wrong os environment.

result = subprocess.run(command, shell=True, env=os.environ if custom_env is None else custom_env)

As shown in this line, it may use os.environ to get the environment variables, but the output variables are not the same as my environment, I use windows 10. You can check whether this varibles are the same as your system variables. For me, the path of git miss, so I modify this script and add the path to my git. Then the issue is solved.

Here is the reference. In run function, add the git path to the os.environ['PATH']

def run(command, desc=None, errdesc=None, custom_env=None, live=False):
    if desc is not None:
        print(desc)
    env_list = os.environ
    cur_path = os.environ['PATH']
    cur_path += ";path to your git bin file" # for example D:\\software\\Git\\cmd
    os.environ['PATH'] = cur_path
    if live:
        result = subprocess.run(command, shell=True, env=os.environ if custom_env is None else custom_env)
        if result.returncode != 0:
            raise RuntimeError(f"""{errdesc or 'Error running command'}.
Command: {command}
Error code: {result.returncode}""")

        return ""

@xiejibing
Copy link

update git version to 2.x.

@Tiro00
Copy link

Tiro00 commented May 8, 2023

hi any fix or advise pls
sdfgsdfsd

@zdxpan
Copy link

zdxpan commented May 10, 2023

This because a bug of git version,
when i use git version 1.8.3.1
it`s not support git -C "path_dir", while it shoud be git -c

change the code launch.py "-C" to "-c" can solve this problem

addition: git -c "/home/dell/workspace/stable-diffusion-webui/repositories/stable-diffusion-stability-ai" rev-parse HEAD can get the repo`s commit Hash

@webgoto
Copy link

webgoto commented May 13, 2023

I edited launch.py in windows.
current_hash = run(f'"{git}" -C "{dir}" rev-parse HEAD', None, f"Couldn't determine {name}'s hash: {commithash}").strip()
It worked when I changed "{git}" to {git} used in these codes.

@linshizuowei
Copy link

I tried to modify the launch.py and it works.

-   stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "69ae4b35e0a0f6ee1af8bb9a5d0016ccb27e36dc")
+   stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "45bf9a6264b3507473e02cc3f9aa36559f24aca2") # Use latest commit hash

this works for me

@bjrocks00
Copy link

i read someone comment and got my issue resolved by doing this.
just go to your directory where stable diffusion is installed
then right click and click on git bash here
copy this command and paste it there and run it
git config --global --add safe.directory "*"
i hope this will work for you. it worked for me

@CHONGANDXU
Copy link

image

Having the same error

I think you can go to your directory using the command tool cd repositories/
then run this command git clone https://github.com/CompVis/taming-transformers.git
may it help you solve the problem

@heboba
Copy link

heboba commented Jul 16, 2023

I have fixed it by changing "shell": True into "shell": False in stable-diffusion-webui-directml\modules\launch_utils.py. In this part of code
run_kwargs = {
"args": command,
"shell": False,
"env": os.environ,
"encoding": 'utf8',
"errors": 'ignore',
}

@chengmo03013106
Copy link

I remove all of these as follow in launch_utils.py, it worked
stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "")
stable_diffusion_xl_commit_hash = os.environ.get('STABLE_DIFFUSION_XL_COMMIT_HASH', "")
k_diffusion_commit_hash = os.environ.get('K_DIFFUSION_COMMIT_HASH', "")
codeformer_commit_hash = os.environ.get('CODEFORMER_COMMIT_HASH', "")
blip_commit_hash = os.environ.get('BLIP_COMMIT_HASH', "")

@saffatbokul
Copy link

Running conda install -c anaconda git worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
asking-for-help-with-local-system-issues This issue is asking for help related to local system; please offer assistance
Projects
None yet
Development

No branches or pull requests