351 words
2 minutes
Running DeepSeek Locally
2025-02-07

Background#

Around the 2025 New Year, DeepSeek released the R1 model, pitched against OpenAI’s o1, along with a path for running it locally. This post walks through that local deployment.

Deployment#

I deployed it on a Mac mini with the following specs:

  • Chip: M4
  • Memory: 16GB
  • Storage: 512GB

The main tools involved:

  • Docker: containerized deployment
  • Ollama: serving the model locally
  • Open Web UI: a self-hosted UI

Installing Docker#

From the official site#

Docker website

Via Homebrew#

Terminal window
brew install docker

Verify#

Terminal window
docker --version

Installing Ollama#

From the official site#

Ollama website

Via Homebrew#

Terminal window
brew install ollama

Verify#

Terminal window
ollama --version

Configuration#

  1. Create and edit the config file
Terminal window
nano ~/Library/LaunchAgents/com.user.ollama.service.plist
  1. Add the following content: the config below defines the service-style launch and sets up CORS, so access from other devices on the LAN is allowed
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.ollama.service</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/ollama</string>
<string>serve</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/ollama.err</string>
<key>StandardOutPath</key>
<string>/tmp/ollama.out</string>
<key>EnvironmentVariables</key>
<dict>
<key>OLLAMA_HOST</key>
<string>0.0.0.0</string>
<key>Ollama_ORIGINS</key>
<string>*</string>
</dict>
</dict>
</plist>
  1. Set permissions and start the service
Terminal window
chmod 644 ~/Library/LaunchAgents/com.user.ollama.service.plist
launchctl load ~/Library/LaunchAgents/com.user.ollama.service.plist

Installing Open Web UI#

Here’s the docker-compose.yml:

services:
open-webui:
image: ghcr.io/open-webui/open-webui:main
restart: always
ports:
- "3000:8080"
volumes:
- ./open-webui:/app/backend/data
watchtower:
image: containrrr/watchtower
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --interval 300 open-webui
depends_on:
- open-webui

Start#

Terminal window
docker-compose up -d

Verify#

Terminal window
docker-compose ps

Installing the Model#

If everything above went through, open http://localhost:3000 in a browser and you’ll see the Open Web UI interface.

Point Open Web UI at Ollama#

Open Open Web UI, click your avatar in the bottom-left corner to enter settings, choose Admin Settings -> External Connections, and under the Ollama API section fill in the address http://host.docker.internal:11434. Make sure the toggle is enabled, click Save, and you’re done.

Pull the Model#

Head to the Ollama model library, search for deepseek, pick deepseek-r1, and choose a model size that matches your hardware. I went with the 14b variant. Copy the command it shows and run it in a terminal to pull the model.

Terminal window
ollama pull deepseek-r1:14b
NOTE

Pick a model size that fits your machine’s available memory. A handy rule of thumb: your available memory needs to be larger than the disk space the model occupies. Note: this compares machine memory against disk storage usage

alt text

Test the Model#

In Open Web UI, select the model in the top-left corner, choose deepseek-r1, and try a conversation.

alt text

alt text

Running DeepSeek Locally
https://www.mihouo.com/en/posts/tool-share/deepseek-local-deploy/
Author
Jia
Published at
2025-02-07
License
CC BY-NC-SA 4.0