> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-zh/yu-yan-mo-xing/deepseek-v3.md).

# DeepSeek-V3

在 Clore.ai GPU 上运行具有出色推理能力的 DeepSeek-V3

在 CLORE.AI GPU 上运行 DeepSeek-V3，这款具备卓越推理能力的最先进开源 LLM。

{% hint style="success" %}
所有示例都可以在通过以下方式租用的 GPU 服务器上运行 [CLORE.AI 市场](https://clore.ai/marketplace).
{% endhint %}

{% hint style="info" %}
**更新：DeepSeek-V3-0324（2024年3月）** — DeepSeek-V3 的最新修订版在代码生成、数学推理和通用问题求解方面带来了显著改进。请参见 [更新日志](#whats-new-in-deepseek-v3-0324) 部分了解详情。
{% endhint %}

## 为什么选择 DeepSeek-V3？

* **最先进** - 可与 GPT-4o 和 Claude 3.5 Sonnet 竞争
* **671B MoE** - 总参数 671B，每个 token 激活 37B（高效推理）
* **推理能力提升** - DeepSeek-V3-0324 在数学和代码方面显著更强
* **高效** - 与稠密模型相比，MoE 架构降低了计算成本
* **开源** - 在 MIT 许可下完全开放权重
* **长上下文** - 128K token 上下文窗口

## DeepSeek-V3-0324 有什么新变化

DeepSeek-V3-0324（2024年3月修订版）在关键领域带来了实质性改进：

### 代码生成

* **在 HumanEval 上提升 8-12%** 相较于原始 V3
* 在多文件代码库和复杂重构任务中表现更好
* 对现代框架（FastAPI、Pydantic v2、LangChain v0.3）的理解有所提升
* 更可靠地生成完整、可运行且无遗漏的代码

### 数学推理

* **在 MATH-500 上提升 5%** 基准
* 更好的逐步证明构建能力
* 多步问题的数值准确性提升
* 增强了在解题过程中识别并纠正错误的能力

### 通用推理

* 更强的逻辑推断和因果推理
* 在多步规划任务中表现更好
* 在边界情况和含糊提示上的表现更稳定
* 对复杂、多约束请求的指令遵循能力提升

## 在 CLORE.AI 上快速部署

**Docker 镜像：**

```
vllm/vllm-openai:latest
```

**端口：**

```
22/tcp
8000/http
```

**命令（需要多 GPU）：**

```bash
python -m vllm.entrypoints.openai.api_server \
    --model deepseek-ai/DeepSeek-V3-0324 \
    --host 0.0.0.0 \\
    --port 8000 \\
    --tensor-parallel-size 8 \\
    --trust-remote-code
```

## 访问你的服务

部署后，找到你的 `http_pub` URL 在 **我的订单**:

1. 前往 **我的订单** 页面
2. 点击你的订单
3. 找到 `http_pub` URL（例如， `abc123.clorecloud.net`)

使用 `https://YOUR_HTTP_PUB_URL` 替代 `localhost` 在下面的示例中。

### 验证是否正常工作

```bash
# 检查服务是否就绪
curl https://your-http-pub.clorecloud.net/health

# 列出可用模型
curl https://your-http-pub.clorecloud.net/v1/models

# 获取版本
curl https://your-http-pub.clorecloud.net/version
```

{% hint style="warning" %}
**重要：** DeepSeek-V3 需要 **8x A100 80GB** 块 GPU 以及较长的下载时间。在模型下载期间，HTTP 502 可能会持续 15-30 分钟。
{% endhint %}

## 模型变体

| 模型                | 参数   | 激活   | 所需显存   | HuggingFace                                                                                             |
| ----------------- | ---- | ---- | ------ | ------------------------------------------------------------------------------------------------------- |
| DeepSeek-V3-0324  | 671B | 37B  | 8x80GB | [deepseek-ai/DeepSeek-V3-0324](https://huggingface.co/deepseek-ai/DeepSeek-V3-0324)                     |
| DeepSeek-V3       | 671B | 37B  | 8x80GB | [deepseek-ai/DeepSeek-V3](https://huggingface.co/deepseek-ai/DeepSeek-V3)                               |
| DeepSeek-V3-Base  | 671B | 37B  | 8x80GB | [deepseek-ai/DeepSeek-V3-Base](https://huggingface.co/deepseek-ai/DeepSeek-V3-Base)                     |
| DeepSeek-V2.5     | 236B | 21B  | 4x80GB | [deepseek-ai/DeepSeek-V2.5](https://huggingface.co/deepseek-ai/DeepSeek-V2.5)                           |
| DeepSeek-V2-Lite  | 16B  | 2.4B | 16GB   | [deepseek-ai/DeepSeek-V2-Lite](https://huggingface.co/deepseek-ai/DeepSeek-V2-Lite)                     |
| DeepSeek-Coder-V2 | 236B | 21B  | 4x80GB | [deepseek-ai/DeepSeek-Coder-V2-Instruct](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct) |

## 硬件要求

{% hint style="warning" %}
**Clore.ai 市场上未列出多 GPU 的 80GB 级机型。** 目前列出的最大配置是 4× RTX PRO 6000 Blackwell（每张 96GB，共 380GB）以及 8–11× RTX 5090（每张 32GB）。A100 / H200 / B200 容量可按 [裸机](https://clore.ai/bare-metal) 需求提供。部署前请查看 [GPU 价格与可用性](/guides/guides_v2-zh/ru-men-zhi-nan/pricing.md) 。
{% endhint %}

### 全精度

| 模型               | 最低            | 推荐           |
| ---------------- | ------------- | ------------ |
| DeepSeek-V3-0324 | 8x A100 80GB  | 8x H100 80GB |
| DeepSeek-V2.5    | 4x A100 80GB  | 4x H100 80GB |
| DeepSeek-V2-Lite | RTX 4090 24GB | A100 40GB    |

### 量化版（AWQ/GPTQ）

| 模型               | 量化   | 显存     |
| ---------------- | ---- | ------ |
| DeepSeek-V3-0324 | INT4 | 4x80GB |
| DeepSeek-V2.5    | INT4 | 2x80GB |
| DeepSeek-V2-Lite | INT4 | 8GB    |

## 安装

### 使用 vLLM（推荐）

```bash
pip install vllm==0.7.3

# DeepSeek-V3-0324（最新，8 张 GPU）
python -m vllm.entrypoints.openai.api_server \
    --model deepseek-ai/DeepSeek-V3-0324 \
    --tensor-parallel-size 8 \\
    --trust-remote-code \\
    --host 0.0.0.0 \\
    --port 8000

# 原始 V3（仍可用）
python -m vllm.entrypoints.openai.api_server \
    --model deepseek-ai/DeepSeek-V3 \\
    --tensor-parallel-size 8 \\
    --trust-remote-code \\
    --host 0.0.0.0 \\
    --port 8000
```

### 使用 Transformers

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "deepseek-ai/DeepSeek-V3-0324"

tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True
)

messages = [{"role": "user", "content": "用简单的话解释量子计算。"}]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)

outputs = model.generate(inputs, max_new_tokens=512, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```

### 使用 Ollama

```bash
# 拉取 DeepSeek-V3（需要大量资源）
ollama pull deepseek-v3

# 或者更轻量的变体
ollama pull deepseek-coder-v2:16b

# 运行
ollama run deepseek-v3
```

## API 使用

### OpenAI 兼容 API（vLLM）

```python
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8000/v1",
    api_key="not-needed"
)

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3-0324",
    messages=[
        {"role": "system", "content": "你是一个乐于助人的 AI 助手。"},
        {"role": "user", "content": "编写一个 Python 函数来查找质数。"}
    ],
    temperature=0.7,
    max_tokens=1000
)

print(response.choices[0].message.content)
```

### 流式输出

```python
stream = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3-0324",
    messages=[{"role": "user", "content": "解释机器学习"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
```

### cURL

```bash
curl http://localhost:8000/v1/chat/completions \\
    -H "Content-Type: application/json" \\
    -d '{
        "model": "deepseek-ai/DeepSeek-V3-0324",
        "messages": [
            {"role": "user", "content": "法国的首都是什么？"}
        ],
        "temperature": 0.7
    }'
```

## DeepSeek-V2-Lite（单 GPU）

适用于硬件有限的用户：

```bash
# 使用 vLLM
python -m vllm.entrypoints.openai.api_server \
    --model deepseek-ai/DeepSeek-V2-Lite \
    --trust-remote-code \\
    --host 0.0.0.0

# 使用 Ollama
ollama run deepseek-coder-v2:16b
```

```python
# 在单 GPU 上使用 Transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model = AutoModelForCausalLM.from_pretrained(
    "deepseek-ai/DeepSeek-V2-Lite",
    torch_dtype=torch.float16,
    device_map="cuda",
    trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-V2-Lite", trust_remote_code=True)
```

## 代码生成

DeepSeek-V3-0324 在代码方面是同类最佳：

```python
prompt = """编写一个 Python 类来实现二叉搜索树，包含：
- 插入
- 搜索
- 删除
- 中序遍历
包含类型提示和文档字符串。"""

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3-0324",
    messages=[{"role": "user", "content": prompt}],
    temperature=0.2  # 代码建议更低
)

print(response.choices[0].message.content)
```

V3-0324 擅长的高级代码任务：

```python
# 多文件重构
prompt = """我有一个 Flask 应用，所有代码都在 app.py 中（500 行）。
将其重构为使用应用工厂模式，并为以下部分使用蓝图：
- auth（登录、注册、注销）
- api（REST 端点）
- admin（仪表盘）
显示完整的文件结构和所有文件。"""

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3-0324",
    messages=[{"role": "user", "content": prompt}],
    temperature=0.1,
    max_tokens=4000
)
```

## 数学与推理

```python
# 复杂数学问题
prompt = """证明对于任意整数 n >= 1，和 1^2 + 2^2 + ... + n^2 = n(n+1)(2n+1)/6。
使用数学归纳法，并清晰展示所有步骤。"""

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3-0324",
    messages=[{"role": "user", "content": prompt}],
    temperature=0.1  # 数学任务建议设为非常低
)

print(response.choices[0].message.content)
```

## 多 GPU 配置

### 8x GPU（完整模型 — V3-0324）

```bash
python -m vllm.entrypoints.openai.api_server \
    --model deepseek-ai/DeepSeek-V3-0324 \
    --tensor-parallel-size 8 \\
    --max-model-len 32768 \\
    --gpu-memory-utilization 0.9 \
    --trust-remote-code
```

### 4x GPU（V2.5）

```bash
python -m vllm.entrypoints.openai.api_server \
    --model deepseek-ai/DeepSeek-V2.5 \
    --tensor-parallel-size 4 \\
    --max-model-len 16384 \\
    --trust-remote-code
```

## 性能

### 吞吐量（tokens/秒）

| 模型                    | GPU          | 上下文 | 每秒 Token 数 |
| --------------------- | ------------ | --- | ---------- |
| DeepSeek-V3-0324      | 8x H100      | 32K | \~85       |
| DeepSeek-V3-0324      | 8x A100 80GB | 32K | \~52       |
| DeepSeek-V3-0324 INT4 | 4x A100 80GB | 16K | \~38       |
| DeepSeek-V2.5         | 4x A100 80GB | 16K | \~70       |
| DeepSeek-V2.5         | 2x A100 80GB | 8K  | \~45       |
| DeepSeek-V2-Lite      | RTX 4090     | 8K  | \~40       |
| DeepSeek-V2-Lite      | RTX 3090     | 4K  | \~25       |

### 首个 token 时间（TTFT）

| 模型               | 配置       | TTFT      |
| ---------------- | -------- | --------- |
| DeepSeek-V3-0324 | 8x H100  | 约 750 毫秒  |
| DeepSeek-V3-0324 | 8 张 A100 | 约 1100 毫秒 |
| DeepSeek-V2.5    | 4 张 A100 | 约 500 毫秒  |
| DeepSeek-V2-Lite | RTX 4090 | \~150毫秒   |

### 内存占用

| 模型               | 精度   | 所需显存    |
| ---------------- | ---- | ------- |
| DeepSeek-V3-0324 | FP16 | 8x 80GB |
| DeepSeek-V3-0324 | INT4 | 4x 80GB |
| DeepSeek-V2.5    | FP16 | 4x 80GB |
| DeepSeek-V2.5    | INT4 | 2x 80GB |
| DeepSeek-V2-Lite | FP16 | 20GB    |
| DeepSeek-V2-Lite | INT4 | 10GB    |

## 基准

### DeepSeek-V3-0324 vs 竞品

| 基准            | V3-0324 | V3（原始） | GPT-4o | Claude 3.5 Sonnet |
| ------------- | ------- | ------ | ------ | ----------------- |
| MMLU          | 88.5%   | 87.1%  | 88.7%  | 88.3%             |
| HumanEval     | 90.2%   | 82.6%  | 90.2%  | 92.0%             |
| MATH-500      | 67.1%   | 61.6%  | 76.6%  | 71.1%             |
| GSM8K         | 92.1%   | 89.3%  | 95.8%  | 96.4%             |
| LiveCodeBench | 72.4%   | 65.9%  | 71.3%  | 73.8%             |
| Codeforces 评分 | 1850    | 1720   | 1780   | 1790              |

*注意：V3 → V3-0324 的 MATH-500 提升为 +5.5 个百分点。*

## Docker Compose

```yaml
version: '3.8'

services:
  deepseek:
    image: vllm/vllm-openai:latest
    ports:
      - "8000:8000"
    volumes:
      - ~/.cache/huggingface:/root/.cache/huggingface
    environment:
      - HUGGING_FACE_HUB_TOKEN=${HF_TOKEN}
    command: >
      --model deepseek-ai/DeepSeek-V2-Lite
      --host 0.0.0.0
      --port 8000
      --trust-remote-code
      --gpu-memory-utilization 0.9
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
```

## GPU 需求总结

| 使用场景                | 推荐配置              | 每小时成本   |
| ------------------- | ----------------- | ------- |
| 完整 DeepSeek-V3-0324 | 8x A100 80GB      | \~$2.00 |
| DeepSeek-V2.5       | 4x A100 80GB      | \~$1.00 |
| 开发/测试               | RTX 4090（V2-Lite） | \~$0.10 |
| 生产 API              | 8x H100 80GB      | \~$3.00 |

## 成本估算

CLORE.AI 市场的典型费率：

| GPU 配置        | 小时费率    | 日费率      |
| ------------- | ------- | -------- |
| RTX 4090 24GB | \~$0.10 | \~$2.30  |
| A100 40GB     | \~$0.17 | \~$4.00  |
| A100 80GB     | \~$0.25 | \~$6.00  |
| 4x A100 80GB  | \~$1.00 | \~$24.00 |
| 8x A100 80GB  | \~$2.00 | \~$48.00 |

*价格因提供商而异。查看* [*CLORE.AI 市场*](https://clore.ai/marketplace) *以获取当前费率。*

**节省费用：**

* 使用 **竞价** 用于开发的市场——大约三分之一的服务器价格低于按需价格的现货价（中位数约便宜 13%），其余与之持平
* 使用 **CLORE** 代币支付
* 在扩展之前，先用 DeepSeek-V2-Lite 进行测试

## 故障排查

### 内存不足

```bash
# 缩短上下文长度
--max-model-len 8192

# 或使用量化
--quantization awq

# 适用于 12GB GPU 上的 V2-Lite
--gpu-memory-utilization 0.85
--max-model-len 4096
```

### 模型下载缓慢

```bash
# 预先下载
huggingface-cli download deepseek-ai/DeepSeek-V3-0324

# 或使用镜像
export HF_ENDPOINT=https://hf-mirror.com
```

### trust\_remote\_code 错误

```bash
# 对 DeepSeek 模型始终包含此标志
--trust-remote-code
```

### 多 GPU 无法工作

```bash
# 检查 NCCL
nvidia-smi topo -m

# 设置 NCCL 变量
export NCCL_DEBUG=INFO
export NCCL_P2P_DISABLE=0
```

## DeepSeek 与其他模型

| 功能   | DeepSeek-V3-0324 | Llama 3.1 405B | Mixtral 8x22B |
| ---- | ---------------- | -------------- | ------------- |
| 参数   | 671B（37B 激活）     | 405B           | 176B（44B 激活）  |
| 上下文  | 128K             | 128K           | 64K           |
| 代码   | **优秀**           | 很高             | 好             |
| 数学   | **优秀**           | 好              | 好             |
| 最低显存 | 8x80GB           | 8x80GB         | 2x80GB        |
| 许可证  | MIT              | Llama 3.1      | Apache 2.0    |

**在以下情况使用 DeepSeek-V3：**

* 需要最佳推理性能
* 代码生成是主要用途
* 数学/逻辑任务很重要
* 具备多 GPU 环境
* 想要完全开源的权重（MIT 许可）

## 下一步

* [vLLM](/guides/guides_v2-zh/yu-yan-mo-xing/vllm.md) - 部署服务器
* [DeepSeek-R1](/guides/guides_v2-zh/yu-yan-mo-xing/deepseek-r1.md) - 推理专用变体
* [DeepSeek Coder](/guides/guides_v2-zh/yu-yan-mo-xing/deepseek-coder.md) - 代码专用变体
* [Ollama](/guides/guides_v2-zh/yu-yan-mo-xing/ollama.md) - 部署更简单
* [微调 LLM](/guides/guides_v2-zh/xun-lian/finetune-llm.md) - 定制训练


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-zh/yu-yan-mo-xing/deepseek-v3.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
