Lesson 3.1: Installing Ollama (Cross-Platform Setup)
Objective:
Set up Ollama on your local machine to run large language models (LLMs) like Mistral or LLaMA offline, with no API dependencies.
What is Ollama?
Ollama is an open-source tool designed to run LLMs locally on your computer. It supports multiple platforms and allows you to download, manage, and interact with language models directly, ensuring privacy and eliminating API costs.
Prerequisites:
-
A computer running one of the supported operating systems: Windows, macOS, or Linux.
-
Basic familiarity with using the terminal or command prompt.
-
Internet connection for initial installation and downloading models.
Step 1: Download and Install Ollama
For macOS:
-
Open the Terminal.
-
Install Ollama using Homebrew (if Homebrew is installed):
brew install ollama -
If Homebrew is not installed, install it first:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -
Alternatively, download the Ollama installer from the official website and follow the installation instructions.
For Windows:
-
Download the Windows installer from the Ollama official site.
-
Run the
.exeinstaller and follow the setup wizard. -
After installation, open Command Prompt or PowerShell.
-
Verify installation by running:
ollama --version
For Linux:
-
Ollama provides binaries for Linux or you can build from source.
-
Download the latest Linux release from the Ollama GitHub releases page or official website.
-
Extract the archive and move the executable to
/usr/local/binor a directory in your PATH:tar -xzf ollama-linux.tar.gz sudo mv ollama /usr/local/bin/ -
Verify installation:
ollama --version
Step 2: Verify Installation
-
Open your terminal or command prompt.
-
Run:
ollama --help -
You should see usage instructions and a list of available commands.
Step 3: Set Up Ollama Configuration (Optional)
-
Ollama stores configurations and downloaded models in a default directory.
-
You can customize settings via environment variables or config files if needed.
-
For most users, the default setup works out of the box.
Step 4: Pull Your First Model
-
Ollama allows you to download pre-trained models. For example, to pull the Mistral model:
ollama pull mistral -
The model will download and be available locally.
Step 5: Run and Test the Model
-
Test the model by running:
ollama run mistral -
You should enter an interactive prompt where you can type questions or commands, and the model will respond.
Troubleshooting Tips:
-
Command not found: Ensure Ollama’s executable path is correctly added to your system PATH.
-
Permissions issues: On Linux/macOS, use
chmod +x ollamato make it executable. -
Network issues during model download: Check your internet connection and firewall settings.
-
Model not found error: Verify the model name spelling or check available models via
ollama list.
Summary:
By completing this lesson, you have installed Ollama on your machine, pulled a language model, and tested it locally. This setup forms the foundation for running your AI agent without relying on external APIs.
42
