AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Deploy and Run DeepSeek Locally with Ollama and LM Studio for Offline Inference

365Finds Editorial
Indexed 11,430 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Software developers handling proprietary source code and privacy-focused users managing sensitive personal data often cannot risk transmitting queries to third-party cloud APIs. Running DeepSeek models locally delivers complete data sovereignty: zero network telemetry, no per-token billing, and zero reliance on cloud infrastructure.

Both Ollama and LM Studio allow you to run DeepSeek reasoning and coding models entirely on consumer-grade hardware. Once weights are downloaded or sideloaded, both platforms operate in complete offline isolation. This guide explains how to choose the right model size, configure offline inference, launch local OpenAI-compatible developer servers, and apply DeepSeek-recommended inference parameters.


1. Choosing the Right DeepSeek Model for Your Hardware

DeepSeek-R1 is available in its original 671-billion-parameter Mixture-of-Experts (MoE) architecture as well as six distilled dense models based on Qwen 2.5 and Llama 3. While the full 671B model requires enterprise multi-GPU clusters or workstation-class unified memory (such as a 512GB Mac Studio), the distilled models run smoothly on standard laptops and desktops.

For coding-specific workflows, DeepSeek-Coder-V2 also offers a 16B MoE lite model that fits into standard developer workstations.

Model VariantBase ArchitectureDownload Size (Q4 Quantized)Required Memory (VRAM / RAM)Recommended Target Hardware
DeepSeek-R1-Distill-Qwen-1.5BQwen 2.5 Math~1.1 GB4 GB system RAMLightweight laptops; basic CPU inference; edge devices
DeepSeek-R1-Distill-Qwen-7BQwen 2.5 Math~4.7 GB8 GB VRAM or 16 GB RAMMid-range laptops; 8GB GPUs (RTX 3060/4060); M1/M2/M3 Macs
DeepSeek-R1-Distill-Llama-8BLlama 3.1~5.2 GB8 GB VRAM or 16 GB RAMExcellent all-rounder for code review and structured reasoning
DeepSeek-R1-Distill-Qwen-14BQwen 2.5~9.0 GB12–16 GB VRAM or 24 GB RAMEnthusiast GPUs (RTX 4070/4080); 16GB/24GB unified memory Macs
DeepSeek-R1-Distill-Qwen-32BQwen 2.5~20 GB24 GB VRAM or 32–64 GB RAMFlagship GPUs (RTX 3090/4090); 36GB+ Macs; best reasoning sweet spot
DeepSeek-R1-Distill-Llama-70BLlama 3.3~43 GBDual 24 GB GPUs or 64–96 GB RAMMulti-GPU desktop workstations; Mac Studio (64GB–128GB)
DeepSeek-R1 (Full 671B MoE)DeepSeek-V3 Base~404 GB400 GB+ VRAM / High-RAM ClusterEnterprise server nodes; 8x 80GB GPUs; Mac Studio 512GB

For most software engineering tasks, DeepSeek-R1-Distill-Qwen-14B and DeepSeek-R1-Distill-Qwen-32B offer an outstanding balance between rigorous reasoning capabilities and manageable local memory requirements.


2. Deploying DeepSeek Locally with Ollama

Ollama is a lightweight, command-line-driven runtime designed for background service automation, developer terminal workflows, and seamless IDE integration.

Step 1: Install Ollama

Download and install the runtime for your operating system:

Step 2: Download and Run the Model

While connected to the internet, pull and launch your chosen DeepSeek model variant:

# Pull and start an interactive terminal session with the 8B model
ollama run deepseek-r1:8b

# Or deploy the high-accuracy 14B or 32B model
ollama run deepseek-r1:14b
ollama run deepseek-r1:32b

Ollama automatically pulls the quantized model layers, detects available GPU acceleration (NVIDIA CUDA, Apple Metal, or AMD ROCm), allocates VRAM, and opens an interactive prompt.

Step 3: Verify Pure Offline Operation

To verify that no telemetry or network calls occur during inference:

  1. Disconnect your machine from Wi-Fi or unplug your Ethernet cable.
  2. Open a new terminal and invoke:
    ollama run deepseek-r1:8b
    

Because the weights reside entirely in your local cache directory (~/.ollama/models on Linux/macOS or %USERPROFILE%\.ollama\models on Windows), the model loads and generates tokens with zero internet dependency.

Step 4: Transferring Models to Air-Gapped Environments

For secure enterprise networks or air-gapped workstations that never connect to the public internet:

  1. On an internet-connected workstation, run ollama pull deepseek-r1:14b.
  2. Locate the model storage directory defined by OLLAMA_MODELS (or the default ~/.ollama/models folder).
  3. Copy the directory onto an authorized external encrypted drive.
  4. Paste the files into the corresponding directory on your isolated machine and run ollama list to confirm detection.

Step 5: Adjusting Context Window and Memory Settings

By default, Ollama initializes models with a 4,096-token context window. To expand the context window for large codebases or documents:

Step 6: Integrating with Developer Tools and Scripts

Ollama exposes a native REST API on port 11434 as well as OpenAI-compatible endpoints.

Calling the Local API via cURL

curl http://localhost:11434/api/chat -d '{
  "model": "deepseek-r1:8b",
  "messages": [
    {"role": "user", "content": "Explain race conditions in concurrent Go code."}
  ],
  "stream": false
}'

Calling from Python Using the Official Ollama Client

from ollama import chat

response = chat(
    model="deepseek-r1:8b",
    messages=[
        {
            "role": "user",
            "content": "Write a Python script to parse JSON logs without external dependencies.",
        }
    ],
    options={
        "temperature": 0.6,
    },
)

print(response.message.content)

You can also point coding extensions like Continue.dev, Aider, or Claude Code directly to http://localhost:11434/v1 for local code generation inside VS Code or JetBrains IDEs.


3. Deploying DeepSeek Locally with LM Studio

LM Studio provides a clean graphical interface with visual GPU memory allocation sliders, multi-model side-by-side testing, and an integrated local server.

Step 1: Install LM Studio

Download the desktop installer for macOS (Apple Silicon M1–M4), Windows (x64 / Snapdragon ARM), or Linux (AppImage) from the official website. Install and launch the application.

Step 2: Search and Download DeepSeek Models

  1. Click the Discover tab (magnifying glass icon on the left sidebar).
  2. Enter deepseek-r1 or deepseek-coder in the search bar.
  3. LM Studio displays community-quantized GGUF files (such as Q4_K_M, Q5_K_M, or Q8_0).
  4. Check the estimated memory indicator. Select a quantization that matches your available VRAM and click Download.

Step 3: Offline Sideloading (Manual GGUF Import)

If your computer cannot connect to the internet:

  1. Download the DeepSeek .gguf weight file on another machine from Hugging Face.
  2. In LM Studio, click the My Models tab (folder icon).
  3. Drag and drop the .gguf file directly into the LM Studio window, or place it into ~/.cache/lm-studio/models.
  4. LM Studio immediately parses the model architecture and prepares it for execution.

Step 4: Configure Hardware and GPU Layer Offload

  1. Navigate to the AI Chat tab.
  2. At the top of the interface, click Select a model to load and choose your DeepSeek model.
  3. In the right-hand configuration panel under Inference Parameters:
    • GPU Offload: Adjust the slider to offload all model layers to your GPU if your VRAM permits. If your VRAM is limited (e.g., loading a 14B model on an 8GB GPU), offload partial layers to GPU and let system RAM handle the remainder.
    • Context Length: Adjust the context length slider to balance token memory overhead with document capacity.

Step 5: Start the Local Developer Server

To turn LM Studio into a local drop-in replacement for cloud APIs:

  1. Click the Developer tab (code bracket icon on the sidebar).
  2. Toggle the Start Server button.
  3. By default, LM Studio binds to http://localhost:1234/v1.

Connecting with the OpenAI Python SDK

Developers can use standard OpenAI client code without changing business logic:

from openai import OpenAI

# Connect to the local LM Studio server with zero cloud egress
client = OpenAI(
    base_url="http://localhost:1234/v1",
    api_key="lm-studio",  # LM Studio does not require a key by default
)

completion = client.chat.completions.create(
    model="deepseek-r1-distill-qwen-14b",
    messages=[
        {
            "role": "user",
            "content": "Review this SQL schema for potential indexing bottlenecks:\nCREATE TABLE orders (id INT, user_id INT, created_at TIMESTAMP);",
        }
    ],
    temperature=0.6,
)

print(completion.choices[0].message.content)

4. DeepSeek-R1 Recommended Settings & Reasoning Token Handling

DeepSeek-R1 features distinctive reasoning behaviors that require specific operational adjustments to maximize accuracy:

1. Set Temperature to 0.6

The DeepSeek team explicitly recommends keeping sampling temperature between 0.5 and 0.7, with 0.6 as the default benchmark value. Setting temperature too high introduces hallucination and rambling, while setting it near zero suppresses the model's exploratory chain-of-thought process.

2. Avoid Heavy System Prompts

Unlike standard conversational models, DeepSeek-R1's reinforcement learning alignment was optimized with all instructions provided directly inside the user prompt. Providing elaborate system prompts can degrade reasoning patterns or trigger repetitive loops. Place instructions, role definitions, and output format constraints directly into your user query.

3. Handling <think> Tokens in Developer Applications

DeepSeek-R1 outputs its internal step-by-step reasoning inside <think>...</think> tags before delivering its final answer.


5. Ollama vs. LM Studio: Which Should You Choose?

Evaluation DimensionOllamaLM Studio
Primary User InterfaceCLI terminal; background service daemonGraphical desktop application
Best Target AudienceBackend developers; DevOps engineers; CLI power usersPrivacy researchers; UI testers; prompt evaluators
Hardware Fine-TuningAutomatic GPU detection; configured via Modelfile / CLIInteractive visual slider for precise GPU layer offloading
Sideloading GGUF FilesSupported via custom Modelfile FROM ./file.ggufDirect drag-and-drop into desktop interface
Default Base URLhttp://localhost:11434http://localhost:1234/v1
Local Document RAGRequires external tooling or Open WebUI integrationBuilt-in local document ingestion and vector retrieval
IDE Tool IntegrationNative support across Continue, Aider, Claude CodeCompatible via OpenAI-compatible endpoints

Recommendation:


References