How to Run DeepSeek-R1 Locally with Ollama: The Complete Developer Setup

How to Run DeepSeek-R1 Locally with Ollama: The Complete Developer Setup


Disclosure: This article may contain affiliate links. We only recommend products we believe in.

DeepSeek-R1 has shifted the balance for local AI development. By open-sourcing a 671-billion parameter reasoning model alongside highly optimized “distilled” versions (using Qwen and Llama architectures), developers can now run complex reasoning and self-correcting code assistants entirely on consumer hardware.

If you want to run these reasoning models locally with zero data leakage, here is the complete developer setup.

TL;DR: Install Ollama, run ollama run deepseek-r1:8b (for 16GB RAM machines) or ollama run deepseek-r1:14b (for 32GB RAM machines), and point your IDE (Cursor, VS Code, or Roo Code) to http://localhost:11434. Read on for exact hardware sizing and configuration tweaks.


Understanding DeepSeek-R1 Sizing & Sizing Matrix

The full DeepSeek-R1 model requires 671 billion parameters (about 720 GB of storage) and a cluster of high-end enterprise GPUs (like 8x H100s). For local use, DeepSeek released distilled models fine-tuned on R1’s reasoning traces.

Here is how the distilled models size up against typical consumer developer hardware:

Model TagBase ArchitectureMin VRAMMin System RAMRecommended HardwareBest Use Case
deepseek-r1:1.5bQwen-2.5-Math2 GB8 GBStandard laptops (MacBook Air, Intel Core i5)Ultra-fast simple completions
deepseek-r1:7bQwen-2.56 GB16 GBGaming laptops, entry M-series MacsBudget coding companion
deepseek-r1:8bLlama-3.16 GB16 GBRTX 3060/4060, Apple M1/M2/M3 (16GB)Balanced code & logic
deepseek-r1:14bQwen-2.510 GB32 GBRTX 4070/4080, Apple M-series (24GB+)Sweet Spot: Advanced reasoning
deepseek-r1:32bQwen-2.520 GB48 GBDual RTX 3090/4090, Mac Studio (64GB)Deep refactoring & logic
deepseek-r1:70bLlama-3.140 GB64 GBDual RTX 4090 (48GB VRAM total)Commercial API competitor

Tip: For coding tasks, the 14B and 32B parameters distilled models represent the sweet spot, offering robust reasoning, multi-file comprehension, and logical verification without requiring datacenter hardware.


Step 1: Installing Ollama and Downloading the Model

If you don’t already have Ollama installed, run the official installer command in your terminal:

# macOS or Linux
curl -fsSL https://ollama.com/install.sh | sh

(Windows users can download the installer executable directly from Ollama’s official website).

Once installed, download and run your chosen distilled model size. For a standard 16GB machine, we recommend the 8B model:

ollama run deepseek-r1:8b

During the first run, Ollama will download the model weights (approx. 4.7 GB for the 8B model). Once complete, you will see a chat prompt. You can test the reasoning capabilities by asking a coding logic problem:

>>> Write a python generator that yields Fibonacci numbers but stops if the number is prime.

You will notice the model outputting its reasoning process enclosed in <think>...</think> tags before rendering the final python script.


Step 2: Integrating DeepSeek-R1 with VS Code (Roo Code)

VS Code extensions like Roo Code (formerly Roo Cline) are built specifically to handle agentic workflows. Hooking up local DeepSeek-R1 gives Roo Code a powerful local brain:

  1. Open VS Code and install the Roo Code extension.
  2. Open the Roo Code settings panel (gear icon).
  3. Under API Provider, select Ollama.
  4. Set the Ollama Base URL to http://localhost:11434.
  5. Under Model ID, type or select the exact tag you downloaded, e.g., deepseek-r1:8b or deepseek-r1:14b.
  6. Ensure the Context Window is set to at least 8192 tokens (R1 models support larger context, but local speeds will scale down as context scales up).
  7. Save settings. Roo Code can now execute terminal commands, edit local files, and debug code using local reasoning.

Step 3: Integrating DeepSeek-R1 with Cursor

To use local DeepSeek-R1 inside Cursor as your chat or inline editor model:

  1. Open Cursor and head to Settings (Cmd+, or Ctrl+,) ➡️ Models.
  2. Click Add Model under the model listing.
  3. Enter openai/deepseek-r1:8b (or whichever tag you are running).
  4. Turn on your new model and turn off the other models if you wish to enforce local-only usage.
  5. Scroll down to OpenAI API Key configuration.
  6. Toggle the Override OpenAI Base URL option and enter: http://localhost:11434/v1
  7. In the API Key field, you can enter any dummy text (e.g. ollama), as local Ollama calls do not require authentication.
  8. Save settings and open the Chat sidebar. Select your added model from the dropdown.

Essential Configuration Tweaks for Reasoning Models

To get the best performance from reasoning models like DeepSeek-R1, you need to adjust a few parameters that differ from standard LLMs:

1. Maintain Low Temperature

Reasoning models perform their own search-like exploration during generation. Setting the temperature too high causes the model’s chain-of-thought to diverge or loop indefinitely.

  • Recommended Temperature: 0.0 (for math, security audits, and strict code syntax) or 0.6 (for general software architecture design).

2. Keep the <think> Tags

Many IDE integrations attempt to parse or strip <think> tags because they look like HTML. However, stripping them mid-generation can break the model’s coherence, as the model’s actual answer is dependent on the reasoning traces it just generated. Verify your extension supports “thinking visualization” or lets the traces stream naturally.

3. GPU Offloading (system with dual GPUs)

If you have a dedicated GPU but also integrated graphics, ensure Ollama uses your discrete GPU. You can check which device Ollama is running on by running:

nvidia-smi   # For NVIDIA GPUs

If it is not offloading to the GPU, set the environment variable: OLLAMA_NUM_PARALLEL=1 to optimize VRAM caching.


FAQ: Common Troubleshooting

Why does DeepSeek-R1 loop or repeat itself in chat?

This typically occurs if the temperature is set too high (above 0.7) or if the context window is saturated. Lower the temperature to 0.0 or restart your Ollama model runner to clear the cache.

How do I stop Ollama from running in the background when not in use?

Ollama keeps the model loaded in VRAM for 5 minutes after the last request before unloading it. If you want to force unload it immediately, run:

ollama gc

Can I run DeepSeek-R1 on a standard MacBook?

Yes! Apple Silicon (M1/M2/M3) unified memory makes it exceptionally good at running large local models. A standard 16GB MacBook Air runs the deepseek-r1:8b model at a fast 25+ tokens per second.


For further developer tutorials, check our guides on configuring Roo Code custom modes and API rate-limiting strategies.