Apple Silicon Macs, powered by M1, M2, and subsequent chips, offer incredible performance, especially for compute-heavy tasks like image generation. Fooocus, a popular tool for creative endeavors such as stable diffusion-based workflows, can be installed and run efficiently on these machines. This guide will walk you through the steps to install Fooocus, including setting up Git, Conda, and creating a suitable environment for the software.
Step 1: Installing Git
Git is essential for managing Fooocus code repositories. You can install Git in two ways:
Option 1: Install Git with Xcode
- Install Xcode Command Line Tools via Terminal:
Open a terminal and run:
xcode-select --install
- Install Xcode from the App Store:
Open the App Store, search for Xcode, and download/install it. This will include Git.
Option 2: Install Git Manually
- Download Git:
Visit git-scm.com and download the macOS installer. - Run the Installer:
Follow the on-screen instructions to complete the installation. - Verify the Installation:
After installation, check the version of Git installed by running:
git --version
Step 2: Installing and Setting Up Conda
Conda is a powerful package manager and environment manager, crucial for managing dependencies for Fooocus. For Apple Silicon Macs, Miniconda is the recommended variant of Conda.
Setting Up Python
- Check for an Existing Python Installation:
Open the terminal and run:
python3 --version
Ensure the Python version is 3.10 or newer. If not, install Python from python.org.
- Install Miniconda:
Visit the Miniconda website and download the macOS arm64 installer. - Run the Installer:
Open the downloaded.sh
file in a terminal by navigating to its directory and running:
bash Miniconda3-latest-MacOSX-arm64.sh
Follow the prompts to complete the installation.
- Initialize Conda:
Add Conda to your terminal session by running:
conda init zsh
Restart your terminal to activate Conda.
Verify the Installation
Run the following command to verify Conda is installed:
conda --version
Step 3: Setting Up Fooocus
Fooocus requires a specific environment to ensure all dependencies are compatible.
Cloning the Fooocus Repository
- Clone the Repository:
Open your terminal and run:
git clone https://github.com/lllyasviel/Fooocus.git
- Navigate to the Fooocus Directory:
cd Fooocus
Creating the Environment
- Create a New Conda Environment:
Run the following command:
conda env create -n fooocus python=3.11 -f environment.yaml
This creates a new Conda environment named fooocus
with Python 3.11 using the environment.yaml
file.
- Activate the Environment:
Switch to the newly created environment:
conda activate fooocus
Installing Dependencies
Install the additional required packages:
pip install -r requirements_versions.txt
Step 4: Using Fooocus
With the environment set up, you’re ready to use Fooocus.
Running Fooocus
- Activate the Environment:
Each time you use Fooocus, ensure the environment is active by running:
conda activate fooocus
- Launch Fooocus:
Run the following command:
python entry_with_update.py
- Optional Flags for Improved Performance:
- For better model loading/unloading times on Apple Silicon, use
python entry_with_update.py --enable-smart-memory
- Some M2 users may find performance improvements with:
python entry_with_update.py --disable-offload-from-vram
First-Time Setup
When you run Fooocus for the first time, it will automatically download the Stable Diffusion SDXL models. This process may take some time depending on your internet connection. Once Fooocus finishes starting up, it will automatically open in your browser.
Using Presets
Fooocus supports presets for different styles:
- Anime Edition:
python entry_with_update.py --preset anime
- Realistic Edition:
python entry_with_update.py --preset realistic
Notes for Apple Silicon and Intel Mac Users
Apple Silicon (M1/M2) Users
- Fooocus runs on Apple Silicon Macs using PyTorch MPS device acceleration.
- macOS Catalina or newer is required.
- Due to the lack of a dedicated graphics card, image processing times may be longer than on systems with dedicated GPUs.
- Refer to the Accelerated PyTorch Training on Mac guide for optimizing PyTorch performance.
Intel Mac Users
Fooocus currently does not support Intel-based Macs. The developers note that support for M1/M2 Macs is experimental.
By following these steps, you should have Fooocus installed and ready to use on your Apple Silicon Mac. Happy creating!