stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

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

Open HeavenlyChorus opened this issue 2 years ago • 36 comments

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 avatar Oct 07 '22 17:10 HeavenlyChorus

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: ⠪᪠ 訡   䠩,    ⪥ ⮬.

theunit187 avatar Oct 07 '22 17:10 theunit187

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

ClashSAN avatar Oct 07 '22 19:10 ClashSAN

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

HeavenlyChorus avatar Oct 07 '22 19:10 HeavenlyChorus

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.

theunit187 avatar Oct 07 '22 19:10 theunit187

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

HeavenlyChorus avatar Oct 07 '22 20:10 HeavenlyChorus

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?

ClashSAN avatar Oct 07 '22 20:10 ClashSAN

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.

theunit187 avatar Oct 07 '22 20:10 theunit187

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.

HeavenlyChorus avatar Oct 08 '22 01:10 HeavenlyChorus

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.

BrutalCrabbo avatar Oct 08 '22 04:10 BrutalCrabbo

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.

Swah avatar Oct 09 '22 13:10 Swah

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.

BrutalCrabbo avatar Oct 09 '22 13:10 BrutalCrabbo

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

CryUshio avatar Oct 09 '22 18:10 CryUshio

image

Having the same error

agarzon avatar Oct 10 '22 02:10 agarzon

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:

Promisin avatar Oct 11 '22 18:10 Promisin

maybe you can upgrade your git version to 2.39.0

Teale001 avatar Dec 14 '22 04:12 Teale001

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

iAimFoxZ avatar Jan 23 '23 18:01 iAimFoxZ

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}")

jmt33 avatar Mar 03 '23 15:03 jmt33

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.

za-wa-n-go avatar Mar 08 '23 15:03 za-wa-n-go

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 avatar Mar 24 '23 03:03 Foul-Tarnished

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"

Foul-Tarnished avatar Mar 24 '23 03:03 Foul-Tarnished

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

NielsGx avatar Mar 24 '23 03:03 NielsGx

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.

Promisin avatar Mar 24 '23 05:03 Promisin

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.

dongxiaofu avatar Mar 26 '23 18:03 dongxiaofu

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

ElchWiesel avatar Mar 30 '23 15:03 ElchWiesel

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 ""

leeruibin avatar Apr 13 '23 09:04 leeruibin

update git version to 2.x.

xiejibing avatar May 08 '23 04:05 xiejibing

hi any fix or advise pls sdfgsdfsd

Tiro00 avatar May 08 '23 21:05 Tiro00

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

zdxpan avatar May 10 '23 09:05 zdxpan

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.

webgoto avatar May 13 '23 12:05 webgoto

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

linshizuowei avatar May 22 '23 08:05 linshizuowei