InvokeAI: [bug]: patchmatch failed to load or compile

Is there an existing issue for this?

  • I have searched the existing issues

OS

macOS

GPU

mps

VRAM

M1 Pro with 8C CPU, 14C GPU, 32GB unified memory

What version did you experience this issue on?

3.0.0 beta 3 (and earlier)

What happened?

I have installed brew and opencv but everytime i run invoke i get the error saying patchmatch failed to load or compile.

I’ve tried running the make clean && make command as well but that only provided the below errors in the screenshot.

I saw another thread suggesting to go into the makefile and change the opencv to opencv4 #1893 but that didn’t help fix my issue either. So i’m totally stumped on how to get patchmatch to work?

Screenshots

`Generate images with a browser-based interface

patchmatch.patch_match: INFO - Compiling and loading c extensions from “/Users/kurisu/invokeai/.venv/lib/python3.10/site-packages/patchmatch”. patchmatch.patch_match: ERROR - patchmatch failed to load or compile (Command ‘make clean && make’ returned non-zero exit status 2.). patchmatch.patch_match: INFO - Refer to https://invoke-ai.github.io/InvokeAI/installation/060_INSTALL_PATCHMATCH/ for installation instructions.`

252121506-4ab1beff-5574-49a7-94da-4e9c793d3e10

Additional context

No response

Contact Details

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 32 (3 by maintainers)

Most upvoted comments

@icpryde I also encountered the same problem. I can’t compile patchmatch after installing opencv with macport.

Finally, I downloaded the opencv source code, compiled the relevant dynamic library, and then successfully compiled the libpatchmatch.so.

Compiling opencv is very time-consuming. If you want to skip this step, you can download the file I provided. patchmatch.zip (Suitable for M1/M2)

Copy the “lib, opencv4, Makefile” in the package I provided to .venv/lib/python3.9/site-packages/patchmatch, Modify the Makefile file to line 23 and replace the path after “-rpath,” with your absolute path.

After starting the invoke, it will be automatically compiled, but the following message will appear. I don’t know what’s wrong, but it can be ignored. Patchmatch can work normally.

Class CaptureDelegate is implemented in both /Volumes/SOFT/Develop/Tool/StableDiffusion/InvokeAI/venv/lib/python3.9/site-packages/cv2/cv2.abi3.so (0x17d04e5e0) and /Volumes/SOFT/Develop/Tool/StableDiffusion/InvokeAI/venv/lib/python3.9/site-packages/patchmatch/lib/libopencv_videoio.4.7.0.dylib (0x17f57c880). One of the two will be used. Which one is undefined.

@icpryde Maybe it’s because foreign dylib doesn’t have permission. Try this command.

xattr -rd com.apple.quarantine /Users/kurisu/invokeai/.venv/lib/python3.10/site-packages/patchmatch/lib

Oh guys, I think I found a way better solution. On my system, there was no pkg-config installed (which the Makefile uses to try to find opencv). So a simple brew install pkg-config and make clean; make and everything was working! Using MacOS 14.2. Probably thats a new thing with newer MacOS versions?

Maybe worth an addition in the Readme if this works for others as well @hipsterusername? I’m glad to make a MR if anybody can confirm!