Running Ollama on a VPS: Step by Step

Running AI models locally is becoming more popular, especially with tools like Ollama. Instead of relying on cloud APIs, you can run powerful AI models directly on your own server.

If you have a VPS, you can use it to host Ollama and run models like Llama, Mistral, or other open-source AI models.

In this guide, we will walk you through running Ollama on a VPS step by step, including installation, configuration, and optimization.


What is Ollama?

Ollama is a tool that allows you to run large language models locally.

It simplifies:

  • Model downloads
  • Model execution
  • API access

Why Run Ollama on a VPS?

Benefits:

1. Full Control

You control data and privacy.

2. No API Costs

No per-request charges.

3. Custom Models

Run your own models.


VPS Requirements

Minimum:

  • 4GB RAM
  • 2 CPU cores

Recommended:

  • 8GB+ RAM
  • GPU support

Step 1: Connect to VPS

ssh user@your-server-ip

Step 2: Update Server

sudo apt update && sudo apt upgrade -y

Step 3: Install Ollama

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

Step 4: Verify Installation

ollama --version

Step 5: Run First Model

ollama run llama2

Step 6: Access Ollama API

Default:

  • Port 11434

Test:

curl http://localhost:11434

Step 7: Run in Background

Use:

ollama serve

Step 8: Open Firewall Port

sudo ufw allow 11434

Step 9: Access Remotely

Visit:

http://your-ip:11434

Step 10: Optimize Performance

  • Use smaller models
  • Increase RAM
  • Enable swap

Common Issues

Out of Memory

Use smaller model.

Slow Performance

Upgrade VPS.


Best Practices

  • Monitor usage
  • Secure API
  • Use reverse proxy

FAQs

Can I run Ollama without GPU?

Yes.

Is it free?

Yes.


Final Thoughts

Running Ollama on a VPS is a powerful way to host your own AI models. It gives you full control, better privacy, and no dependency on external APIs.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *