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:
Install available package updates:
Install curl, which we will use to download the Ollama installer:
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:
Before executing the script, review its contents:
Press q to exit the viewer.
Run the installation script:
The installer will configure Ollama and, on supported systemd-based distributions, configure its background service.
Once installation is complete, verify that Ollama is available:
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:
A functioning installation should report:
Press q to exit the status display.
If the service exists but is not running, start it:
To configure Ollama to start automatically when your computer boots:
You can also perform both operations with a single command:
Verify that the local Ollama API is responding:
A new installation without downloaded models should return a JSON response containing an empty model list:
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 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:
The output should include an entry for:
You can inspect additional information about the model using:
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 will load the model into available memory and present an interactive prompt.
Enter a question:
The model will generate a response using your computer's computational resources.
Try additional prompts:
You can continue interacting with the model by entering additional prompts.
To exit the interactive session, enter:
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:
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:
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:
Press Ctrl+C to stop monitoring.
Monitoring system memory¶
To check available system memory:
To monitor CPU and memory utilization:
Alternatively, install htop for a more interactive system monitoring experience:
Launch 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:
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:
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¶
List currently loaded models¶
Download another model¶
Run another model¶
Display model information¶
Display model licensing information¶
Unload a model from memory¶
Unloading a model releases the resources associated with its loaded instance without deleting the downloaded model files.
Delete a downloaded model¶
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.
- Verify that your model is installed using
ollama list. - Disconnect your computer from the internet.
- Launch the downloaded model.
- Submit a prompt and verify that a response is generated.
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:
Check whether the executable is available:
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:
Restart the service if necessary:
Review recent service logs:
To monitor service logs in real time:
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:
Try running a smaller model:
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:
If this command fails, verify that the appropriate NVIDIA drivers are installed and functioning.
Review the Ollama service logs for hardware detection errors:
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:
List downloaded models:
Remove models you no longer need:
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.
Related articles¶
- Introduction to On-Premises AI
- What Is a Large Language Model?
- Local AI vs. Cloud AI
- Understanding GPU Memory
- AI Server Hardware
Official references¶
- Ollama website
- Ollama documentation
- Ollama model library
- Ollama GitHub repository
- Llama 3.2 model
- Ubuntu documentation
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.