Deploy DeepSeek-R1 series models
This topic uses the DeepSeek-R1-Distill-Qwen-7B model as an example to demonstrate how to use a DataCache to quickly deploy DeepSeek-R1 series models. By pre-pulling model data with a DataCache and then mounting it directly to the inference service, you can eliminate data download wait times and accelerate deployment.
Why deploy DeepSeek on ECI
-
Elastic Container Instance (ECI) offers zero O&M, flexible deployment, high elasticity, and low cost. For more information, see Benefits.
-
With its DataCache and ImageCache features, ECI saves time pulling container images and downloading models, reduces network resource consumption, and improves system efficiency.
NoteDeploying a containerized large model inference service involves several stages: container creation and startup, container image pulling, model file downloading, and the inference service loading the model and starting up. Because these container images and models are large (for example, the vLLM image is about 16.5 GB and the DeepSeek-R1-Distill-Qwen-7B model is about 14 GB), pulling them consumes significant time and network bandwidth. ECI uses ImageCache and DataCache to save time pulling images and downloading models.
Prerequisites
The VPC that you use is bound to an Internet NAT gateway, and an SNAT entry is configured to allow resources in the VPC or its vSwitches to access the Internet.
If the VPC is not bound to an Internet NAT gateway, bind an elastic IP address (EIP) when you create the DataCache and deploy the application so that you can pull data from the Internet.
Prepare the environment
Different DeepSeek models have different runtime requirements. This topic uses the DeepSeek-R1-Distill-Qwen-7B model as an example.
-
Recommended instance types
The GPU instance type must meet the following requirements. For a list of GPU instance types that ECI supports, see ECI instance types.
-
CPU: No strict limit
-
Memory: > 16 GiB
-
GPU: ≥ 1
-
GPU memory: ≥ 20 GB. An A10 GPU is recommended. Insufficient GPU memory may cause an out-of-memory (OOM) error.
-
-
Software environment
Deploying large models involves many libraries and configurations. vLLM is a popular inference engine for large models. This topic uses vLLM to deploy the inference service. ECI provides a public container image that you can use directly or as a base image for further development. The image is available at
registry.cn-hangzhou.aliyuncs.com/eci_open/vllm-openai:v0.7.2, and its size is approximately 16.5 GB.
Step 1: Create a DataCache
Before your first deployment, create a DataCache to avoid model download delays within the instance and to speed up DeepSeek deployments.
Console
-
Go to Hugging Face and get the model ID.
This example uses the main revision of the DeepSeek-R1-Distill-Qwen-7B model. After you find the model on Hugging Face, you can copy the model ID from the top of the model details page.
-
Log on to the Elastic Container Instance console.
-
In the upper-left corner of the top navigation bar, select a region.
-
In the left-side navigation pane, click Data Cache.
-
Create a DataCache for the DeepSeek-R1-Distill-Qwen-7B model.
-
Click Create Data Cache.
-
Configure the DataCache parameters.
The following table shows the example values. The settings for Cache Data Source are required to pull the DeepSeek-R1-Distill-Qwen-7B model. You can customize other parameters. For more information, see Create a DataCache.
Parameter
Value
Cache Bucket
test
Cache Directory
/model/deepseek-r1-distill-qwen-7b
Cache Name
deepseek-qwen-7b
Cache Size
20 GiB
Cache Data Source
-
Type: URL
-
Parameters
-
repoSource: HuggingFace/Model
-
repoId: deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
-
revision: main
-
-
-
Click OK.
-
-
Check the DataCache status.
On the Data Cache page, refresh the page to check the status. When the status changes to Available, the DataCache is ready. Alibaba Cloud's hot-load capability for DeepSeek-R1 series models creates a DataCache in seconds.
OpenAPI
-
Go to Hugging Face and get the model ID.
This example uses the main revision of the DeepSeek-R1-Distill-Qwen-7B model. After you find the model on Hugging Face, you can copy the model ID from the top of the model details page.
-
Create a DataCache for the DeepSeek-R1-Distill-Qwen-7B model.
Call the CreateDataCache operation to create a DataCache. We recommend that you use an SDK. For more information, see SDK overview.
The following Java SDK example pulls the specified model data from HuggingFace and saves it to the
/model/deepseek-r1-distill-qwen-7bdirectory in a bucket namedtest.CreateDataCacheRequest request = new CreateDataCacheRequest(); request.setName("deepseek-qwen-7b"); request.setBucket("test"); request.setPath("/model/deepseek-r1-distill-qwen-7b"); request.setVSwitchId("vsw-bp1*********"); request.setSecurityGroupId("sg-bp1*********"); CreateDataCacheRequest.DataSource dataSource = new CreateDataCacheRequest.DataSource(); dataSource.setType("URL"); HashMap<String, String> options = new HashMap<>(); options.put("repoId", "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"); options.put("repoSource", "HuggingFace/Model"); options.put("revision", "main"); dataSource.setOptions(options); request.setDataSource(dataSource); -
Query the DataCache status.
Use the returned DataCache ID to call the DescribeDataCaches API operation to query DataCache information. When the DataCache status (DataCaches.Status) is Available, you can use the DataCache.
Step 2: Deploy the DeepSeek inference service
Console
-
In the Elastic Container Instance console, on the Container Group page, click Create Container Group.
-
Configure the instance parameters, and then click Confirm Configuration.
The following table describes the example parameters. The instance uses a GPU-accelerated instance type and mounts the DeepSeek-R1-Distill-Qwen-7B model. After the container starts, it runs
vllm serve /deepseek-r1-7b --tensor-parallel-size 1 --max-model-len 24384 --enforce-eagerto start the vLLM inference engine.ImportantIf the VPC is associated with an Internet NAT gateway, you do not need to associate an EIP when you create the ECI instance. After the instance is created, you can configure DNAT entries to allow external access to the ECI instance.
Configuration page
Section
Parameter
Value
Basic Settings
Container Group Configurations
Specify Instance Type
ecs.gn7i-c16g1.4xlarge
Name
deepseek-r1-7b-server
20 GiB
NoteBecause the startup framework is large, you must configure and pay for additional ephemeral storage.
Container Configurations
Container Name
vllm
Image
-
Image: registry.cn-hangzhou.aliyuncs.com/eci_open/vllm-openai
-
Image Tag: v0.7.2
Executable Command
/bin/sh
Parameter
-
-c
-
vllm serve /deepseek-r1-7b --tensor-parallel-size 1 --max-model-len 24384 --enforce-eager
Data Cache
Data Cache Bucket
test
Click Add to mount the DataCache for the DeepSeek-R1-Distill-Qwen-7B model.
-
Data Cache Directory: /model/deepseek-r1-distill-qwen-7b
-
Destination Container: vllm
-
Container Mount Directory: /deepseek-r1-7b
Enable Burst
Enable as needed. This option speeds up model loading but may incur burst performance charges.
Other Settings (Optional)
EIP
EIP
-
Auto Create
-
Maximum Bandwidth: 5 Mbps
-
-
Confirm the instance configuration, read and select the terms of service, and then click Confirm Order.
-
Return to the Container Group page to confirm the deployment status and view the EIP of the instance.
On the Container Group page, view the instance status. Click the instance ID to go to the instance details page and view the container status. When both the instance status and container status are Running, the application is deployed. Find the instance EIP in the IP Address column.
OpenAPI
-
Create an ECI instance with a DataCache to deploy the DeepSeek model.
The following example shows the parameters used to call the CreateContainerGroup operation to create an ECI instance. The instance uses a GPU-accelerated instance type and mounts the DeepSeek-R1-Distill-Qwen-7B model. After the container starts, it runs
vllm serve /deepseek-r1-7b --tensor-parallel-size 1 --max-model-len 24384 --enforce-eagerto start the vLLM inference engine.NoteIn the following example, an EIP is automatically created and associated with the ECI instance. If your VPC is associated with an Internet NAT gateway, you do not need to associate an EIP when you create the ECI instance. After the instance is created, you can configure DNAT entries to allow external access.
{ "RegionId": "cn-hangzhou", "SecurityGroupId": "sg-bp18***********", "VSwitchId": "vsw-bp14***********", "ContainerGroupName": "deepseek-r1-7b-server", "InstanceType": "ecs.gn7i-c16g1.4xlarge", "DataCacheBucket": "default", "Container": [ { "Arg": [ "-c", "vllm serve /deepseek-r1-7b --tensor-parallel-size 1 --max-model-len 24384 --enforce-eager" ], "Command": [ "/bin/sh" ], "Gpu": 1, "Name": "vllm", "Image": "registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/vllm-openai:v0.7.2", "VolumeMount": [ { "Name": "llm-model", "MountPath": "/deepseek-r1-7b" } ] } ], "Volume": [ { "Type": "HostPathVolume", "HostPathVolume.Path": "/model/deepseek-r1-distill-qwen-7b", "Name": "llm-model" } ], "DataCacheProvisionedIops": 15000, "DataCacheBurstingEnabled": true, "AutoCreateEip": true } -
Confirm the application deployment status.
Use the returned instance ID to call DescribeContainerGroupStatus to query the status of the instance and its containers. When the instance status (Status) and the container status (ContainerStatuses.State) are both Running, the instance is created and the container is running.
-
Query the EIP of the instance.
Use the returned instance ID to call the DescribeContainerGroups operation and query instance details. The instance EIP is returned in the
InternetIpresponse parameter.
Step 3: Test the model inference service
-
Add an inbound rule to the security group of the ECI instance to allow traffic on port 8000.
-
Send an inference request to the model inference service.
The DeepSeek service deployed in this example is associated with an EIP. Replace
XX.XX.XX.XXin the sample command with your actual EIP address.curl POST http://XX.XX.XX.XX:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "/deepseek-r1-7b", "messages": [ { "role": "user", "content": "Briefly describe cloud computing in one sentence" } ], "temperature": 0.6, "max_tokens": 3000 }' \ --verboseExpected output:
{"id":"chatcmpl-2d3419bd63f24251a8ea1244851312e5","object":"chat.completion","created":1739179460,"model":"/deepseek-r1-7b","choices":[{"index":0,"message":{"role":"assistant","reasoning_content":null,"content":"<think>\nOK, the user wants me to briefly describe cloud computing in one sentence. First, I need to understand the basic concept of cloud computing. Cloud computing refers to providing computing resources, such as servers, storage, and data analytics, over the internet on demand, rather than provisioning and maintaining them in advance. It offers elastic computing resources through the internet, reducing hardware costs.\n\nNext, I should consider the user's needs. They might want a quick understanding of what cloud computing is or want to apply it in a certain field. The user might not be familiar with technical terms, so I need to use simple and clear language.\n\nI also need to make sure the sentence is concise and covers the main points: internet, computing resources, elasticity, on-demand use, cost reduction, and resource management. I might need to mention how cloud computing helps users save costs and improve efficiency.\n\nFinally, I will organize this information into one sentence, ensuring it flows naturally and accurately conveys the core value of cloud computing.\n</think>\n\nCloud computing is a technology that delivers elastic computing resources over the internet on demand to reduce hardware costs and improve resource management efficiency.","tool_calls":[]},"logprobs":null,"finish_reason":"stop","stop_reason":null}],"usage":{"prompt_tokens":8,"total_tokens":189,"completion_tokens":181,"prompt_tokens_details":null},"prompt_logprobs":null}The content within the
<think></think>tags represents the model's internal reasoning before it generates the final answer. These tags are not part of the final output but record the model's thought process.The final answer is:
Cloud computing is a technology that delivers elastic computing resources over the internet on demand to reduce hardware costs and improve resource management efficiency.