Extension not working on Mac M2 Max
*** Error loading script: depthmap_api.py
Traceback (most recent call last):
File "/Users/daniel/stable-diffusion-webui/modules/scripts.py", line 469, in load_scripts
script_module = script_loading.load_module(scriptfile.path)
File "/Users/daniel/stable-diffusion-webui/modules/script_loading.py", line 10, in load_module
module_spec.loader.exec_module(module)
File "
File "/Users/daniel/stable-diffusion-webui/venv/lib/python3.10/site-packages/vispy/ext/cocoapy.py", line 1288, in
I'm seeing the same behaviour w/ Sonoma 14.2.1
In the system frameworks strangely I see a broken link to the /Quartz subdir:
My understanding is that this should be part of the OS frameworks, but I can see no relevant directory to update the link to.
I have this running on a 16" MacBook Pro with an M2 processor and Sonoma 14.2.1.
I only recently obtained this machine and access to local AI/ML tools so my experience is not very deep yet. However, I do have experience writing and troubleshooting software.
Background:
- I have the stable-diffusion-webui installed in my user directory (~) at the moment
- I'm using a Python virtual environment that gets stored in a .venv directory in stable-diffusion-webui
- I installed stable-diffusion-webui using this guide https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Installation-on-Apple-Silicon for a "New install"
- I have a host of other developer tools that are not standard on the system installed - hopefully these don't contribute to the success
- I have a customized webui-user.sh file with these customizations:
export COMMANDLINE_ARGS="--theme dark --skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate"
venv_dir="${install_dir}/${clone_dir}/.venv"
These are not necessary as far as I know, especially the .venv mod. I just want to help anybody else who lands here understand how I got to functional.
It's important to understand that I modified a package outside of stable-diffusion-webui to make this work. If you have other Python code, and you're not using virtual environments of some sort, you may break other things by doing this...or you may accidentally fix them 😂
As described by the accepted answer at stackoverflow ...
"This error is because Big Sur no longer has the OpenGL library nor other system libraries in standard locations in the file system and instead uses a cache. PyOpenGL uses ctypes to try to locate the OpenGL library and it fails to find it."
The correct answer also mentions ...
"So a future version of Python should resolve the problem."
But I wouldn't hold out for this since Python has already had new versions since, and stable-diffusion-webui is built around an older version.
Here's what I did:
- Shut down the webui in the browser and the terminal if you have it running
- Find the correct cocoapy.py - this belongs to the Vispy package that Depth Map uses - based on my install this is the file
~/stable-diffusion-webui/.venv/lib/python3.10/site-packages/vispy/ext/cocoapy.py - Open
cocoapy.pyin your editor of choice - Line 1288 of cocoapy.py looks like this
quartz = cdll.LoadLibrary(util.find_library('quartz')) - I commented the original line 1288 out so that it now looks like this
#quartz = cdll.LoadLibrary(util.find_library('quartz')) - Make a new line below the code at line 1288 and paste this code
quartz = cdll.LoadLibrary(util.find_library('/System/Library/Frameworks/Quartz.framework/Quartz')) - Save the changes to cocoapy.py
- Reload stable-diffusion-webui and you should now have a tab for Depth
I successfully generated a test depth map on an image after I did this.
^ incredible writeup and workaround - editing cocoapy.py in the dependencies worked great for me - thanks @myspoonistoobig !
Some further reading re: library cache that I found helpful: https://forums.developer.apple.com/forums/thread/655588