Skip to content

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.

License

Notifications You must be signed in to change notification settings

HowardShih/LocalAI_Mac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

LocalAI_Mac   

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.

Chapter 1: Setting Up Ollama   

Install the Ollama tool to run AI models like Llama locally. This foundational step ensures the required software environment is set up.

  1. Download and Install Ollama

    • Visit the official website to download: ollama.com
  2. Run Ollama

    • Open Terminal and execute the following command to start a model:

      ollama run llama3.2:3b
  3. Test Ollama

    • Enter a message in the terminal to test functionality:

      Hello!
      

Chapter 2: Installing Homebrew

Install Homebrew, a package manager for macOS that simplifies the installation of required software.

  1. Install Homebrew

    Run the following command in Terminal:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. 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
  3. Restart Terminal and Verify Installation

    • Close and reopen Terminal.

    • Run this command to verify Homebrew installation:

      brew --help

Chapter 3: Installing Conda

Obtain the Conda installer suitable for your system to manage Python environments and dependencies.

  1. Download Miniforge3

  2. Run the Installer

    • Navigate to the download directory and execute the script:

      cd Downloads
      sh Miniforge3-MacOSX-arm64.sh
  3. Activate Conda

    • Add Conda to your shell by running:

      eval "$($(conda info --base)/bin/conda shell.zsh hook)"
  4. Verify Installation

    • Run this command to check Python version:

      python --version

Chapter 4: Installing and Running Open WebUI

Launch the WebUI to provide a local interaction interface and add required AI models to extend WebuUI functionality.

  1. Install Open WebUI     Use pip to install Open WebUI:

    pip install open-webui
  2. Start Open WebUI

    open-webui serve
  3. Access the Interface

    • Open your browser and navigate to: localhost:8080.
    • Complete the registration process.

Chapter 5: Setting Up Stable Diffusion

Download model files to serve as the foundation for image generation.

  1. 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  
  2. 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
  3. Download the Stable Diffusion Model

    • Get the model file (e.g., v1.5 Model) and place it in:

      models/Stable-diffusion  
      
  4. Run the WebUI Script

    ./webui.sh
  5. Generate Images

    • Open the interface in a browser, select the model file, and enter prompts to generate images.

Chapter 6: Linking Stable Diffusion to Open WebUI

Enable API mode to control Stable Diffusion via WebUI.

Start Stable Diffusion with API Mode

  1. Start Stable Diffusion with API Mode

    ./webui.sh --listen --api
  2. 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
      
  3. Test the Connection

    • In Open WebUI, click Refresh under Image Settings and save the configuration.

Chapter 7: Automating Setup with AI_Start.sh

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.

Instructions

  1. Download the Script
    Place AI_Start.sh in your home directory or another convenient location.

  2. Grant Execute Permission

    chmod +x AI_Start.sh
  3. Run the Script

    ./AI_Start.sh
  4. 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.

Script Details

  • 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.

Final Testing

  1. Generate Images from Open WebUI

    • Enter a text prompt and click the Image Icon under the response.
  2. 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! 😻😻

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages