All Products
Search
Document Center

Elastic Container Instance:Deploy a Qwen application

Last Updated:Oct 30, 2026

This topic uses the Qwen-7B-Chat model from the ModelScope community as an example to demonstrate how to use a data cache. By pre-pulling the Qwen-7B-Chat model data into a data cache, you can directly mount the model data when you create a Qwen application instance. This eliminates the wait time for pulling model data during instance creation and accelerates application deployment.

Background information

Qwen-7B is a 7-billion-parameter model in the Qwen large language model (LLM) series developed by Alibaba Cloud. It is a Transformer-based LLM trained on a massive-scale pre-training dataset. This tutorial uses Qwen-7B-Chat, an AI assistant built on Qwen-7B using alignment mechanisms.

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.

Note

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 a runtime environment

  • Hardware requirements

    The GPU-accelerated Elastic Compute Service (ECS) instance family that is used to create the Elastic Container Instance-based pod must meet the following conditions. For information about the GPU-accelerated ECS instance families that can be used to create pods, see Supported instance families.

    • CPU: no strict limits

    • Memory size: greater than 16 GiB

    • Number of GPUs: 1 or more

    • Size of the GPU memory: greater than 16 GB. If the GPU memory size is less than 16 GB, an out-of-memory (OOM) error may occur.

  • Software requirements

    Qwen-7B-Chat depends on many libraries and configurations. Elastic Container Instance provides a public container image that includes a Gradio-based web UI. You can use this image directly or as a base image for further development. The image is available at registry.cn-hangzhou.aliyuncs.com/eci_open/qwen-webui:1.0.0 and is approximately 15 GB in size.

Procedure

Create a data cache

Console

  1. Access ModelScope and obtain the ID of the Qwen-7B-Chat model.

    This example uses version v1.1.4 of the Qwen-7B-Chat model. In ModelScope, find the target model and copy its model ID from the top of the model details page.

  2. Log on to the ECI console.

  3. In the top navigation bar, select a region.

  4. In the left-side navigation pane, click Data Cache.

  5. Create a data cache for Qwen-7B-Chat.

    1. Click Create Data Cache.

    2. Configure the parameters for the data cache.

      The following table shows example parameter settings. The settings for Cache Data Source are required to pull the Qwen-7B-Chat model. You can customize other parameters. For more information, see Create a data cache.

      Parameter

      Example value

      Cache Bucket

      test

      Cache Directory

      /model/qwen/

      Cache Name

      qwen

      Cache Size

      20 GiB

      Cache Data Source

      • Type: URL

      • Parameters

        • repoSource: ModelScope/Model

        • repoId: qwen/Qwen-7B-Chat

        • revision: v1.1.4

    3. Click OK.

  6. View the status of the data cache.

    On the Data Cache page, refresh the page to view the data cache status. The cache is ready to use when its status changes to Available.

API

  1. Access ModelScope and obtain the ID of the Qwen-7B-Chat model.

    This example uses version v1.1.4 of the Qwen-7B-Chat model. In ModelScope, find the target model and copy its model ID from the top of the model details page.

  2. Create a data cache for Qwen-7B-Chat.

    Call the CreateDataCache API operation to create a data cache. The following code shows an example of the parameters. This example pulls the specified model data from ModelScope and saves it to the /model/qwen/ directory of a bucket named test. The data cache is named qwen and is retained for one day.

    Important

    If you create a DataCache by using an SDK, you do not need to prefix the parameters in DataSource.Options with the length of the parameter name. For example, write #10#repoSource as repoSource and #6#repoId as repoId.

    {
      "RegionId": "cn-beijing",
      "SecurityGroupId": "sg-2ze7l1o0ql1cbk******",
      "VSwitchId": "vsw-2ze23nqzig8inpr******",
      "Bucket": "test",
      "Path": "/model/qwen/",
      "Name": "qwen",
      "DataSource": {
        "Type": "URL",
        "Options": {
          "#6#repoId": "qwen/Qwen-7B-Chat",
          "#10#repoSource": "ModelScope/Model"
          "#8#revision": "v1.1.4"
        }
      },
      "RetentionDays": 1
    }
  3. Query the status of the data cache.

    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.

Deploy the Qwen application

Console

  1. On the Container Group page of the ECI console, click Create Container Group.

  2. Configure the instance parameters and then click Confirm Configuration.

    The following table provides example parameter settings. This configuration uses a GPU-accelerated instance type, mounts the Qwen model, and runs a container that includes the Qwen WebUI application. After the container starts, it runs the python Qwen-7B/web_demo.py --server_port 8888 command to launch the WebUI.

    Important

    If 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.

    Section

    Parameter

    Example value

    Container Group Configurations

    Specify Instance Type

    ecs.gn6i-c16g1.4xlarge

    Name

    qwen-web

    Container Configurations

    Container Name

    qwen

    Image

    • Image: registry.cn-hangzhou.aliyuncs.com/eci_open/qwen-webui

    • Container image tag: 1.0.0

    Executable Command

    /bin/sh

    Parameter

    • -c

    • python Qwen-7B/web_demo.py --server_port 8888

    Data Cache

    Data Cache Bucket

    test

    Click Add to mount the data cache for Qwen-7B-Chat.

    • Data Cache Directory: /model/qwen/

    • Destination Container: qwen

    • Container Mount Directory: /data/model/

    Enable Burst

    Enabled

    EIP

    EIP

    • Auto Create

    • Maximum Bandwidth: 5 Mbps

  3. Confirm the instance configurations, read and select the terms of service, and then click Confirm Order.

  4. Return to the Container Group page to confirm the application deployment status and view the EIP address 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. The application is deployed successfully when both the instance and container statuses are Running. The EIP address of the instance is available in the IP Address column.

API

  1. Use the data cache to create an ECI instance and deploy the Qwen application.

    Call the CreateContainerGroup API operation to create an ECI instance. The following code shows example parameters. This configuration uses a GPU-accelerated instance type, mounts the Qwen model, and runs a container that includes the Qwen WebUI application. After the container starts, it runs the python Qwen-7B/web_demo.py --server_port 8888 command to launch the WebUI.

    Note

    In 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-beijing",
      "SecurityGroupId": "sg-2ze7l1o0ql1cbk******",
      "VSwitchId": "vsw-2ze23nqzig8inpr******",
      "ContainerGroupName": "qwen-web",
      "InstanceType": "ecs.gn6i-c16g1.4xlarge",
      "DataCacheBucket": "test",
      "Container": [
        {
          "Arg": [
            "-c",
            "python Qwen-7B/web_demo.py --server_port 8888"
          ],
          "Command": [
            "/bin/sh"
          ],
          "Gpu": 1,
          "Name": "qwen",
          "Image": "registry.cn-hangzhou.aliyuncs.com/eci_open/qwen-webui:1.0.0",
          "VolumeMount": [
            {
              "Name": "model-qwen",
              "MountPath": "/data/model"
            }
          ]
        }
      ],
      "Volume": [
        {
          "Type": "HostPathVolume",
          "HostPathVolume.Path": "/model/qwen/",
          "Name": "model-qwen"
        }
      ],
      "DataCacheProvisionedIops": 35000,
      "DataCacheBurstingEnabled": true,
      "AutoCreateEip": true
    }
  2. 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.

  3. Query the EIP address of the instance.

    Call the DescribeContainerGroups API operation with the instance ID to query the instance details. The EIP address is available in the InternetIp parameter of the response.

Test the model

  1. Add an inbound rule to the ECI instance's security group to open port 8888.

  2. Open a browser and access the Qwen web page.

    Access the application in your browser by using the instance's EIP address and the exposed container port, for example, 123.57.XX.XX:8888.

  3. Enter text to test the Qwen-7B-Chat model.

    In the Gradio chat interface, enter Introduce yourself and click Submit. The model responds: 'I am an AI assistant and can help you solve various problems. I can provide definitions, explanations, and suggestions; translate text from one language to another; summarize text; generate text; write stories; analyze sentiment; provide advice; develop algorithms; write code; and perform any other language-based tasks.'