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.
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 --versionLinux
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 --versionCommon commands
ollama list # list installed models
ollama run <model_name> # load and run a model
ollama help <command> # display help for a commandExample: 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 informationImporting 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:mainOpen 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'])Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
