Master Ollama: Deploy and Run DeepSeek LLM Locally with Step-by-Step Guide

This article introduces Ollama, an open-source platform for locally running large language models, and walks through installing the software on macOS and Linux, configuring common commands, managing models such as DeepSeek-R1, deploying the Web UI, and using the Python API for interactive inference.

Subtle Storm
Subtle Storm
Subtle Storm
Master Ollama: Deploy and Run DeepSeek LLM Locally with Step-by-Step Guide

Overview

Ollama is an open‑source platform that runs large language models (LLMs) locally. It supports models such as GPT‑2, GPT‑3, LLaMA, T5, BERT, and the DeepSeek‑R1 family, allowing data to stay on the host machine and avoiding cloud latency.

Installation

macOS

Install via Homebrew and verify the installation:

brew install ollama
ollama --version

Linux

Install required packages, download the tarball, extract it, and move the binary to /usr/local/bin:

sudo apt-get install curl tar
curl -LO https://ollama.com/download/ollama-linux.tar.gz
tar -xvzf ollama-linux.tar.gz
sudo mv ollama /usr/local/bin/
ollama --version

Common commands

ollama list               # list installed models
ollama run <model_name>    # load and run a model
ollama help <command>     # display help for a command

Example: run the 1.5 B DeepSeek‑R1 model ollama run deepseek-r1:1.5b The full DeepSeek model is the 671 B version; smaller variants are trimmed.

Hardware requirements

7 B models – 10‑12 GB VRAM, 16 GB RAM – recommended GPU: RTX 3060 (cost‑effective: used RTX 2060 S)

14 B models – 20‑24 GB VRAM, 32 GB RAM – recommended GPU: RTX 3090 (cost‑effective: dual RTX 2080 Ti)

32 B models – 40‑48 GB VRAM, 64 GB RAM – recommended GPU: RTX 4090 (cost‑effective: cloud‑GPU rental)

Model management commands

ollama install <model_name>   # download a model (e.g., ollama install llama)
ollama switch <model_name>    # switch active model (e.g., ollama switch llama)
ollama uninstall <model_name> # remove a model
ollama pull <model_name>      # pull from remote repository
ollama push <model_name>      # push to remote repository
ollama cp <src> <dst>        # copy a model
ollama rm <model_name>       # delete a model
ollama show <model_name>     # display model information

Importing custom models

Prepare a .bin or .pth file and import it with: ollama import --file /path/to/mymodel.pth Verify with ollama list.

Web UI deployment

Install Node.js and npm if needed, then run the Open‑WebUI Docker container. The container exposes a browser interface at http://localhost:3000:

docker run -d -p 3000:8080 \
  --add-host=host.docker.internal:host-gateway \
  -v open-webui:/app/backend/data \
  --name open-webui \
  --restart always \
  ghcr.io/open-webui/open-webui:main

Open a browser to the address above, type a prompt, and view the model’s response.

Python API usage

Install the client library: pip install ollama Example streams responses from DeepSeek‑R1 and prints the total duration:

import ollama

def api_generate(text: str):
    stream = ollama.generate(
        stream=True,
        model='deepseek-r1:1.5b',
        prompt=text,
    )
    for chunk in stream:
        if not chunk['done']:
            print(chunk['response'], end='', flush=True)
        else:
            print()
    print(f"Total duration: {chunk['total_duration']}")

if __name__ == '__main__':
    api_generate('Why is the sky blue?')
    content = ollama.generate(model='deepseek-r1:1.5b', prompt='Why is the sky blue?')
    print(content)

The API also supports non‑streaming calls, temperature adjustment, and token limits, e.g.:

response = ollama.generate(
    model='deepseek-r1:1.5b',
    prompt='What is the capital of China?',
    temperature=0.7,
    max_tokens=100,
)
print(response['response'])
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DeepSeekLarge Language ModelPython APILocal DeploymentOllamaWeb UI
Subtle Storm
Written by

Subtle Storm

The micro era's marvels are boundlessly subtle.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.