👉点击这里申请火山引擎VIP帐号,立即体验火山引擎产品>>>
为方便您快速部署DeepSeek模型,火山引擎为您提供了Terraform脚本。该脚本可以自动创建GPU实例,并自动在实例中部署、运行DeepSeek-R1、DeepSeek-V3或不同参数量级的DeepSeek-R1-Distill模型。本文主要介绍如何获取、运行该Terraform脚本。
背景信息
Terraform
DeepSeek-V3
DeepSeek-R1
DeepSeek-R1-Distill
模型名称 | 参数量级 |
DeepSeek-R1-Distill-Qwen-7B | 7B |
DeepSeek-R1-Distill-Qwen-32B | 32B |
DeepSeek-R1-Distill-Llama-70B | 70B |
方案优势
方便易用
稳定快速
操作步骤
步骤一:准备环境
登录任意可连通公网的服务器。
本文以未安装GUI界面的Ubuntu 22.04 64位服务器为例。
安装Terraform工具。了解更多。
执行如下命令,下载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
执行如下命令,验证是否安装成功。
terraform -v
成功安装后,执行如下命令,通过环境变量配置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创建、管理哪个火山引擎地域的资源。取值:
说明 该值需与您在“步骤二:通过Terraform脚本部署模型”中下载的Terraform脚本地域相同。例如: 下载DeepSeek-R1-Distill-Qwen-7B模型华北2(北京)地域的Terraform脚本时,VOLCENGINE_REGION参数需传入cn-beijing。 | cn-beijing |
步骤二:通过Terraform脚本部署模型
登录上一步搭建环境的服务器。
执行如下命令,下载Terraform脚本。
DeepSeek-R1
wget https://public-terraform-cn-beijing.tos-cn-beijing.volces.com/models/deepseek/DeepSeek-R1/main.tf
DeepSeek-V3
wget https://public-terraform-cn-beijing.tos-cn-beijing.volces.com/models/deepseek/DeepSeek-V3/main.tf
DeepSeek-R1-Distill
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
进入main.tf文件所在目录执行如下命令,初始化Terraform。
terraform init
执行如下命令,查看Terraform脚本默认配置的资源信息。
terraform plan
(可选)若默认的资源不满足您的需求,您可以修改Terraform脚本。否则,请跳过本步骤。
执行如下命令,打开脚本文件。
vim main.tf
按i键进入编辑模式,按需调整如下参数值。
字段名称 | 说明 | 取值样例 |
instance_name | Terraform创建的实例名称。其中:
| deepseek一键部署 |
password | Terraform创建的实例的登录密码,默认为93f0cb0614Aab12。 | 93f0cb0****ab12 |
instance_type | Terraform创建的实例规格。根据模型数据量级不同,默认按如下规则创建实例。
说明 ecs.gni3cg、ecs.gni3cl、ecs.pni3l、ecs.hpcpni3ln规格实例正在邀测中,如需试用,请提交工单或联系客户经理申请。 | ecs.gni3cg.5xlarge |
hpc_cluster_id | Terraform创建的实例归属的高性能集群ID。 注意
| hpcCluster-sjsi**** |
按ecs键退出编辑,输入:wq按回车键,保存并退出文件。
执行如下命令,通过Terraform脚本部署模型。
terraform apply
步骤三:测试验证
DeepSeek-R1
登录Terraform创建的deepseek一键部署node1 GPU实例。了解更多。
执行如下命令,查看/home/result文件。
cat /home/result
执行如下命令调用模型,确保部署的模型可以正常进行推理。
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
登录Terraform创建的GPU实例。了解更多。
执行如下命令,查看/home/result文件。
cat /home/result
通过Docker日志确认容器及模型是否成功启动。
执行如下命令,查看容器ID。
docker ps
执行如下命令,查看对应容器的运行日志。
docker logs --since 30m <CONTAINER_ID>
执行如下命令调用模型,确保部署的模型可以正常进行推理
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 }'