Install Stable Diffusion XL Locally on MacOS
DALL-E & Midjourney are great but free is better.
Hey yāall!
The more well-known image-generating tools out there are OpenAI (DALL-E) and Midjourney but sadly they arenāt free and so your ability to experiment rapidly is limited by cost. As a fan of open source I naturally wanted to find and use a tool that not only gave similar outcomes but that wasnāt limited by my wallet.
Stable Diffusion is one such tool but it isnāt easy to install if youāre not technical and after helping a few friends put it together I thought it would be useful to share the process, step-by-step, so that you can start designing without limitation.
In addition, Stable Diffusion XL is even more flexible and customizable right out of the box! There are a few other tools like Automatic111 and Comfyanonymous that have decent web-based user interfaces but Iāve found greater success using Fooocus.
So, weāll start there!
ā(-āæ-)ā
First, head to the open source project and youāll find some instructions for installing on MacOS and if youāre technical youāll probably have little trouble getting it to boot.
But, if youāre not, youāre going to have to install a number of additional developer tools that you wonāt be familiar with.
Youāll need to first install PyTorch (above) and then a Package Manager called Anaconda. There are specific instructions based on whether you have an Intel-based Mac or an M1:
Thereās a graphical downloader too which might be easier for folks ā go here.
If youāre doing it via command-line then youāll want to boot up āTerminalā and copy and paste the above code. This will install the latest version of āMiniconda3ā locally on your Mac.
Youāll go through a few prompts (just type āyesā) and youāll work through the installer.
Next, youāll need to install a Developer Tool for Mac, more specifically XCode. You can find this directly on the Mac App Store:
Itās not a small app so it may take a bit of time to download. Take a small break, stand up, get a drink of water, and relax! Staying hydrated is really important!
When that is done youāll need to enable Xcode command-line tools:
Youāll do this via Terminal again like so:
xcode-select āinstall
Letās keep going! Now, weāll install Fooocus into a new directory on your local box so you can get all the power of Stable Diffusion XL on your mac! Through the Terminal youāll clone the repository:
git clone https://github.com/lllyasviel/Fooocus.git
It should look like this:
This command will create a new folder off the root called āFooocusā:
We have pretty much all the external components now. Youāre doing great! A few more command-line inputs and youāre home free. First, make sure youāre doing all of the next commands in the āFooocusā folder ā you can navigate there by typing:
cd Fooocus
You can check if youāre in the right spot via the Terminal) by typing ālsā:
Above you can see I typed ālsā to see where I was and you see the āFooocusā folder below. I then typed ācd Fooocusā and then ālsā again to see the contents of that directory which should seem familiar in your MacOS Finder view.
Weāll now create a new āConda Environmentā on your Mac by typing:
conda env create -f environment.yaml
It should look like this and it may require a few more updates ā just keep typing in āyesā and review the Terms of Service by hitting āReturnā on your keyboard (and holding it down if youād like):
Itāll download what it needs to download to give you the most updated software:
Some of these packages are large so feel free to get more water if you need! š¦
Once this is all done itās time to activate the new environment:
conda activate fooocus
And then install any of the final packages that Fooocus needs to operate:
pip install -r requirements_versions.txt
Enjoy the (installation) show!
When thatās all done you should be able to launch Fooocus and start building! One more command-line prompt and youāre good to go:
python entry_with_update.py
It should look like this in your Terminal:
If that works itāll open a new browser window and will show you the beautiful UI:
You have now successfully installed Stable Diffusion XL on your Mac! You can create an infinite number of work for free! There are quite a few options (click the āAdvancedā button at the bottom) so take your time to learn the features.
For instance, I designed a few fun examples of me in āLord of the Ringsā style garb (or Game of Thrones?) as one of my first tests:
Here are the outputs:
Please let me know if you have any questions or issues (via the comments) and Iāll try my best to help you troubleshoot! Good luck and have fun!
And if this was useful please share this with others! ā(-āæ-)ā
ā Summer
Hey, great write up. thanks
How can we do live stream diffusion from a camera with this?
Thanks for the great tutorial. I succeeded in installing it, and it works. The only thing I miss here is system requirements. I have a M2 Mac with 8 GB memory, it takes almost 2 hours to create 2 small images. If this can't be improved I'm going to delete it.