easydiffusion / easydiffusion

Easiest 1-click way to create beautiful artwork on your PC using AI, with no tech knowledge. Provides a browser UI for generating images from text prompts and images. Just enter your text prompt, and see the generated image.
https://easydiffusion.github.io/
Other
9.66k stars 798 forks source link

torch, libmkl_core.so: invalid ELF header #500

Closed jola5 closed 1 year ago

jola5 commented 2 years ago

Hi,

executing the installer start.sh script results in invalid ELF header error.

Steps to reproduce:

  1. Download https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.3.5/stable-diffusion-ui-linux.zip
  2. Extract files
  3. Execute ./start.sh

Expected result: stable-diffusion-ui is started Actual result: start.sh script terminates wit error message OSError: /opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/torch/lib/../../../../libmkl_core.so: invalid ELF header

Trace:

> ./start.sh
scripts/bootstrap.sh: line 9: ./scripts/functions.sh: No such file or directory                                                                                              
/usr/bin/git                                                                          
git version 2.38.1                                                                                                                                                           
/opt/stable-diffusion-ui-linux/stable-diffusion-ui/installer_files/env/bin/conda
conda 22.9.0                                                                                                                                                                 
scripts/on_env_start.sh: line 3: ./scripts/functions.sh: No such file or directory                                                                                           

Stable Diffusion UI                                                                                                                                                          

Stable Diffusion UI's git repository was already installed. Updating from main..
HEAD is now at c890ef6 Merge pull request #497 from cmdr2/beta
Already on 'main'                          
Your branch is up to date with 'origin/main'.
Already up to date.                        
./scripts/on_sd_start.sh: line 3: ./scripts/functions.sh: No such file or directory

Hotfixed broken JSON file from OpenAI
Stable Diffusion's git repository was already installed. Updating..
HEAD is now at f6cfebf Merge pull request #188 from jn-jairo/patch-1
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

HEAD is now at f6cfebf Merge pull request #188 from jn-jairo/patch-1
Packages necessary for Stable Diffusion were already installed
Packages necessary for GFPGAN (Face Correction) were already installed
Packages necessary for ESRGAN (Resolution Upscaling) were already installed
Packages necessary for Stable Diffusion UI were already installed
Data files (weights) necessary for Stable Diffusion were already downloaded
Data files (weights) necessary for GFPGAN (Face Correction) were already downloaded
Data files (weights) necessary for ESRGAN (Resolution Upscaling) x4plus were already downloaded
Data files (weights) necessary for ESRGAN (Resolution Upscaling) x4plus_anime were already downloaded
Data files (weights) necessary for the default VAE (sd-vae-ft-mse-original) were already downloaded

Stable Diffusion is ready!

PYTHONPATH=/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion:/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-pac
kages                                      
/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/bin/python
Python 3.8.5                               
started in  /opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion
Traceback (most recent call last):
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/bin/uvicorn", line 11, in <module>
    sys.exit(main())                       
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/uvicorn/main.py", line 404, in main
    run(                                   
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/uvicorn/main.py", line 569, in run
    server.run()                           
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/uvicorn/server.py", line 60, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/uvicorn/server.py", line 67, in serve
    config.load()                          
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/uvicorn/config.py", line 474, in load
    self.loaded_app = import_from_string(self.app)
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/uvicorn/importer.py", line 21, in import_from_string
    module = importlib.import_module(module_str)
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/ui/server.py", line 48, in <module>
    from sd_internal import Request, Response, task_manager
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/ui/sd_internal/task_manager.py", line 12, in <module>
    import torch                           
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/torch/__init__.py", line 198, in <module>
    _load_global_deps()
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/torch/__init__.py", line 151, in _load_global_deps
    ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
  File "/opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/ctypes/__init__.py", line 381, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/torch/lib/../../../../libmkl_core.so: invalid ELF header
Press any key to continue

Environment:

> cat /proc/version 
Linux version 6.0.8-arch1-1 (linux@archlinux) (gcc (GCC) 12.2.0, GNU ld (GNU Binutils) 2.39.0) #1 SMP PREEMPT_DYNAMIC Thu, 10 Nov 2022 21:14:24 +0000
> cat /etc/*-release
DISTRIB_ID=ArcoLinux
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="ArcoLinux"NAME=ArcoLinux
ID=arcolinux
ID_LIKE=arch
BUILD_ID=rolling
ANSI_COLOR="0;36"
HOME_URL="https://arcolinux.info/"
SUPPORT_URL="https://arcolinuxforum.com/"
BUG_REPORT_URL="https://github.com/arcolinux"
LOGO=arcolinux-hello
> hostnamectl
 Static hostname: ***
       Icon name: computer-desktop
         Chassis: desktop 🖥️
      Machine ID: ***
         Boot ID: ***
          Kernel: Linux 6.0.8-arch1-1
    Architecture: x86-64
 Hardware Vendor: Gigabyte Technology Co., Ltd.
  Hardware Model: AB350M-DS3H
Firmware Version: F42a
> $SHELL --version
fish, version 3.5.1
# using other shells doesn't change anything, tried sh and bash as well, same result

My first research suggests some platform issue (i.e. using an executable build for another platform). I'm using the only linux download that is available, therefore I don't know what I could be doing wrong there.

If there is anything I can try or any other information that I can provide let me know. Thanks for your efforts.

Regards Johannes

jola5 commented 2 years ago

Some more digging from my side:

> la /opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/torch/lib/../../../../lib
mkl_core.so                                                                           
lrwxrwxrwx 1 ho ho 16 Nov 17 12:54 /opt/stable-diffusion-ui-linux/stable-diffusion-ui/stable-diffusion/env/lib/python3.8/site-packages/torch/lib/../../../../libmkl_core.so -> libmkl_core.so.1*
> file ./stable-diffusion/env/lib/libmkl_core.so.1
./stable-diffusion/env/lib/libmkl_core.so.1: data
> hexdump ./stable-diffusion/env/lib/libmkl_core.so.1
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
474b460 0000 0000 0000 0000                    
474b468

But further than this, I don't have any clue how to proceed with debugging.

I have no clue how to work with shared object files and how to debug issues with them. But the following commands should provide some meaningful output. But in this case they don't:

> objdump -T ./stable-diffusion/env/lib/libmkl_core.so.1 
objdump: ./stable-diffusion/env/lib/libmkl_core.so.1: file format not recognized
> ldd ./stable-diffusion/env/lib/libmkl_core.so.1
        not a dynamic executable

Could the download be corrupt? Normally I would check this, but I didn't find any hashes for the artifacts to do so.

jola5 commented 2 years ago

Some more digging leads to https://github.com/Ben-Louis/Deep-Image-Analogy-PyTorch/issues/8 and https://github.com/ContinuumIO/anaconda-issues/issues/698#issuecomment-219004477 with the same/similar issue.

Both suggesting manually installing conda install -c anaconda mkl. That didn't work in my case though.

cmdr2 commented 1 year ago

If this is still relevant, please try the latest version. A lot has improved since then. Feel free to reopen if it's still a problem. https://github.com/easydiffusion/easydiffusion/releases/tag/v3.0.2

jola5 commented 1 year ago

Nice! This fixed my issue indeed. Thanks @cmdr2