Live data from Hacker News

Run Stable Diffusion on Your M1 Mac’s GPU

replicate.com

371–380 of 415 posts

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#371

Earlier quoted context omitted.

The answer depends VERY MUCH on RAM. My M1 with 8GB takes 70-90 minutes per image. My M1 Pro with 16GB takes 3 minutes per image.

Hopefully the library is intentionally going very slowly trying to fit in RAM and that's not just your 8GB machine totally falling over.

Sadly, in this case it's the 8GB machine falling over.

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#372
post #351

Is there anyway to keep up with this stuff / beginners guide? I really want to play around with it but it's kinda confusing to me. I don't have an M1 Mac, I have an Intel one with an AMD GPU, not sure if i can run it? don't mind if it's a bit slow, or what is the best way of running it in the cloud? Anything that can product high res for free?

Have you managed to set it up? I might have the same computer as you.

Not yet, I haven't had much time to look into it all yet.

Looks like it's going to be a lot of fun though.

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#373

Earlier quoted context omitted.

JS isn't perfect, but it's so much easier to deal with than Python in these regards.

I've had the exact same issues with the JS ecosystem (ran into a problem where npm wouldn't work but yarn did, still haven't figured out why). Both are easy and reliable with a few months of experience. Both are terrible if you rarely ever use them.

That's probably fair. I've found pyenv/venv/poetry/pipenv/pip/conda/etc more frustrating than ESM/CJS/yarn/npm/PNP/etc, but then I just do a lot less Python stuff than JS these days.

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#375
post #99

Without k-diffusion support, I don't think this replicates Stable Diffusion experience: https://github.com/crowsonkb/k-diffusion Yes, running on M1/M2 (MPS device) was possible with modifications. img2img and inpainting also works. However you'll run into problems when you want k-diffusion sampling or textual inversion support.

stable-diffusion supports k-diffusion just fine on M1. You just have to detach a tensor in to_d() to stop the values exploding to infinity. https://twitter.com/Birchlabs/status/1563622002581184517?s=2...

I've been following your MPS branch and have run it but couldn't address the issue without this explanation. Thank you!

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#377
post #76

Earlier quoted context omitted.

Brilliant, thank you! I just got OP's setup working, but this seems much more user-friendly. Giving it a try now... EDIT: Got it working, with a couple of pre-requisite steps: 0. `rm` the existing `stable-diffusion` repo (assuming you followed OP's original setup) 1. Install `conda`, if you don't already have it: brew install --cask miniconda 2. Install the other build requirements referenced in OP's setup: brew inst…

I had to manually install pytorch for the preload_models.py step to work, because ReduceOp wasn't found. Why even use anaconda if all the dependencies aren't included? Every time I touch an ML project, there's always a python dependency issue. How can people use a tool that's impossible to provide a consistent environment for?

You are completely correct that there are a lot of dependency bugs here, I would just like to pedantically complain that the issue in question is PyTorch supporting MPS, which is basically entirely a C++ dependency issue rather than a Python one. (PyTorch being mostly written in C++ despite having "py" in the name.) And yeah the state of C++ dependency management is pretty bad.

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#378

Earlier quoted context omitted.

> Python is pretty much innocent here. Could not possibly disagree more. https://xkcd.com/1987/ The problem with dependencies is that for very bad reasons people don’t ship them. Someone needs to package SD with a full copy of the Python runtime and every dependency. This should be the default method of distribution. #ShipYourDamnDependencies

Just don't mess up your system. The tutorial linked works perfectly fine in a clean python environment. That XKCD is more about messing up your system by not knowing what you're doing but randomly following shitty tutorials which suggest stuff that collide with each other... Python's only fault in this is that it's a simple language and thus attracts people who aren't software engineers (students and math majors) and…

If your solution is “spend a lot of time learning a lot of rules and make sure you never accidentally do something you shouldn’t” then your solution is fragile and shitty.

You know what’s radically simpler? Shipping your damn dependencies so all any user needs to do is double-click the launcher and it will always work no matter what weird and bad things your user as done. The fact that “keep your system clean” is a thing anyone thinks about ever is a catastrophic failure.

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#379
post #296

Earlier quoted context omitted.

To run stable diffusion at home you have to download the model file, which took the equivalent of tens of thousands of hours spread across cloud provided GPUs. If the model file just vanished from everyone's hard drive one day, and cloud providers installed heuristics to detect and ban image dataset training, retraining the model file would actually take decades for any consumer, even an enthusiast with a dozen power…

You forget how much mark-up cloud providers charge. I trained StyleGAN 2 from scratch using 8x 3090s at home and it took 3 months. It's fine. 240TB is small fish, my homelab is a petabyte and I consider it small.

Just to build my intuition, how long do you think it would take you to train Stabl eDiffusion in your homelab if you dedicated it to that task ? 10 years ? 20 years ? What about GPT-3 ?

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#380
post #76

Magnusviri[0], the original author of the SD M1 repo credited in this article, has merged his fork into the Lstein Stable Diffusion fork. You can now run the Lstein fork[1] with M1 as of a few hours ago. This adds a ton of functionality - GUI, Upscaling & Facial improvements, weighted subprompts etc. This has been a big undertaking over the last few days, and I highly recommend checking it out. See the mac m1 readme…

Brilliant, thank you! I just got OP's setup working, but this seems much more user-friendly. Giving it a try now... EDIT: Got it working, with a couple of pre-requisite steps: 0. `rm` the existing `stable-diffusion` repo (assuming you followed OP's original setup) 1. Install `conda`, if you don't already have it: brew install --cask miniconda 2. Install the other build requirements referenced in OP's setup: brew inst…

To get past `pip install -r requirements` I had to muck around with CFLAGS/LDFLAGS because I guess maybe on your system /opt/homebrew/opt/openssl is a symlink to something? On mine it doesn't exist, I just have /opt/homebrew/opt/openssl@1.1 symlinked to /opt/Cellar/somewhere.

The command that finally worked for me:

  python3 -m venv venv
  . venv/bin/activate
  CFLAGS="-I /opt/homebrew/opt/openssl@1.1/include" LDFLAGS="-L /opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/Cellar/openssl@1.1/1.1.1q/lib -lssl -lcrypto" PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig" GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 pip install -r requirements.txt
Post reply on HN