invoke-ai / InvokeAI

Invoke is a leading creative engine for Stable Diffusion models, empowering professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry leading WebUI, and serves as the foundation for multiple commercial products.
https://invoke-ai.github.io/InvokeAI/
Apache License 2.0
23.51k stars 2.42k forks source link

[bug]: PatchMatch does not load on Archlinux, returns notfatal error. #2217

Closed atuarre closed 1 year ago

atuarre commented 1 year ago

Is there an existing issue for this?

OS

Linux

GPU

cuda

VRAM

No response

What happened?

Followed the instructions here: https://invoke-ai.github.io/InvokeAI/installation/060_INSTALL_PATCHMATCH/?h=patchmatch#debian-based-distros

See attached screen shot, always get Patchmatch not loaded (nonfatal)

If you do the test in python to see if patchmatch is installed it returns nothing.

Screenshots

Screenshot_2023-01-03_12-38-05

Additional context

I have never gotten Patchmatch to load on any Arch based system. Did the devs test this? Whether it was vanilla Arch, EndeavourOS or Manjaro Linux (the two most popular Arch distros). I have never gotten patchmatch to work on any Linux system except Ubuntu/Debian based systems (Linux Mint, Ubuntu, etc)

Contact Details

atuarre@gmail.com

Lolagatorade commented 1 year ago

Same issue here but slightly different error. using majaro latest build

Version `GOMP_5.0' not found (required by /usr/lib/libvtkCommonCore.so.1)).

only time pypatchmatch worked for me was when the arch linux instruction manual was posted at first way back when invoke ai V2 or so was released... after that it was a fight to get it to work. and aftter a few more breaks it was either too complicated or not enough resources discribing fixes.

hopefully the devs fix this as i have been opening bugs in the past and they have been wrongfully flaged as "fixed"

Lolagatorade commented 1 year ago

Update tried to do once again full reinstall, clear pacman and pip cache, new error once testing

python  ✔ Python 3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.

from patchmatch import patch_match patchmatch.patch_match: ERROR - patchmatch failed to load or compile (libopencv_gapi.so.406: cannot open shared object file: No such file or directory). patchmatch.patch_match: INFO - Refer to https://invoke-ai.github.io/InvokeAI/installation/060_INSTALL_PATCHMATCH/ for installation instructions.

image

6630507 commented 1 year ago

Do you have xformers installed?

I discovered the hard way that xformers wants pytorch 1.13, under which patchmatch will not compile.

To get xformers and patchmatch, I had to first rebuild my conda environment, then install patchmatch (under torch 1.12), then launch InvokeAI to make patchmatch compile, then I could upgrade torch to 1.13 to install xformers (from facebook https://github.com/facebookresearch/xformers ) and lastly install triton's latest release ( pip install triton==2.0.0.dev20221120 ).

Lolagatorade commented 1 year ago

I will give it a try right now and let you know. Seems to me patchmatch hasnt been updated for some time... i dont even have torch 1.12 it was 1.13.1

From what i understood the process is

Ok i tried it and still not compiling

sudo pip install torch==1.12
Collecting torch==1.12 Downloading torch-1.12.0-cp39-cp39-manylinux1_x86_64.whl (776.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 776.3/776.3 MB 1.6 MB/s eta 0:00:00 Requirement already satisfied: typing-extensions in /opt/anaconda/lib/python3.9/site-packages (from torch==1.12) (4.4.0) Installing collected packages: torch Attempting uninstall: torch Found existing installation: torch 1.12.1 Uninstalling torch-1.12.1: Successfully uninstalled torch-1.12.1 ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. xformers 0.0.15.dev344+git.8910bb5 requires pyre-extensions==0.0.23, which is not installed. Successfully installed torch-1.12.1 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

pip install pyre-extensions==0.0.23
Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: pyre-extensions==0.0.23 in ./.local/lib/python3.9/site-packages (0.0.23) Requirement already satisfied: typing-extensions in /opt/anaconda/lib/python3.9/site-packages (from pyre-extensions==0.0.23) (4.4.0) Requirement already satisfied: typing-inspect in ./.local/lib/python3.9/site-packages (from pyre-extensions==0.0.23) (0.8.0) Requirement already satisfied: mypy-extensions>=0.3.0 in /opt/anaconda/lib/python3.9/site-packages (from typing-inspect->pyre-extensions==0.0.23) (0.4.3)

pip install pypatchmatch

Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: pypatchmatch in ./.local/lib/python3.9/site-packages (0.1.5) Requirement already satisfied: tqdm in /opt/anaconda/lib/python3.9/site-packages (from pypatchmatch) (4.64.1) Requirement already satisfied: pillow in /opt/anaconda/lib/python3.9/site-packages (from pypatchmatch) (9.3.0) Requirement already satisfied: numpy in /opt/anaconda/lib/python3.9/site-packages (from pypatchmatch) (1.21.5)

python
Python 3.9.15 (main, Nov 24 2022, 14:31:59) [GCC 11.2.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information.

from patchmatch import patch_match patchmatch.patch_match: ERROR - patchmatch failed to load or compile (/opt/anaconda/lib/python3.9/site-packages/PIL/../../../././libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /usr/lib/libopencv_gapi.so.407)). patchmatch.patch_match: INFO - Refer to https://invoke-ai.github.io/InvokeAI/installation/060_INSTALL_PATCHMATCH/ for installation instructions.

Lolagatorade commented 1 year ago

Do you have xformers installed?

I discovered the hard way that xformers wants pytorch 1.13, under which patchmatch will not compile.

To get xformers and patchmatch, I had to first rebuild my conda environment, then install patchmatch (under torch 1.12), then launch InvokeAI to make patchmatch compile, then I could upgrade torch to 1.13 to install xformers (from facebook https://github.com/facebookresearch/xformers ) and lastly install triton's latest release ( pip install triton==2.0.0.dev20221120 ).

So in the end of the ordeal i ended back in square 1 :'( tried to install patchmatch on 1.12 but...

patchmatch.patch_match: ERROR - patchmatch failed to load or compile (libopencv_gapi.so.406: cannot open shared object file: No such file or directory).

error on invoke ai and previously mentioned python terminal error.

image

Anyways question thats maybe related whats your GCC version on python? You think that would matter? on the install instructions for invoke ai they are using [GCC 9.3.0] while my version is GCC 11.2... maybe that has something to do with it as its Gnu compiler? but ime not sure how to fix ot set older version

Attempt3035 commented 1 year ago

I am having what seems to be the same problem on OSX M1 Mac. Installing opencv doesn't help, any progress?

Lolagatorade commented 1 year ago

I am having what seems to be the same problem on OSX M1 Mac. Installing opencv doesn't help, any progress?

I saw solutions mentioned but its convoluted. It involved downgrading python to a earlier version so that it can compile and several other things. I think its best to just wait for the next release of invoke ai and hope they include an up to date pypatchmatch that doesent have install requirements that are old

https://github.com/invoke-ai/InvokeAI/pull/1580

problem is that its annoying to run different versions of python and it can lead to its own problems if other programs are dependant on a newer version. + security, performance and optimization issues ect

Attempt3035 commented 1 year ago

Actually, I used chatGPT to help me trace back the issues and come up with a solution. On my system, it seemed opencv being installed by homebrew was not being found by invokeai. Calling export PKG_CONFIG_PATH=/opt/homebrew/Cellar/opencv/4.7.0_1 solved the problem! However this definitely is only a temporary fix, as it will break with any version updates. As you say, next release will hopefully sort out these convoluted dependancy issues XD

Lolagatorade commented 1 year ago

Actually, I used chatGPT to help me trace back the issues and come up with a solution. On my system, it seemed opencv being installed by homebrew was not being found by invokeai. Calling export PKG_CONFIG_PATH=/opt/homebrew/Cellar/opencv/4.7.0_1 solved the problem! However this definitely is only a temporary fix, as it will break with any version updates. As you say, next release will hopefully sort out these convoluted dependancy issues XD

On arch Linux, it's basically the same thing. One loading patch match it says libgomp5 is missing. So it's either the libraries are properly linked or didn't compile properly because the python versions weren't compatible. Honestly, at the end of the day I'm a student I don't really have time to troubleshoot for hours. But it's nice as a community with people with similar hobbies and issues.

tbogdala commented 1 year ago

I'm getting more or less the same problem with it not finding GOMP_5.0 and InvokeAI 2.3.0 installed from release zip file. I can't remember if I did something specific to get to at least this point, where I can let it error or run the server with --no-patchmatch. Initially when I did my first, fresh install, the server would segfault upon attempt to generate an image in CLI or once the web interface connected; this was remedied by passing --no-patchmatch.

image

I'm running Manjaro which is current on all packages. GCC version is 12.2.1, Python 3.10.9, opencv-cuda installed with the symbolic link made per the documentation. Right now, it's generating my banana sushi images fine, but without patchmatch, outpainting will be crippled.

I've tried installing it to default paths under my home directory. I've tried forcing rebuilds of pypatchmatch. I've tried reinstalling pytorch. I've tried installing python-pytorch-cuda and python-pytorchvision-cua through the package manager. I've tried (unsuccessfully) to force an alternate install of python 3.9.16 (venv still used 3.10).

I'm a somewhat capable user and developer, but ML is mostly a blind spot and my python has 20 years of rust on it, so I'm kind of out of my element here. Let me know if there's any other information I could provide.

Attempt3035 commented 1 year ago

Not sure if it helps anyone, but passing the argument export PKG_CONFIG_PATH=/opt/homebrew/Cellar/opencv/4.7.0_1 Helped invokeAI find the packages it needed. (That was for opencv installed using homebrew, point it to whatever folder contains opencv.pc for you!) Obviously this isn't a great solution as it hard links to the opencv version number, but at least it might get it working 😄

Alexander-LIT commented 1 year ago

Same issue for me on Manjaro. I followed the instructions from the documentation. Using AMDGPU the automated installer and no xformers installed.

`>> System config requested

patchmatch.patch_match: ERROR - patchmatch failed to load or compile (libvtkFiltersTexture.so.1: cannot open shared object file: No such file or directory). patchmatch.patch_match: INFO - Refer to https://invoke-ai.github.io/InvokeAI/installation/060_INSTALL_PATCHMATCH/ for installation instructions. Patchmatch not loaded (nonfatal) `

pip install pypatchmatch  ✔  31s  Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: pypatchmatch in /home/alex/.local/lib/python3.10/site-packages (0.1.6) Requirement already satisfied: pillow in /home/alex/.local/lib/python3.10/site-packages (from pypatchmatch) (9.4.0) Requirement already satisfied: numpy in /home/alex/.local/lib/python3.10/site-packages (from pypatchmatch) (1.23.3) Requirement already satisfied: tqdm in /home/alex/.local/lib/python3.10/site-packages (from pypatchmatch) (4.64.1)

`Python 3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.

from patchmatch import patch_match patchmatch.patch_match: ERROR - patchmatch failed to load or compile (libvtkFiltersTexture.so.1: cannot open shared object file: No such file or directory). patchmatch.patch_match: INFO - Refer to https://invoke-ai.github.io/InvokeAI/installation/060_INSTALL_PATCHMATCH/ for installation instructions. `

B14CK313 commented 1 year ago

A workaround that worked for me (Archlinux) is to use the systems libgomp.so instead of the included one. If you want to try it for yourself:

  1. cd <invokeai dir>/.venv/lib/python3.10/site-packages/torch/lib/
  2. Backup libgomp-a34b3233.so.1: mv libgomp-a34b3233.so.1 libgomp-a34b3233.so.1.bkp
  3. Symlink the systems library: ln -s /usr/lib/libgomp.so.1 libgomp-a34b3233.so.1
Alexander-LIT commented 1 year ago

A workaround that worked for me (Archlinux) is to use the systems libgomp.so instead of the included one. If you want to try it for yourself:

  1. cd <invokeai dir>/.venv/lib/python3.10/site-packages/torch/lib/
  2. Backup libgomp-a34b3233.so.1: mv libgomp-a34b3233.so.1 libgomp-a34b3233.so.1.bkp
  3. Symlink the systems library: ln -s /usr/lib/libgomp.so.1 libgomp-a34b3233.so.1

Thank you for the tip. Sadly it did not seem to work for me. My /torch/lib folder inside invokeai only has libgomp.so (system has both libgomp.so and libgomp.so.1). I tried linking them as per your example, but no change.

Also reinstalled opencv (non cuda version), but still the same error: patchmatch failed to load or compile (libvtkFiltersTexture.so.1: cannot open shared object file: No such file or directory).

B14CK313 commented 1 year ago

Thank you for the tip. Sadly it did not seem to work for me. My /torch/lib folder inside invokeai only has libgomp.so (system has both libgomp.so and libgomp.so.1). I tried linking them as per your example, but no change.

It looks like you are missing another library libvtkFiltersTexture.so.1. On my machine this library is not located in the .venv directory but in the system-wide library directory. Check if you have community/vtk installed (it should be because it is required by python-opencv).

Sidenote: I just noticed that the instructions for Arch-based distros don't include installing python-opencv, I just installed it because it was mentioned for Debian-based distros. So if you don't have extra/python-opencv, maybe try installing it.

Alexander-LIT commented 1 year ago

Fantastic! That worked, thank you very much!

Steps (Manjaro):

Now starts up with ">> Patchmatch initialized" and no more errors! :smiley:

Svenare commented 1 year ago

Issue is still present in 2.3.1-rc2

You will need to reapply the above fix to get patchmatch working again

tbogdala commented 1 year ago

A workaround that worked for me (Archlinux) is to use the systems libgomp.so instead of the included one. If you want to try it for yourself:

1. `cd <invokeai dir>/.venv/lib/python3.10/site-packages/torch/lib/`

2. Backup `libgomp-a34b3233.so.1`: `mv libgomp-a34b3233.so.1 libgomp-a34b3233.so.1.bkp`

3. Symlink the systems library: `ln -s /usr/lib/libgomp.so.1 libgomp-a34b3233.so.1`

This did it for me, though I had also installed python-opencv as a precaution before the install as well. Patchmatch now initializes and seems to behave when outpainting!

Thanks for the solve, @B14CK313

Lolagatorade commented 1 year ago

A workaround that worked for me (Archlinux) is to use the systems libgomp.so instead of the included one. If you want to try it for yourself:

1. `cd <invokeai dir>/.venv/lib/python3.10/site-packages/torch/lib/`

2. Backup `libgomp-a34b3233.so.1`: `mv libgomp-a34b3233.so.1 libgomp-a34b3233.so.1.bkp`

3. Symlink the systems library: `ln -s /usr/lib/libgomp.so.1 libgomp-a34b3233.so.1`

This did it for me, though I had also installed python-opencv as a precaution before the install as well. Patchmatch now initializes and seems to behave when outpainting!

Thanks for the solve, @B14CK313

Couldnt get it working for me but thank you for the advice. Every time i try to fix pypathmatch its a new error its inasine. its either gomp 5 not found, patchmatch failed to load or compile (/opt/anaconda/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found ect or when testing on python with import-pypatchmatch or whatever the command was it either outputs an error or no output at all which is rediculous for trying to troubleshoot image

github-actions[bot] commented 1 year ago

There has been no activity in this issue for 14 days. If this issue is still being experienced, please reply with an updated confirmation that the issue is still being experienced with the latest release.

Lolagatorade commented 1 year ago

There has been no activity in this issue for 14 days. If this issue is still being experienced, please reply with an updated confirmation that the issue is still being experienced with the latest release.

Still occuring. errors are seemingly random, sometimes python gives an erorr other times nothing. Same thing with the errors for invokeai can show up other times no. either way patchmatch hasnt been functional on arch for a while now. not sure if its just my system ide love to hear from other manjaro or arch users

python  ✔  3s   base  Python 3.10.9 (main, Mar 1 2023, 18:23:06) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.

from patchmatch import patch_match patchmatch.patch_match: ERROR - patchmatch failed to load or compile (libopencv_gapi.so.406: cannot open shared object file: No such file or directory). patchmatch.patch_match: INFO - Refer to https://invoke-ai.github.io/InvokeAI/installation/060_INSTALL_PATCHMATCH/ for installation instructions.

Kpaiva commented 1 year ago

A workaround that worked for me (Archlinux) is to use the systems libgomp.so instead of the included one. If you want to try it for yourself:

  1. cd <invokeai dir>/.venv/lib/python3.10/site-packages/torch/lib/
  2. Backup libgomp-a34b3233.so.1: mv libgomp-a34b3233.so.1 libgomp-a34b3233.so.1.bkp
  3. Symlink the systems library: ln -s /usr/lib/libgomp.so.1 libgomp-a34b3233.so.1

This also worked for me on Arch. Thank you @B14CK313

hchasens commented 7 months ago

A workaround that worked for me (Archlinux) is to use the systems libgomp.so instead of the included one. If you want to try it for yourself:

  1. cd <invokeai dir>/.venv/lib/python3.10/site-packages/torch/lib/
  2. Backup libgomp-a34b3233.so.1: mv libgomp-a34b3233.so.1 libgomp-a34b3233.so.1.bkp
  3. Symlink the systems library: ln -s /usr/lib/libgomp.so.1 libgomp-a34b3233.so.1

I also had to do this. I wonder if it has to do with the naming schema. Well whatever the case it's working now! Cheers!