AUTOMATIC1111 / stable-diffusion-webui

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

[Bug]: RuntimeError: Couldn't install torch (Debian stable) #6717

Open Auravendill opened 1 year ago

Auravendill commented 1 year ago

Is there an existing issue for this?

What happened?

When I try to install the Nvidia version via the automated script, it always fails, even though I tried it with a range of different python environments. When I run it with the default Python version from debian stable (3.9.2), I get "RuntimeError: Couldn't install torch"

But the dependencies say, that I shall use Python 3.10.6, so I created a conda environment with that, activated it and run the bash script, but I still got this:

bash <(wget -qO- https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh)

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on daniel user
################################################################

################################################################
Clone stable-diffusion-webui
################################################################
Klone nach 'stable-diffusion-webui' ...
remote: Enumerating objects: 14218, done.
remote: Counting objects: 100% (182/182), done.
remote: Compressing objects: 100% (128/128), done.
remote: Total 14218 (delta 104), reused 112 (delta 54), pack-reused 14036
Empfange Objekte: 100% (14218/14218), 26.29 MiB | 19.35 MiB/s, fertig.
Löse Unterschiede auf: 100% (9918/9918), fertig.

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Python 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:36:39) [GCC 10.4.0]
Commit hash: 82725f0ac439f7e3b67858d55900e95330bbd326
Installing torch and torchvision
Traceback (most recent call last):
  File "/home/daniel/stable-diffusion-webui/launch.py", line 307, in <module>
    prepare_environment()
  File "/home/daniel/stable-diffusion-webui/launch.py", line 218, in prepare_environment
    run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch")
  File "/home/daniel/stable-diffusion-webui/launch.py", line 64, in run
    raise RuntimeError(message)
RuntimeError: Couldn't install torch.
Command: "/home/daniel/stable-diffusion-webui/venv/bin/python3" -m pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113
Error code: 137
stdout: Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu113
Collecting torch==1.12.1+cu113

stderr: Killed

Steps to reproduce the problem

  1. conda create --name diffusion python=3.10.6
  2. conda activate diffusion
  3. bash <(wget -qO- https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh)

What should have happened?

It should have created the environment with torch installed

Commit where the problem happens

82725f0ac439f7e3b67858d55900e95330bbd326

What platforms do you use to access UI ?

Linux

What browsers do you use to access the UI ?

Mozilla Firefox

Command Line Arguments

No response

Additional information, context and logs

Before that I had the issue, that I installed pytorch via its own documentation in an environment (via pip, since the interactive documentation glitched (or was updated in the meantine) and showed, that only pip would work rn). When I opened the bash script while this environment was activated, I got "RuntimeError: Error running command. Command: "/home/daniel/stable-diffusion-webui/venv/bin/python3" -c "import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'""

CUDA is installed per Nvidias instruction: https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Debian&target_version=11&target_type=deb_local

The GPU is a GTX 970

Auravendill commented 1 year ago

As a workaround, I used the semi-automatic version with launch.py, without any venv and with pytorch installed beforehand and that worked (after a lot of struggle with cuda and nvidias dumb driver issues in Debian...)

Angular-Angel commented 1 year ago

Had the same problem:

    src/libImaging/Jpeg2KEncode.c: In function ‘j2k_encode_entry’:
    src/libImaging/Jpeg2KEncode.c:345:9: warning: ‘bpp’ is deprecated: Use prec instead [-Wdeprecated-declarations]
      345 |         image_params[n].bpp = bpp;
          |         ^~~~~~~~~~~~
    In file included from src/libImaging/Jpeg2K.h:11,
                     from src/libImaging/Jpeg2KEncode.c:20:
    /usr/include/openjpeg-2.5/openjpeg.h:750:45: note: declared here
      750 |     OPJ_DEPRECATED_STRUCT_MEMBER(OPJ_UINT32 bpp, "Use prec instead");
          |                                             ^~~
    /usr/include/openjpeg-2.5/openjpeg.h:80:83: note: in definition of macro ‘OPJ_DEPRECATED_STRUCT_MEMBER’
       80 | #define OPJ_DEPRECATED_STRUCT_MEMBER(memb, msg) __attribute__ ((deprecated(msg))) memb
          |                                                                                   ^~~~
    src/libImaging/Jpeg2KEncode.c:466:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
      466 |         while (tile_width < (1 << (params.numresolution - 1U)) || tile_height < (1 << (params.numresolution - 1U))) {
          |                           ^
    src/libImaging/Jpeg2KEncode.c:466:79: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
      466 |         while (tile_width < (1 << (params.numresolution - 1U)) || tile_height < (1 << (params.numresolution - 1U))) {
          |                                                                               ^
    /usr/bin/gcc-11 -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_LIBJPEG -DHAVE_OPENJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -DHAVE_XCB -DPILLOW_VERSION="9.4.0" -I/usr/include/freetype2 -I/usr/include/openjpeg-2.5 -I/tmp/pip-install-_8f4_h55/pillow -I/usr/include/x86_64-linux-gnu -I/home/angle/stable-diffusion-webui/venv/include -I/usr/local/include -I/usr/include -I/home/angle/stable-diffusion-webui/venv/include -I/home/angle/anaconda3/include/python3.7m -c src/libImaging/BoxBlur.c -o build/temp.linux-x86_64-3.7/src/libImaging/BoxBlur.o
    /usr/bin/gcc-11 -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_LIBJPEG -DHAVE_OPENJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -DHAVE_XCB -DPILLOW_VERSION="9.4.0" -I/usr/include/freetype2 -I/usr/include/openjpeg-2.5 -I/tmp/pip-install-_8f4_h55/pillow -I/usr/include/x86_64-linux-gnu -I/home/angle/stable-diffusion-webui/venv/include -I/usr/local/include -I/usr/include -I/home/angle/stable-diffusion-webui/venv/include -I/home/angle/anaconda3/include/python3.7m -c src/libImaging/QuantPngQuant.c -o build/temp.linux-x86_64-3.7/src/libImaging/QuantPngQuant.o
    /usr/bin/gcc-11 -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_LIBJPEG -DHAVE_OPENJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -DHAVE_XCB -DPILLOW_VERSION="9.4.0" -I/usr/include/freetype2 -I/usr/include/openjpeg-2.5 -I/tmp/pip-install-_8f4_h55/pillow -I/usr/include/x86_64-linux-gnu -I/home/angle/stable-diffusion-webui/venv/include -I/usr/local/include -I/usr/include -I/home/angle/stable-diffusion-webui/venv/include -I/home/angle/anaconda3/include/python3.7m -c src/libImaging/codec_fd.c -o build/temp.linux-x86_64-3.7/src/libImaging/codec_fd.o
    gcc -pthread -shared -B /home/angle/anaconda3/compiler_compat -L/home/angle/anaconda3/lib -Wl,-rpath=/home/angle/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.7/src/_imaging.o build/temp.linux-x86_64-3.7/src/decode.o build/temp.linux-x86_64-3.7/src/encode.o build/temp.linux-x86_64-3.7/src/map.o build/temp.linux-x86_64-3.7/src/display.o build/temp.linux-x86_64-3.7/src/outline.o build/temp.linux-x86_64-3.7/src/path.o build/temp.linux-x86_64-3.7/src/libImaging/Access.o build/temp.linux-x86_64-3.7/src/libImaging/AlphaComposite.o build/temp.linux-x86_64-3.7/src/libImaging/Resample.o build/temp.linux-x86_64-3.7/src/libImaging/Reduce.o build/temp.linux-x86_64-3.7/src/libImaging/Bands.o build/temp.linux-x86_64-3.7/src/libImaging/BcnDecode.o build/temp.linux-x86_64-3.7/src/libImaging/BitDecode.o build/temp.linux-x86_64-3.7/src/libImaging/Blend.o build/temp.linux-x86_64-3.7/src/libImaging/Chops.o build/temp.linux-x86_64-3.7/src/libImaging/ColorLUT.o build/temp.linux-x86_64-3.7/src/libImaging/Convert.o build/temp.linux-x86_64-3.7/src/libImaging/ConvertYCbCr.o build/temp.linux-x86_64-3.7/src/libImaging/Copy.o build/temp.linux-x86_64-3.7/src/libImaging/Crop.o build/temp.linux-x86_64-3.7/src/libImaging/Dib.o build/temp.linux-x86_64-3.7/src/libImaging/Draw.o build/temp.linux-x86_64-3.7/src/libImaging/Effects.o build/temp.linux-x86_64-3.7/src/libImaging/EpsEncode.o build/temp.linux-x86_64-3.7/src/libImaging/File.o build/temp.linux-x86_64-3.7/src/libImaging/Fill.o build/temp.linux-x86_64-3.7/src/libImaging/Filter.o build/temp.linux-x86_64-3.7/src/libImaging/FliDecode.o build/temp.linux-x86_64-3.7/src/libImaging/Geometry.o build/temp.linux-x86_64-3.7/src/libImaging/GetBBox.o build/temp.linux-x86_64-3.7/src/libImaging/GifDecode.o build/temp.linux-x86_64-3.7/src/libImaging/GifEncode.o build/temp.linux-x86_64-3.7/src/libImaging/HexDecode.o build/temp.linux-x86_64-3.7/src/libImaging/Histo.o build/temp.linux-x86_64-3.7/src/libImaging/JpegDecode.o build/temp.linux-x86_64-3.7/src/libImaging/JpegEncode.o build/temp.linux-x86_64-3.7/src/libImaging/Matrix.o build/temp.linux-x86_64-3.7/src/libImaging/ModeFilter.o build/temp.linux-x86_64-3.7/src/libImaging/Negative.o build/temp.linux-x86_64-3.7/src/libImaging/Offset.o build/temp.linux-x86_64-3.7/src/libImaging/Pack.o build/temp.linux-x86_64-3.7/src/libImaging/PackDecode.o build/temp.linux-x86_64-3.7/src/libImaging/Palette.o build/temp.linux-x86_64-3.7/src/libImaging/Paste.o build/temp.linux-x86_64-3.7/src/libImaging/Quant.o build/temp.linux-x86_64-3.7/src/libImaging/QuantOctree.o build/temp.linux-x86_64-3.7/src/libImaging/QuantHash.o build/temp.linux-x86_64-3.7/src/libImaging/QuantHeap.o build/temp.linux-x86_64-3.7/src/libImaging/PcdDecode.o build/temp.linux-x86_64-3.7/src/libImaging/PcxDecode.o build/temp.linux-x86_64-3.7/src/libImaging/PcxEncode.o build/temp.linux-x86_64-3.7/src/libImaging/Point.o build/temp.linux-x86_64-3.7/src/libImaging/RankFilter.o build/temp.linux-x86_64-3.7/src/libImaging/RawDecode.o build/temp.linux-x86_64-3.7/src/libImaging/RawEncode.o build/temp.linux-x86_64-3.7/src/libImaging/Storage.o build/temp.linux-x86_64-3.7/src/libImaging/SgiRleDecode.o build/temp.linux-x86_64-3.7/src/libImaging/SunRleDecode.o build/temp.linux-x86_64-3.7/src/libImaging/TgaRleDecode.o build/temp.linux-x86_64-3.7/src/libImaging/TgaRleEncode.o build/temp.linux-x86_64-3.7/src/libImaging/Unpack.o build/temp.linux-x86_64-3.7/src/libImaging/UnpackYCC.o build/temp.linux-x86_64-3.7/src/libImaging/UnsharpMask.o build/temp.linux-x86_64-3.7/src/libImaging/XbmDecode.o build/temp.linux-x86_64-3.7/src/libImaging/XbmEncode.o build/temp.linux-x86_64-3.7/src/libImaging/ZipDecode.o build/temp.linux-x86_64-3.7/src/libImaging/ZipEncode.o build/temp.linux-x86_64-3.7/src/libImaging/TiffDecode.o build/temp.linux-x86_64-3.7/src/libImaging/Jpeg2KDecode.o build/temp.linux-x86_64-3.7/src/libImaging/Jpeg2KEncode.o build/temp.linux-x86_64-3.7/src/libImaging/BoxBlur.o build/temp.linux-x86_64-3.7/src/libImaging/QuantPngQuant.o build/temp.linux-x86_64-3.7/src/libImaging/codec_fd.o -L/tmp/pip-install-_8f4_h55/pillow -L/home/angle/stable-diffusion-webui/venv/lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib -L/usr/lib/x86_64-linux-gnu/libfakeroot -L/usr/local/lib -ljpeg -lopenjp2 -lz -ltiff -lxcb -o build/lib.linux-x86_64-3.7/PIL/_imaging.cpython-37m-x86_64-linux-gnu.so
    /home/angle/anaconda3/compiler_compat/ld: /lib/x86_64-linux-gnu/libc.so.6: unknown type [0x13] section `.relr.dyn'
    /home/angle/anaconda3/compiler_compat/ld: skipping incompatible /lib/x86_64-linux-gnu/libc.so.6 when searching for /lib/x86_64-linux-gnu/libc.so.6
    /home/angle/anaconda3/compiler_compat/ld: /lib/x86_64-linux-gnu/libc.so.6: unknown type [0x13] section `.relr.dyn'
    /home/angle/anaconda3/compiler_compat/ld: skipping incompatible /lib/x86_64-linux-gnu/libc.so.6 when searching for /lib/x86_64-linux-gnu/libc.so.6
    /home/angle/anaconda3/compiler_compat/ld: cannot find /lib/x86_64-linux-gnu/libc.so.6
    /home/angle/anaconda3/compiler_compat/ld: /lib64/ld-linux-x86-64.so.2: unknown type [0x13] section `.relr.dyn'
    /home/angle/anaconda3/compiler_compat/ld: skipping incompatible /lib64/ld-linux-x86-64.so.2 when searching for /lib64/ld-linux-x86-64.so.2
    /home/angle/anaconda3/compiler_compat/ld: /lib64/ld-linux-x86-64.so.2: unknown type [0x13] section `.relr.dyn'
    /home/angle/anaconda3/compiler_compat/ld: skipping incompatible /lib64/ld-linux-x86-64.so.2 when searching for /lib64/ld-linux-x86-64.so.2
    /home/angle/anaconda3/compiler_compat/ld: cannot find /lib64/ld-linux-x86-64.so.2
    collect2: error: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/angle/stable-diffusion-webui/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_8f4_h55/pillow/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_8f4_h55/pillow/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-s6f77y0a/install-record.txt --single-version-externally-managed --compile --install-headers /home/angle/stable-diffusion-webui/venv/include/site/python3.7/pillow Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 23.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Traceback (most recent call last):
  File "launch.py", line 360, in <module>
    prepare_environment()
  File "launch.py", line 269, in prepare_environment
    run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
  File "launch.py", line 91, in run
    Error code: {result.returncode}""")
RuntimeError: Couldn't install torch.
Command: "/home/angle/stable-diffusion-webui/venv/bin/python3" -m pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
Error code: 1
Norrica commented 1 year ago

Having same problem. First ever install worked fine, after i moved it into other folder, from there and fresh installs are not unable to install torch.

Manually sourcing venv/bin/activate and using pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117 susccessfully installed torch.

andzejsp commented 1 year ago

Having the same issues right now, clean VM with GPU passthrough, linux mint, followed linux install with wget and it dies at "Installing torch and torchvision"

Im running python 3.10.6

I tried what the comment above said, sourcing venv, it installed it but it doesnt work. still the same error

andzejsp commented 1 year ago

I found solution, if you have 8gib ram not Vram then you need to add this line

in the launch.py file, find : torch_command = os.env

it should be the line where it runs pip install torch stuff.

add the

--no-cache-dir

https://stackoverflow.com/a/62302334/14106028

Im still struggling with 'Torch is not able to use GPU'

EDIT: solved torch not able to find GPU, turns out my pass through was not set up correctly, now i have no issues. EDIT2: also use more cpu RAM, with 16gibs i have no problems, with 8gibs i have OOM errors and failures when im switching between models.

Angular-Angel commented 1 year ago

Well, I tried again, trying both the 'add --no-cache-dir' and and the 'using pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117' solutions, and neither worked for me. I'll keep poking at it, and see what I can figure out?

LuceDeCielo commented 1 year ago

I ran into the same issue and solved it by deleting the "pip"-folder in /home/$USER/.cache