Skip to content

Running Your First Local Language Model

You do not need a dedicated AI server or expensive enterprise hardware to begin experimenting with artificial intelligence.

In this tutorial, we will install Ollama on a Linux computer, download a language model, and begin interacting with it directly from the command line.

By the end of this guide, you will have a functional local AI environment capable of generating responses without relying on an external AI inference service.

What is Ollama?

Ollama is a software platform that simplifies downloading, managing, and running large language models on local hardware.

Ollama handles many of the complexities associated with model execution, including model storage, hardware acceleration, and memory management.

It provides several useful capabilities:

  • Downloading and managing language models.
  • Running models using CPUs or supported GPUs.
  • Interacting with models through a command-line interface.
  • Providing a local HTTP API for application integration.
  • Supporting multiple model families.
  • Managing model loading and unloading.

Ollama can operate independently or serve as the inference engine behind a web-based interface such as Open WebUI.

Prerequisites

For this tutorial, we recommend the following:

Component Recommended configuration
Operating system Ubuntu 24.04 LTS or a compatible Linux distribution
Processor Modern 64-bit processor
System memory At least 8 GB RAM
Available storage At least 10 GB
GPU Optional
Network Internet access for initial downloads
Permissions Administrative or sudo access

These recommendations are intended for running a relatively small language model with a modest context window.

Larger models may require significantly more system memory, GPU memory, and storage.

A dedicated GPU is not required

Ollama can run compatible language models using your CPU. However, a supported GPU can significantly improve inference performance.

If you are considering purchasing dedicated AI hardware, read our Understanding GPU Memory guide.

Step 1: Prepare your operating system

Before installing Ollama, update your operating system's package index.

On Ubuntu or Debian, execute:

sudo apt update

Install available package updates:

sudo apt upgrade -y

Install curl, which we will use to download the Ollama installer:

sudo apt install -y curl

If the operating system requires a reboot following the updates, restart your computer before continuing.

Step 2: Install Ollama

Ollama provides an installation script for supported Linux systems.

Download the installation script from the official Ollama website:

curl -fsSL https://ollama.com/install.sh -o ollama-install.sh

Before executing the script, review its contents:

less ollama-install.sh

Press q to exit the viewer.

Run the installation script:

sh ollama-install.sh

The installer will configure Ollama and, on supported systemd-based distributions, configure its background service.

Once installation is complete, verify that Ollama is available:

ollama --version

You should see the installed Ollama version.

Other operating systems

Ollama is also available for Windows and macOS.

Visit the official Ollama download page for platform-specific installation instructions.

Step 3: Verify the Ollama service

On Linux systems using systemd, Ollama typically operates as a background service.

Check the service status:

sudo systemctl status ollama

A functioning installation should report:

Active: active (running)

Press q to exit the status display.

If the service exists but is not running, start it:

sudo systemctl start ollama

To configure Ollama to start automatically when your computer boots:

sudo systemctl enable ollama

You can also perform both operations with a single command:

sudo systemctl enable --now ollama

Verify that the local Ollama API is responding:

curl http://localhost:11434/api/tags

A new installation without downloaded models should return a JSON response containing an empty model list:

{
  "models": []
}

Step 4: Select your first language model

Ollama supports a variety of downloadable language models.

For this tutorial, we will use Llama 3.2 with approximately three billion parameters.

This model has relatively modest hardware requirements compared with larger language models, making it a useful starting point for experimenting with local AI.

Some illustrative model options include:

Model Parameters Example use case
Llama 3.2 1B 1 billion Lightweight experimentation
Llama 3.2 3B 3 billion General-purpose experimentation
Qwen 2.5 7B 7 billion General-purpose assistance
Gemma 2 9B 9 billion More demanding language tasks
Qwen 2.5 14B 14 billion More complex workloads

Larger models generally require more computational resources, but parameter count alone does not determine model quality.

Explore available models in the Ollama model library.

Model licensing

Not every downloadable AI model is open source.

Some models are distributed under custom licenses that impose conditions on commercial use, redistribution, or modification.

Always review the applicable model license before deploying a model in a commercial environment.

Step 5: Download your first model

Download the Llama 3.2 three-billion-parameter model:

ollama pull llama3.2:3b

Ollama will download the model files and store them locally.

Depending on your internet connection, this process may take several minutes.

Once the download is complete, list your installed models:

ollama list

The output should include an entry for:

llama3.2:3b

You can inspect additional information about the model using:

ollama show llama3.2:3b

This command displays available information about the model, including its architecture, parameter count, and quantization.

Step 6: Start your first conversation

Launch the model:

ollama run llama3.2:3b

Ollama will load the model into available memory and present an interactive prompt.

Enter a question:

Explain how a computer network works in simple terms.

The model will generate a response using your computer's computational resources.

Try additional prompts:

Explain the difference between RAM and storage.
Write a professional email requesting a meeting with a customer.
Write a Python function that converts Celsius to Fahrenheit.
Explain the advantages and disadvantages of running AI locally.

You can continue interacting with the model by entering additional prompts.

To exit the interactive session, enter:

/bye

Congratulations! You have successfully run your first local large language model.

Step 7: Verify hardware utilization

While the model is running, open a second terminal and execute:

ollama ps

This command displays information about currently loaded models, including their processor allocation.

Depending on your hardware and available memory, the model may be running:

  • Entirely on the CPU.
  • Entirely on a supported GPU.
  • Across both CPU and GPU resources.

Monitoring an NVIDIA GPU

If your computer contains a supported NVIDIA GPU and the appropriate drivers are installed, execute:

nvidia-smi

This command displays information such as:

  • GPU model.
  • Driver version.
  • GPU memory utilization.
  • GPU temperature.
  • Power consumption.
  • Active GPU processes.

To monitor GPU utilization continuously:

watch -n 1 nvidia-smi

Press Ctrl+C to stop monitoring.

Monitoring system memory

To check available system memory:

free -h

To monitor CPU and memory utilization:

top

Alternatively, install htop for a more interactive system monitoring experience:

sudo apt install -y htop

Launch htop:

htop

Step 8: Test the local API

One of the most useful features of Ollama is its local HTTP API.

The API allows other applications to communicate with your language models without requiring an external AI service.

By default, Ollama listens on:

http://localhost:11434

Submit a test request using curl:

curl http://localhost:11434/api/generate \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama3.2:3b",
    "prompt": "What is an on-premises AI server?",
    "stream": false
  }'

Ollama will return a JSON response containing the generated text and additional information about the inference request.

The response will contain fields similar to the following:

{
  "model": "llama3.2:3b",
  "response": "An on-premises AI server is...",
  "done": true
}

The actual response will contain additional metadata, and the generated text will vary.

This API can be used to integrate local AI capabilities into:

  • Custom applications.
  • Internal business systems.
  • Workflow automation platforms.
  • Web-based chat interfaces.
  • Document processing applications.
  • Software development tools.

Do not expose the Ollama API publicly

Ollama's local API does not provide built-in authentication for ordinary local API access.

Do not expose TCP port 11434 directly to the public internet.

Remote access should be implemented using appropriate authentication, network restrictions, and secure transport.

Step 9: Manage your installed models

Ollama provides several commands for managing your local language models.

List installed models

ollama list

List currently loaded models

ollama ps

Download another model

ollama pull qwen2.5:7b

Run another model

ollama run qwen2.5:7b

Display model information

ollama show llama3.2:3b

Display model licensing information

ollama show --license llama3.2:3b

Unload a model from memory

ollama stop llama3.2:3b

Unloading a model releases the resources associated with its loaded instance without deleting the downloaded model files.

Delete a downloaded model

ollama rm llama3.2:3b

Deleting models

The ollama rm command removes the downloaded model from your system.

You will need to download the model again if you want to use it in the future.

Step 10: Test offline operation

One of the advantages of running language models locally is the ability to operate without a continuous internet connection.

Once Ollama and your selected local model have been downloaded, you can test offline operation.

  1. Verify that your model is installed using ollama list.
  2. Disconnect your computer from the internet.
  3. Launch the downloaded model.
  4. Submit a prompt and verify that a response is generated.
ollama run llama3.2:3b

Avoid disconnecting network interfaces if you are administering the computer remotely over SSH.

A successful response demonstrates that the selected model can perform inference locally without an external AI service.

Internet access requirements

Internet access may still be required for downloading models, installing updates, accessing cloud-hosted models, or using applications that integrate with external services.

Local inference does not automatically guarantee that every component of an AI deployment operates offline.

Troubleshooting

Ollama command not found

If you receive the following error:

ollama: command not found

Check whether the executable is available:

command -v ollama

If no executable is found, review the installation output and repeat the installation procedure if necessary.

You may also need to open a new terminal session.

Cannot connect to the Ollama service

Check whether the service is running:

sudo systemctl status ollama

Restart the service if necessary:

sudo systemctl restart ollama

Review recent service logs:

sudo journalctl -u ollama -n 100 --no-pager

To monitor service logs in real time:

sudo journalctl -u ollama -f

Press Ctrl+C to exit.

Model responses are slow

Slow inference can result from several factors:

  • Insufficient GPU memory.
  • CPU-only inference.
  • Limited system memory.
  • Large model size.
  • Long context windows.
  • Other applications consuming system resources.
  • Thermal throttling.

Check the model's processor allocation:

ollama ps

Try running a smaller model:

ollama run llama3.2:1b

If the smaller model performs significantly better, your hardware may be limiting the performance of the larger model.

GPU is not being utilized

For NVIDIA-based systems, verify that the GPU is detected:

nvidia-smi

If this command fails, verify that the appropriate NVIDIA drivers are installed and functioning.

Review the Ollama service logs for hardware detection errors:

sudo journalctl -u ollama -n 100 --no-pager

Not every GPU is supported by every inference engine. Consult the official Ollama hardware compatibility documentation before purchasing or configuring a GPU.

Insufficient memory

If a model fails to load because of insufficient memory, try the following:

  • Close unnecessary applications.
  • Stop other loaded models.
  • Select a smaller model.
  • Select a more heavily quantized model.
  • Reduce the configured context length.
  • Increase available system memory or GPU memory.

Read our Understanding GPU Memory guide for additional information.

Insufficient disk space

Check available disk space:

df -h

List downloaded models:

ollama list

Remove models you no longer need:

ollama rm MODEL_NAME

Replace MODEL_NAME with the name of the model you intend to remove.

Security considerations

Although this tutorial establishes a basic local AI environment, additional configuration is recommended before deploying Ollama in a production or business environment.

Consider the following:

  • Keep your operating system and software updated.
  • Restrict access to the Ollama API.
  • Avoid exposing inference services directly to the internet.
  • Implement authentication for shared AI applications.
  • Review model licensing requirements.
  • Monitor system resource utilization.
  • Establish appropriate data retention policies.
  • Review external integrations for potential data exposure.
  • Implement a backup and recovery strategy.

Language models can also generate inaccurate or fabricated information. Important outputs should be independently verified.

Running an AI model locally provides greater control over your infrastructure, but it does not automatically make the deployment secure, accurate, or compliant with regulatory requirements.

What comes next?

You have now established a basic local AI environment capable of running language models independently of cloud-based inference services.

The next stage is to expand this environment into a more complete AI platform.

Potential next steps include:

  • Installing a web-based chat interface.
  • Configuring GPU acceleration.
  • Experimenting with larger language models.
  • Creating a private document knowledge base.
  • Integrating local AI into existing applications.
  • Configuring secure access for multiple users.
  • Deploying a dedicated AI server.

Open WebUI is one option for providing a browser-based interface to locally hosted language models.

Official references


Prefer a preconfigured AI server?

OnPremLLM provides custom-built, preconfigured AI servers, deployment services, system integration, and professional technical support.

Our documentation is freely available whether you build your own system or purchase one from us.

We handle hardware selection, assembly, software configuration, and deployment so you can focus on using your AI infrastructure rather than building it.

Explore our AI server solutions

Contact us at contact@onpremllm.store to discuss your requirements.