200字
What are the required specifications and deployment steps for deploying DeepSeek on a VPS server?
2025-12-09
2026-11-02

Here is the English translation of the provided text about deploying DeepSeek-R1 on a VPS.

Foreword

AI has been exceptionally popular over the last two years, and there are many AI models on the market. Essentially, every major technology company has its own AI offering, each with its own pros and cons. Today, I'll share the configurations and steps required to deploy DeepSeek-R1 on a VPS server, considering all necessary factors. For specific details, please always refer to the official DeepSeek documentation.

DeepSeek Official Links:

https://github.com/deepseek-ai/DeepSeek-R1

https://github.com/deepseek-ai/DeepSeek-V3

I. Basic Hardware Configuration

Component

Recommendation

Details & Considerations

CPU

4+ Cores (e.g., Intel Xeon or AMD EPYC series)

Recommend 8+ cores for handling high concurrency or complex computations.

RAM (Memory)

$16\text{ GB}+$ for small models

A $7\text{B}$ parameter model typically requires about $20\text{ GB}$ of RAM.

$32\text{ GB}+$ for large models

For $13\text{B}+$ parameter models, $64\text{ GB}+$ is recommended.

Storage

SSD with $50\text{ GB}+$ free space

(Model files + system environment).

$200\text{ GB}+$ reserved for large models

(E.g., if including a vector database or large dataset).

GPU (Optional but Recommended)

NVIDIA GPU with CUDA support (e.g., T4/V100/A10)

VRAM (Video Memory) of at least $16\text{ GB}$ for inference acceleration.

II. Software Environment

Component

Requirement

Notes

Operating System

Ubuntu 20.04/22.04 LTS

Strong community support and compatibility.

Deep Learning Framework

PyTorch / TensorFlow

Install the version corresponding to the model's requirements.

CUDA/cuDNN (for GPU)

Must match the installed framework version.

Python Environment

Python 3.8+

Recommended to use conda or venv to create a virtual environment.

Dependency Libraries

transformers, sentencepiece, accelerate, etc.

(Hugging Face ecosystem tools).

Web Framework

FastAPI/Flask

(To provide API service).

III. Deployment Steps

1: Environment Initialization

# Update System
sudo apt update && sudo apt upgrade -y

# Install Basic Tools
sudo apt install -y git curl wget python3-pip

# Install CUDA (for GPU scenario)
# Refer to NVIDIA Official Documentation: https://developer.nvidia.com/cuda-downloads

2: Python Environment Setup

# Use conda to manage environment
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
conda create -n deepseek python=3.10
conda activate deepseek

3: Install Model Dependencies

pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117  # Adjust based on your CUDA version
pip install transformers accelerate sentencepiece

4: Download the Model

Obtain the model weights from the Hugging Face Hub or official channels:

Python

from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("deepseek-ai/deepseek-llm-7b")
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-llm-7b")

5: Deploy API Service

Use FastAPI to write the inference interface:

Python

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class Query(BaseModel):
    text: str

@app.post("/predict")
async def predict(query: Query):
    inputs = tokenizer(query.text, return_tensors="pt")
    outputs = model.generate(**inputs)
    return {"response": tokenizer.decode(outputs[0])}

6: Configure Web Server

Use Nginx for reverse proxy and SSL configuration:

Nginx

server {
    listen 80;
    server_name your-domain.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name your-domain.com;
    ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;

    location / {
        proxy_pass http://localhost:8000;
        proxy_set_header Host $host;
    }
}

IV. Security and Optimization

1: Firewall Settings

sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw enable

2: Process Management

Use systemd to manage the service:

Ini, TOML

# /etc/systemd/system/deepseek.service
[Unit]
Description=DeepSeek API
After=network.target

[Service]
User=ubuntu
WorkingDirectory=/opt/deepseek
ExecStart=/opt/miniconda3/envs/deepseek/bin/uvicorn main:app --host 0.0.0.0 --port 8000
Restart=always

[Install]
WantedBy=multi-user.target

3: Monitoring and Logging

Use journalctl to view logs:

journalctl -u deepseek.service -f

Key Considerations

  • Model Quantization: If resources are limited, use bitsandbytes for 4/8-bit quantization to reduce VRAM usage.

  • Caching Optimization: Enable vLLM or TGI (Text Generation Inference) to significantly boost inference speed.

  • Bandwidth Limit: Ensure your VPS has sufficient traffic ($1\text{TB}+$), to avoid unexpected overage charges.

  • Adjust configurations based on actual needs. It is recommended to test with a minimal setup first and then gradually scale up.

Summary

Most of these steps follow the official documentation. If anything is unclear, you can check the official DeepSeek documents. To ensure your deployed DeepSeek performs well, you need a computer or server with high RAM and CPU performance. However, the cost of building a high-performance computer yourself is high. I recommend using a cloud server, where you can experience a high-performing DeepSeek for just a small monthly fee.

Comment