A step-by-step guide to set up local AI tools on Mac, including detailed instructions for installing and configuring Ollama, Homebrew, Conda, Open WebUI, and Stable Diffusion.
Install the Ollama tool to run AI models like Llama locally. This foundational step ensures the required software environment is set up.
-
Download and Install Ollama
- Visit the official website to download: ollama.com
-
Run Ollama
-
Open Terminal and execute the following command to start a model:
ollama run llama3.2:3b
-
-
Test Ollama
-
Enter a message in the terminal to test functionality:
Hello!
-
Install Homebrew, a package manager for macOS that simplifies the installation of required software.
-
Install Homebrew
Run the following command in Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Add Homebrew to Your System Path
Append Homebrew's path to your shell profile (e.g.,.zprofile
for Zsh):echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
-
Restart Terminal and Verify Installation
-
Close and reopen Terminal.
-
Run this command to verify Homebrew installation:
brew --help
-
Obtain the Conda installer suitable for your system to manage Python environments and dependencies.
-
Download Miniforge3
- Get the installer for macOS (ARM64):
Miniforge3 for MacOS ARM64
- Get the installer for macOS (ARM64):
-
Run the Installer
-
Navigate to the download directory and execute the script:
cd Downloads sh Miniforge3-MacOSX-arm64.sh
-
-
Activate Conda
-
Add Conda to your shell by running:
eval "$($(conda info --base)/bin/conda shell.zsh hook)"
-
-
Verify Installation
-
Run this command to check Python version:
python --version
-
Launch the WebUI to provide a local interaction interface and add required AI models to extend WebuUI functionality.
-
Install Open WebUI Use
pip
to install Open WebUI:pip install open-webui
-
Start Open WebUI
open-webui serve
-
Access the Interface
- Open your browser and navigate to:
localhost:8080
. - Complete the registration process.
- Open your browser and navigate to:
Download model files to serve as the foundation for image generation.
-
Create a Conda Environment
- Open a new terminal
eval "$($(which conda) shell.zsh hook)" conda create -n stable python=3.10.6 conda activate stable
-
Clone the Stable Diffusion Repository
-
Create a working directory and clone the repository:
mkdir stablediff cd stablediff git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git cd stable-diffusion-webui
-
-
Download the Stable Diffusion Model
-
Get the model file (e.g., v1.5 Model) and place it in:
models/Stable-diffusion
-
-
Run the WebUI Script
./webui.sh
-
Generate Images
- Open the interface in a browser, select the model file, and enter prompts to generate images.
Enable API mode to control Stable Diffusion via WebUI.
Start Stable Diffusion with API Mode
-
Start Stable Diffusion with API Mode
./webui.sh --listen --api
-
Configure Open WebUI
-
Go to Settings > Admin Settings > Images.
-
Set the Image Generation Engine to AUTOMATIC1111.
-
Input the following URL:
http://127.0.0.1:7860
-
-
Test the Connection
- In Open WebUI, click Refresh under Image Settings and save the configuration.
To simplify the startup and configuration process for Open WebUI and Stable Diffusion, use the provided AI_Start.sh
script. This script automates:
- Starting Open WebUI and initializing the Conda environment.
- Guiding users through necessary configurations (e.g., setting up the image generation engine).
- Launching the Stable Diffusion WebUI and enabling API mode.
-
Download the Script
PlaceAI_Start.sh
in your home directory or another convenient location. -
Grant Execute Permission
chmod +x AI_Start.sh
-
Run the Script
./AI_Start.sh
-
Follow the Prompts
- The script will prompt you at key steps, such as configuring the image generation engine in Open WebUI.
- Complete each step and press Enter to proceed.
- Automated Conda Initialization: Ensures dependencies run in the correct environment.
- Multi-Window Management: Runs Open WebUI in a new terminal window for easier process handling.
- Stable Diffusion Automation: Eliminates manual steps for starting the WebUI and enabling API.
-
Generate Images from Open WebUI
- Enter a text prompt and click the Image Icon under the response.
-
Verify Results
- Wait for the image to be generated and check the output.
This guide is designed to help anyone set up a fully functional local AI environment on macOS. Contributions and improvements are free to open a pull request! 😻😻