AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Deploying DeepSeek Locally with Ollama and vLLM for Private Code Generation

Jean-Benoît Doazan · 365Finds Editorial
Indexed 88,650 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

Piping proprietary source code into third-party cloud APIs is an unacceptable risk for security-conscious development teams. Leaking internal APIs, database schemas, or proprietary business logic into public training pipelines violates compliance mandates and IP boundaries. Running DeepSeek locally solves this problem completely: code never leaves your local workstation or private intranet, network traffic remains air-gapped, and your IP stays yours.

At 365Finds, we evaluate AI deployment architectures based on operational practicality rather than hype. The open-weight releases from DeepSeek—specifically DeepSeek-Coder-V2 and DeepSeek-R1 distilled variants—provide code completion, debugging, and refactoring performance that rivals proprietary hosted services. But self-hosting them presents a fundamental fork in the road: should you deploy with Ollama or vLLM?

The answer depends entirely on your operational topology. If you are an individual engineer on a single workstation or laptop, Ollama is the undisputed choice for friction-free setup and GGUF quantization. If you are building a shared internal coding assistant for an engineering squad on a multi-GPU server, vLLM is vastly superior thanks to PagedAttention, continuous batching, and tensor parallelism.


Model Selection: Matching Hardware to Real-World Code Generation

Before running an engine, choosing the right model size prevents out-of-memory crashes and unacceptably sluggish generation speeds. Deploying a full 671B parameter DeepSeek model requires enterprise-grade hardware (such as 8x 80GB H100 or A100 GPUs). For local and private developer setups, 365Finds recommends two primary targets:

Model VariantArchitectureRecommended VRAM / RAMPrimary Use Case
DeepSeek-Coder-V2 Lite (16B)Mixture of Experts (2.4B active)12GB – 16GB (Q4 / FP8)Real-time autocomplete; inline code edits; daily scripting
DeepSeek-R1 Distill Qwen (14B)Dense Reasoning Model12GB – 16GB (Q4 / Q5)Complex debugging; architecture design; code review
DeepSeek-R1 Distill Qwen (32B)Dense Reasoning Model24GB – 32GB (Q4 / FP8)Deep algorithmic generation; test suite synthesis
DeepSeek-Coder-V2 (236B)Mixture of Experts (21B active)140GB+ (Multi-GPU / AWQ)Team-wide general code intelligence server

365Finds strongly advises against using reasoning models like DeepSeek-R1 for real-time tab autocomplete. Reasoning models generate deliberate <think> reasoning traces before writing code. Waiting five seconds for a thinking block while typing an argument destroys developer flow. Use DeepSeek-Coder-V2 Lite for autocomplete, and reserve DeepSeek-R1 for chat panels and explicit code analysis tasks.


Route 1: Local Developer Workstation Deployment with Ollama

Ollama wraps llama.cpp into a clean background daemon that automatically distributes GGUF quantized model layers across available GPU VRAM and system memory. It is the best choice for Apple Silicon Macs and single-GPU Linux or Windows desktops.

1. Install and Start Ollama

Download and install Ollama for your operating system from the official website. Once installed, start the local daemon.

On Linux or macOS terminal:

# Verify the daemon is running
ollama --version

2. Pull and Run DeepSeek Models

To run DeepSeek-Coder-V2 Lite for daily coding tasks:

ollama run deepseek-coder-v2:16b

To pull DeepSeek-R1 14B for reasoning and architectural reviews:

ollama pull deepseek-r1:14b

Ollama automatically downloads the optimized 4-bit quantized GGUF weights and exposes an OpenAI-compatible HTTP endpoint at http://localhost:11434/v1.

3. Exposing Ollama on an Internal Private Network

If you run Ollama on a dedicated office workstation and want colleagues on the local subnet to share it, bind Ollama to the local network interface rather than localhost:

# Linux systemd override or shell environment
export OLLAMA_HOST="0.0.0.0:11434"
ollama serve

Route 2: High-Throughput Team Server Deployment with vLLM

When multiple developers query a single GPU server simultaneously, Ollama queues requests sequentially, causing massive latency spikes. vLLM solves this by implementing PagedAttention and continuous request batching, maintaining high token generation speeds under heavy concurrency.

1. Environment Setup

vLLM requires a Linux environment with NVIDIA CUDA (compute capability 7.0 or higher) or ROCm support.

# Create a clean virtual environment
python3 -m venv vllm-env
source vllm-env/bin/activate

# Install vLLM
pip install --upgrade pip
pip install vllm

2. Launching DeepSeek-Coder-V2 Lite on a Single GPU

For a dedicated server with a single RTX 3090, RTX 4090, or A5000 (24GB VRAM):

vllm serve deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct \
    --trust-remote-code \
    --tensor-parallel-size 1 \
    --max-model-len 16384 \
    --gpu-memory-utilization 0.90 \
    --port 8000

Key configuration flags explained:

3. Launching DeepSeek-R1 Distill on Multi-GPU Nodes

If hosting the heavier DeepSeek-R1-Distill-Qwen-32B across two 24GB GPUs (such as 2x RTX 4090):

vllm serve deepseek-ai/DeepSeek-R1-Distill-Qwen-32B \
    --tensor-parallel-size 2 \
    --max-model-len 16384 \
    --port 8000

vLLM serves an OpenAI-compatible API at http://localhost:8000/v1.


Connecting Local DeepSeek to VS Code and JetBrains via Continue

Having a local inference server is useless without seamless IDE integration. The open-source Continue extension connects VS Code and JetBrains IDEs directly to local Ollama and vLLM endpoints.

  1. Install the Continue extension from the VS Code Marketplace or JetBrains Plugins repository.
  2. Open the Continue configuration file (~/.continue/config.json or config.yaml).
  3. Configure the dual-model setup: DeepSeek-Coder-V2 for tab autocomplete and DeepSeek-R1 or DeepSeek-Coder-V2 for the chat sidebar.

Configuration Example (~/.continue/config.json):

{
  "models": [
    {
      "title": "DeepSeek-Coder-V2 (Local Chat)",
      "provider": "ollama",
      "model": "deepseek-coder-v2:16b",
      "apiBase": "http://localhost:11434"
    },
    {
      "title": "DeepSeek-R1 14B (Reasoning Chat)",
      "provider": "ollama",
      "model": "deepseek-r1:14b",
      "apiBase": "http://localhost:11434"
    },
    {
      "title": "DeepSeek vLLM Server (Team)",
      "provider": "openai",
      "model": "deepseek-ai/DeepSeek-Coder-V2-Lite-Instruct",
      "apiBase": "http://192.168.1.100:8000/v1",
      "apiKey": "EMPTY"
    }
  ],
  "tabAutocompleteModel": {
    "title": "DeepSeek-Coder Autocomplete",
    "provider": "ollama",
    "model": "deepseek-coder-v2:16b",
    "apiBase": "http://localhost:11434"
  }
}

365Finds Critical Assessment: Privacy Verification and Pitfalls

At 365Finds, we insist that local deployment must be verified rather than assumed secure. Common configuration oversights frequently compromise privacy:

  1. Ollama Network Exposure Has Zero Authentication: By default, Ollama provides no authentication layer. If you bind OLLAMA_HOST="0.0.0.0" on an unsegmented office network, anyone on that Wi-Fi can run inference, download models, or delete existing weights. If exposing it outside 127.0.0.1, put it behind an Nginx or Caddy reverse proxy with HTTP Basic Auth or Bearer tokens.
  2. IDE Extension Telemetry Leakage: While your model runs locally, your IDE extension might still phone home. Inside VS Code, set "telemetry.telemetryLevel": "off". In Continue, set "allowAnonymousTelemetry": false in your configuration to block prompt metrics from being transmitted to third-party tracking endpoints.
  3. Context Length VRAM Crashes in vLLM: Setting --max-model-len 65536 on consumer GPUs triggers immediate PyTorch CUDA out-of-memory errors because the KV cache allocation scales linearly with context length and batch size. Limit local context windows to 16,384 tokens unless using FP8 KV caching (--kv-cache-dtype fp8).
  4. Air-Gapped Operation: Once weights are cached in ~/.ollama/models or Hugging Face cache directories, cut WAN access completely on the host. Both Ollama and vLLM execute entirely offline without requiring license checks or external heartbeat pings.

References