火山引擎GPU云服务器指南-GPU-基于Terraform一键部署DeepSeek模型

axin 2025-04-22 63人围观 ,发现0个评论 显卡服务器租用GPU服务器租用远程电脑租用独立显卡服务器GPU云服务器租用火山引擎GPU云服务器GPU云服务器教程


👉点击这里申请火山引擎VIP帐号,立即体验火山引擎产品>>>

为方便您快速部署DeepSeek模型,火山引擎为您提供了Terraform脚本。该脚本可以自动创建GPU实例,并自动在实例中部署、运行DeepSeek-R1、DeepSeek-V3或不同参数量级的DeepSeek-R1-Distill模型。本文主要介绍如何获取、运行该Terraform脚本。

背景信息

Terraform

Terraform是一款开源基础设施即代码(IaC)工具,专注于帮助用户通过声明式配置文件自动化创建、管理和版本化云基础设施资源,方便用户通过单一工具实现多云架构的统一编排。您可以通过火山引擎提供的Terraform脚本,自动化创建所需的云资源,完成DeepSeek模型的一键部署。

DeepSeek-V3

DeepSeek-V3是一款强大的混合专家(MoE)语言模型,其总参数量达到了671 B,每个Token激活37 B参数,且在14.8 T Token上进行了预训练。了解更多。

DeepSeek-R1

DeepSeek-R1是基于DeepSeek-V3-Base训练生成的推理模型,其总参数量达到了671 B。相较于DeepSeek-V3模型,DeepSeek-R1更擅长数学、代码和自然语言推理等复杂任务,其凭借模型开源、算法创新、极致性价比吸引全球注意。了解更多。

DeepSeek-R1-Distill

DeepSeek-R1-Distill是一个基于DeepSeek-R1生成的800K个样本,对原开源模型进行微调得到的新模型,旨在以更小参数规模保留DeepSeek-R1发现的强大推理模型。您可以根据本文指引,按需部署不同参数量级的模型。
模型名称
参数量级
DeepSeek-R1-Distill-Qwen-7B
7B
DeepSeek-R1-Distill-Qwen-32B
32B
DeepSeek-R1-Distill-Llama-70B
70B

方案优势

  • 方便易用

基于开源Terraform的一键部署方案,您仅需下载、执行Terraform脚本,即可安全、高效地在GPU云服务器中部署所需的DeepSeek模型。
  • 稳定快速

Terraform脚本可以通过火山引擎内网,快速、稳定的下载DeepSeek模型,带宽稳定在300 MB/s以上,并且为您省去了公网流量费用。

操作步骤

步骤一:准备环境

  1. 登录任意可连通公网的服务器。

本文以未安装GUI界面的Ubuntu 22.04 64位服务器为例。
  1. 安装Terraform工具。了解更多。

    1. 执行如下命令,下载Terraform。

wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpgecho "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.listsudo apt update && sudo apt install terraform
    1. 执行如下命令,验证是否安装成功。

terraform -v
成功安装回显示例:

    1. 成功安装后,执行如下命令,通过环境变量配置Terraform管理您火山引擎云资源的凭证信息。

export VOLCENGINE_ACCESS_KEY=AK**************export VOLCENGINE_SECRET_KEY=Tj**************export VOLCENGINE_REGION=cn-beijing
参数说明:
参数名
说明
取值样例
VOLCENGINE_ACCESS_KEY
密钥ID,即AK。请根据访问密钥指引获取。
AK**************
VOLCENGINE_SECRET_KEY
访问密钥,即SK。请根据访问密钥指引获取。
Tj**************
VOLCENGINE_REGION
地域,即需要通过Terraform创建、管理哪个火山引擎地域的资源。取值:
  • cn-beijing:华北2(北京)

  • cn-shanghai:华东2(上海)

说明
该值需与您在“步骤二:通过Terraform脚本部署模型”中下载的Terraform脚本地域相同。例如:
下载DeepSeek-R1-Distill-Qwen-7B模型华北2(北京)地域的Terraform脚本时,VOLCENGINE_REGION参数需传入cn-beijing。
cn-beijing

步骤二:通过Terraform脚本部署模型

  1. 登录上一步搭建环境的服务器。

  1. 执行如下命令,下载Terraform脚本。

DeepSeek-R1

说明
该脚本将在华北2(北京)地域创建GPU实例并部署DeepSeek-R1模型。
wget https://public-terraform-cn-beijing.tos-cn-beijing.volces.com/models/deepseek/DeepSeek-R1/main.tf

DeepSeek-V3

说明
该脚本将在华北2(北京)地域创建GPU实例并部署DeepSeek-V3模型。
wget https://public-terraform-cn-beijing.tos-cn-beijing.volces.com/models/deepseek/DeepSeek-V3/main.tf

DeepSeek-R1-Distill

说明
如下脚本将在对应的地域创建GPU实例并部署对应的DeepSeek-R1-Distll模型。
  • DeepSeek-R1-Distill-Qwen-7B

    • 华北2(北京)

wget https://public-terraform-cn-beijing.tos-cn-beijing.volces.com/models/deepseek/DeepSeek-R1-Distill-Qwen-7B/main.tf
    • 华东2(上海)

wget https://public-terraform-cn-shanghai.tos-cn-shanghai.volces.com/models/deepseek/DeepSeek-R1-Distill-Qwen-7B/main.tf
  • DeepSeek-R1-Distill-Qwen-32B

    • 华北2(北京)

wget https://public-terraform-cn-beijing.tos-cn-beijing.volces.com/models/deepseek/DeepSeek-R1-Distill-Qwen-32B/main.tf
    • 华东2(上海)

wget https://public-terraform-cn-shanghai.tos-cn-shanghai.volces.com/models/deepseek/DeepSeek-R1-Distill-Qwen-32B/main.tf
  • DeepSeek-R1-Distill-Llama-70B

    • 华北2(北京)

wget https://public-terraform-cn-beijing.tos-cn-beijing.volces.com/models/deepseek/DeepSeek-R1-Distill-Llama-70B/main.tf
    • 华东2(上海)

wget https://public-terraform-cn-shanghai.tos-cn-shanghai.volces.com/models/deepseek/DeepSeek-R1-Distill-Llama-70B/main.tf
  1. 进入main.tf文件所在目录执行如下命令,初始化Terraform。

terraform init
  1. 执行如下命令,查看Terraform脚本默认配置的资源信息。

terraform plan
  1. (可选)若默认的资源不满足您的需求,您可以修改Terraform脚本。否则,请跳过本步骤。

    1. 执行如下命令,打开脚本文件。

vim main.tf
    1. 按i键进入编辑模式,按需调整如下参数值。

字段名称
说明
取值样例
instance_name
Terraform创建的实例名称。其中:
  • DeepSeek-R1、DeepSeek-V3:默认为deepseek一键部署node1、deepseek一键部署node2。

  • DeepSeek-R1-Distill:默认为deepseek一键部署。

deepseek一键部署
password
Terraform创建的实例的登录密码,默认为93f0cb0614Aab12。
93f0cb0****ab12
instance_type
Terraform创建的实例规格。根据模型数据量级不同,默认按如下规则创建实例。
  • DeepSeek-V3:默认创建 2 台ecs.hpcpni3ln.45xlarge规格实例。

  • DeepSeek-R1:默认创建 2 台ecs.hpcpni3ln.45xlarge规格实例。

  • DeepSeek-R1-Distill:

    • DeepSeek-R1-Distill-Qwen-7B:默认创建 1 台ecs.gni3cg.5xlarge规格实例。

    • DeepSeek-R1-Distill-Qwen-32B:默认创建 1 台ecs.gni3cl.22xlarge规格实例。

    • DeepSeek-R1-Distill-Llama-70B:默认创建 1 台ecs.pni3l.22xlarge规格实例。

说明
ecs.gni3cg、ecs.gni3cl、ecs.pni3l、ecs.hpcpni3ln规格实例正在邀测中,如需试用,请提交工单或联系客户经理申请。
ecs.gni3cg.5xlarge
hpc_cluster_id
Terraform创建的实例归属的高性能集群ID。
注意
  • 仅instance_type参数指定了高性能计算GPU型规格(例如hpcpni3ln)时需传入本参数。

  • 若您还没有高性能计算集群,请根据创建高性能计算集群指引,创建并获取高性能计算集群ID。

hpcCluster-sjsi****
    1. 按ecs键退出编辑,输入:wq按回车键,保存并退出文件。

  1. 执行如下命令,通过Terraform脚本部署模型。

terraform apply
说明
由于模型本身体积较大,DeepSeek R1、DeepSeek V3部署时间约为30 ~ 40分钟,DeepSeek-R1-Distill的部署时间为5 ~ 15分钟,请耐心等待。

步骤三:测试验证

本节以验证DeepSeek-R1、DeepSeek-R1-Distill-Qwen-7B模型为例,介绍部署模型后的验证流程。

DeepSeek-R1

  1. 登录Terraform创建的deepseek一键部署node1 GPU实例。了解更多。

  1. 执行如下命令,查看/home/result文件。

cat /home/result
若文件输出Script execution completed,表示Docker容器安装、启动成功。否则,请耐心等待后重试。
  1. 执行如下命令调用模型,确保部署的模型可以正常进行推理。

curl -X POST http://0.0.0.0:8080/v1/chat/completions -H "Content-Type: application/json" -d '{
"model": "/data/models/DeepSeek-R1",
"messages": [
{
"role": "user",
"content": "请证明一下黎曼猜想"
}
],
"stream": true,
"max_tokens": 100,
"temperature": 0.7
}'


DeepSeek-R1-Distill-Qwen-7B

  1. 登录Terraform创建的GPU实例。了解更多。

  1. 执行如下命令,查看/home/result文件。

cat /home/result
若文件输出Script execution completed,表示Docker容器安装、启动成功。否则,请耐心等待后重试。
  1. 通过Docker日志确认容器及模型是否成功启动。

    1. 执行如下命令,查看容器ID。

docker ps
    1. 执行如下命令,查看对应容器的运行日志。

docker logs --since 30m <CONTAINER_ID>
说明
请将<CONTAINER_ID>替换为实际容器ID。
  1. 执行如下命令调用模型,确保部署的模型可以正常进行推理

curl -X POST http://0.0.0.0:6001/v1/chat/completions -H "Content-Type: application/json" -d '{
"model": "/data00/models/DeepSeek-R1-Distill-Qwen-7B",
"messages": [
{
"role": "user",
"content": "请证明一下黎曼猜想"
}
],
"stream": true,
"max_tokens": 100,
"temperature": 0.7
}'
说明
若您在curl命令后返回Failed to connect ...(拒绝连接)提示,可能是由于权重文件还未下载、加载完毕,建议稍后重试。


不容错过
Powered By TOPYUN 云产品资讯