
We recommend you use attention slicing to reduce memory pressure during inference and prevent swapping, particularly if your computer has lass than 64 GB of system RAM, or if you generate images at non-standard resolutions larger than 512 × 512 pixels. The system will automatically swap if it needs to, but performance will degrade significantly when it does. M1/M2 performance is very sensitive to memory pressure.


Image = pipe(prompt).images Performance Recommendations # Results match those from the CPU device after the warmup pass. Prompt = "a photo of an astronaut riding a horse on mars" # First-time "warmup" pass (see explanation above) # Recommended if your computer has < 64 GB of RAM Pipe = om_pretrained( "runwayml/stable-diffusion-v1-5") You only need to do this pass once, and it’s ok to use just one inference step and discard the result.Ĭopied # make sure you're logged in with `huggingface-cli login` from diffusers import StableDiffusionPipeline This is a temporary workaround for a weird issue we have detected: the first inference pass produces slightly different results than subsequent ones. We recommend to “prime” the pipeline using an additional one-time pass through it. The snippet below demonstrates how to use the mps backend using the familiar to() interface to move the Stable Diffusion pipeline to your M1 or M2 device. You can install it with pip or conda using the instructions in.

🤗 Diffusers is compatible with Apple silicon for Stable Diffusion inference, using the PyTorch mps device. There’s another support post on this topic which is more informing, as Andy from Affinity explained that they weren’t currently able to get Nvidia cards to work reliably, as the hardware and drivers are flakey.How to use Stable Diffusion in Apple Silicon (M1/M2)

There are older AMD cards which support metal that aren’t on that list either, such as the SAPPHIRE Radeon HD 7950 Mac Edition. The AMD cards belonging to “family 2” are much more recent. That doesn’t surprise me that Nvidia cards aren’t part of “family 2” as Apple stopped dealing with Nvidia around 2012/2013. I don't know what specifically the Affinity apps need to provide metal compute acceleration, but clearly Apple has not been spending the time to make nVidia cards work with the full feature set of Metal. It looks like Metal support is divided into two basic GPU "families" by Apple right now: "family 1" offers less functionality than "family 2".įrom what little documentation I have been able to scrounge up, there are NO nVidia cards in "family 2":
