すべてのプロダクト
Search
ドキュメントセンター

Container Compute Service:ACS の GPU 計算能力を使用して、DeepSeek フルバージョンに基づくモデル推論サービスをデプロイします。

最終更新日:Apr 10, 2025

Container Compute Service (ACS) では、基盤となるハードウェアに関する深い知識や GPU インスタンスの管理は不要です。すべての構成はすぐに使用できます。ACS はデプロイが容易で、従量課金制です。LLM 推論サービスに適しており、推論コストを効率的に削減できます。このトピックでは、ACS で DeepSeek フルバージョンを使用してモデル推論サービスをデプロイする方法について説明します。

背景情報

DeepSeek-R1

DeepSeek-R1 は、DeepSeek が提供する第一世代の推論モデルです。大規模拡張学習を通じて LLM の推論パフォーマンスを向上させることを目的としています。統計によると、DeepSeek-R1 は数学的推論とプログラミング競技において他のクローズドソースモデルよりも優れています。そのパフォーマンスは、特定の分野では OpenAI-01 シリーズに匹敵、あるいは凌駕しています。DeepSeek-R1 のパフォーマンスは、作成、ライティング、Q&A などの知識に関連する分野でも素晴らしいものです。 DeepSeek の詳細については、「DeepSeek AI GitHub リポジトリ」をご参照ください。

vLLM

vLLM は、高性能で使いやすい LLM 推論サービスフレームワークです。 vLLM は、Qwen モデルを含む、最も一般的に使用される LLM をサポートしています。 vLLM は、PagedAttention 最適化、連続バッチ処理、モデル量子化などのテクノロジーによって強化されており、LLM の推論効率を大幅に向上させます。 vLLM フレームワークの詳細については、「vLLM GitHub リポジトリ」をご参照ください。

ACS

ACS は 2023 年にリリースされました。ACS は、包括的で使いやすく、柔軟でスケーラブルな次世代コンテナコンピューティングパワーの提供に重点を置いています。ACS は、Kubernetes の仕様に準拠した汎用および異種計算能力を提供します。サーバーレス コンテナコンピューティングリソースを提供し、ノードとクラスターの O&M について心配する必要性を排除します。スケジューリング、コンテナーランタイム、ストレージ、ネットワーキング機能を ACS と統合して、Kubernetes の O&M の複雑さを軽減し、コンテナコンピューティングパワーの柔軟性とスケーラビリティを向上させることができます。従量課金制、スケーラブルなインスタンス、柔軟な機能により、ACS はリソースコストを大幅に削減できます。LLM 推論シナリオでは、ACS はデータとイメージの読み込みを高速化し、モデルの起動時間とリソースコストをさらに削減できます。

前提条件

GPU インスタンスの仕様と推定コスト

ACS では DeepSeek-R1 フルバージョンの高速化に GPU リソースは使用されず、推論サービスのデプロイには 16 GPU 時間かかります。推奨される ACS GPU インスタンスの仕様: 16 GPU(GPU あたり 96 GiB のメモリ)、64 vCPU、512 GiB のメモリ推奨仕様の表GPU モデルと仕様も参照できます。ACS GPU インスタンスの課金の詳細については、「課金概要」をご参照ください。

説明
  • ACS GPU インスタンスの仕様がACS ポッドの仕様調整ロジックに準拠していることを確認してください。

  • デフォルトでは、ACS ポッドは 30 GiB の無料 EphemeralStorage を提供します。この例で使用されている推論イメージは大きいです。より多くのストレージスペースが必要な場合は、EphemeralStorage のサイズをカスタマイズします。詳細については、「EphemeralStorage を追加する」をご参照ください。

手順

ステップ 1: DeepSeek-R1-GPTQ-INT8 モデルファイルを準備する

LLM は、モデルファイルを保存するために大量のディスク容量を必要とします。モデルファイルの永続化には、NAS または OSS ボリュームを使用することをお勧めします。次の例では、OSS ボリュームを使用して DeepSeek-R1-GPTQ-INT8 モデルファイルを永続化します。

説明

チケットを送信する して、モデルファイルとYAML コンテンツを取得します。

  • モデルファイル: DeepSeek-R1-GPTQ-INT8。

  • GPU モデル: alibabacloud.com/gpu-model-series: <example-model> ラベルの変数を、ACS でサポートされている実際の GPU モデルに置き換えます。詳細については、「ACS GPU インスタンス ポッドの GPU モデルとドライバーバージョンを指定する」をご参照ください。

  • ベースイメージ: containers[].image: <PDSA から取得したベースイメージ> の変数を実際のイメージアドレスに置き換えます。

  • イメージをプルするためのシークレット: シークレットを取得して作成し、imagePullSecrets[].name: <PDSA から取得したシークレット> の変数をシークレットの実際の名前に置き換えます。

  • パフォーマンス専有型 RDMA ネットワーク: TCP/IP と比較して、RDMA はゼロコピーとカーネルバイパスをサポートしており、データの頻繁なコピーやコンテキストの切り替えを回避できます。これにより、低レイテンシ、高スループット、低 CPU 使用率を実現できます。ACS では、alibabacloud.com/hpn-type: "rdma" ラベルを YAML テンプレートに追加して RDMA を使用できます。RDMA でサポートされているGPU モデルの詳細については、チケットを送信してください。

  1. (オプション) モデルファイルをローカル環境にダウンロードする場合は、OSS バケットにディレクトリを作成し、モデルファイルをそのディレクトリにアップロードします。

    説明

    ossutil のインストールと使用方法については、「ossutil をインストールする」をご参照ください。

    ossutil mkdir oss://<your-bucket-name>/models/DeepSeek-R1-GPTQ-INT8
    ossutil cp -r /mnt/models/DeepSeek-R1-GPTQ-INT8 oss://<your-bucket-name>/models/DeepSeek-R1-GPTQ-INT8
  2. クラスターに llm-model という名前の PV と PVC を作成します。詳細については、「静的にプロビジョニングされた OSS ボリュームをマウントする」をご参照ください。

    コンソールの使用

    次の表に、PV の作成に使用される基本的なパラメーターを示します。

    パラメーター

    説明

    PV タイプ

    OSS

    ボリューム名

    llm-model

    アクセス証明書

    OSS バケットへのアクセスに使用する AccessKey ID と AccessKey シークレットを指定します。

    バケット ID

    前のステップで作成した OSS バケットを選択します。

    OSS パス

    モデルのパスを選択します(例: /models/DeepSeek-R1-GPTQ-INT8)。

    次の表に、PVC の作成に使用される基本的なパラメーターを示します。

    パラメーター

    説明

    PVC タイプ

    OSS

    名前

    llm-model

    割り当てモード

    この例では、「既存のボリューム」が選択されています。

    既存のボリューム

    「既存のボリューム」をクリックし、作成した PV を選択します。

    kubectl の使用

    次のコードブロックは、YAML テンプレートを示しています。

    apiVersion: v1
    kind: Secret
    metadata:
      name: oss-secret
    stringData:
      akId: <your-oss-ak> # OSS バケットへのアクセスに使用する AccessKey ID。
      akSecret: <your-oss-sk> # OSS バケットへのアクセスに使用する AccessKey シークレット。
    ---
    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: llm-model
      labels:
        alicloud-pvname: llm-model
    spec:
      capacity:
        storage: 30Gi
      accessModes:
        - ReadOnlyMany
      persistentVolumeReclaimPolicy: Retain
      csi:
        driver: ossplugin.csi.alibabacloud.com
        volumeHandle: llm-model
        nodePublishSecretRef:
          name: oss-secret
          namespace: default
        volumeAttributes:
          bucket: <your-bucket-name> # OSS バケットの名前。
          url: <your-bucket-endpoint> # エンドポイント(例: oss-cn-hangzhou-internal.aliyuncs.com)。
          otherOpts: "-o umask=022 -o max_stat_cache_size=0 -o allow_other"
          path: <your-model-path> # モデルパス(この例では /models/DeepSeek-R1-GPTQ-INT8/)。
    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: llm-model
    spec:
      accessModes:
        - ReadOnlyMany
      resources:
        requests:
          storage: 30Gi
      selector:
        matchLabels:
          alicloud-pvname: llm-model

ステップ 2: ACS GPU 計算能力に基づいてモデルをデプロイする

  1. 次のコマンドを実行して、DeepSeek-R1-GPTQ-INT8 モデルを vLLM フレームワーク上の推論サービスとしてデプロイし、RDMA を使用して推論サービスを高速化します。

    推論サービスは、OpenAI 互換の HTTP API を公開します。次のコードを実行して、モデルパラメーターファイルを特別なデータセットとして扱い、推論サービスを実行するコンテナーの指定されたパス (/data/DeepSeek-R1-GPTQ-INT8) にマウントします。--max_model_len は、モデルで処理できるトークンの最大長を指定します。長さを増やすと、パフォーマンスが向上します。ただし、これにより GPU メモリの使用量も増加します。DeepSeek-R1-GPTQ-INT8 モデルでは、長さを 128000 前後の値に設定し、--gpu-memory-utilization を調整することをお勧めします。

    kubectl apply -f- <<EOF
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: deepseek-r1
      namespace: default
      labels:
        app: deepseek-r1
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: deepseek-r1
      strategy:
        type: RollingUpdate
        rollingUpdate:
          maxSurge: 25%
          maxUnavailable: 25%
      template:
        metadata:
          labels:
            app: deepseek-r1
            alibabacloud.com/compute-class: gpu
            # example-model は GPU モデルを示します。実際の GPU モデル(例: T4)に置き換えます。
            alibabacloud.com/gpu-model-series: <example-model>
            # パフォーマンス専有型 RDMA ネットワークでアプリケーションを実行します。RDMA でサポートされている GPU モデルについては、チケットを送信してください。
            alibabacloud.com/hpn-type: "rdma"
        spec:
          imagePullSecrets:
          - name: <PDSA から取得したシークレット>
          containers:
          - name: llm-ds-r1
            image: <PDSA から取得したベースイメージ>
            imagePullPolicy: IfNotPresent
            command:
            - sh
            - -c
            - "vllm serve /data/DeepSeek-R1-GPTQ-INT8 --port 8000 --trust-remote-code --served-model-name ds --max-model-len 128000 --quantization moe_wna16 --gpu-memory-utilization 0.98 --tensor-parallel-size 16"
            resources:
              limits:
                alibabacloud.com/gpu: "16"
                cpu: "64"
                memory: 512Gi
              requests:
                alibabacloud.com/gpu: "16"
                cpu: "64"
                memory: 512Gi
            volumeMounts:
            - name: llm-model
              mountPath: /data/DeepSeek-R1-GPTQ-INT8
            - name: shm
              mountPath: /dev/shm
          restartPolicy: Always
          terminationGracePeriodSeconds: 30
          volumes:
          - name: llm-model
            persistentVolumeClaim:
              claimName: llm-model
          - name: shm
            emptyDir:
              medium: Memory
              sizeLimit: 32Gi
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: deepseek-r1
    spec:
      type: ClusterIP
      selector:
        app: deepseek-r1
      ports:
        - protocol: TCP
          port: 8000
          targetPort: 8000
    EOF

ステップ 3: 推論サービスを確認する

  1. kubectl port-forward を実行して、ローカル環境と推論サービス間のポート フォワーディングを構成します。

    説明

    kubectl port-forward を使用して設定されたポート フォワーディングは、本番環境では信頼性、安全性、または拡張性がありません。開発とデバッグのみを目的としています。本番環境でポート フォワーディングを設定するために、このコマンドを使用しないでください。ACK クラスターの本番で使用されるネットワーキングソリューションの詳細については、「Ingress 管理」をご参照ください。

    kubectl port-forward svc/deepseek-r1 8000:8000

    予期される結果:

    Forwarding from 127.0.0.1:8000 -> 8000
    Forwarding from [::1]:8000 -> 8000
  2. 推論サービスにリクエストを送信します。

    curl http://localhost:8000/v1/chat/completions \
      -H "Content-Type: application/json" \
      -d '{
        "model": "ds",
        "messages": [
          {
            "role": "user",
            "content": "Write a letter to my daughter from the future 2035 and tell her to study science and technology well, be the master of science and technology, and promote the development of science and technology and economy. She is now in grade 3."
          }
        ],
        "max_tokens": 1024,
        "temperature": 0.7,
        "top_p": 0.9,
        "seed": 10
      }'

    予期される結果:

    {"id":"chatcmpl-53613fd815da46df92cc9b92cd156146","object":"chat.com pletion","created":1739261570,"model":"deepseek-r1","choices":[{"index":0,"message":{"role":"assistant","content":"<think>\nOK. The user needs to write a letter to his third-grade daughter from 2035 in the future, and convey three key messages at the same time: learn technology well, be the master of technology, and promote technology and economic development. First, I have to consider that the tone of the letter should be kind and hopeful, while reflecting a sense of future technology. \n\nConsidering that the daughter is now in the third grade, the content should not be too complicated and the language should be simple and easy to understand. At the same time, let the daughter feel the importance of science and technology and spike her interests in science and technology. It may be necessary to start from her daily life and give some examples that she may have come into contact with, such as electronic products, the Internet, etc., so that she can resonate more easily. \n\nNext, I have to think about how to structure this letter. It may start with welcoming her to receive this letter, and then introduce the development of future technology, such as smart robots and smart homes. Then it emphasizes the importance of learning science and technology, and encourages her to become the master of science and technology and participate in the development of science and technology. Finally, express the expectations and blessings. \n\nIn terms of content, it is necessary to highlight the impact of technology on life, such as smart assistants, smart homes, new energy vehicles, etc. These are all children may have heard of, but the specific details may need to be simplified to avoid being too technical and keep them interesting. \n\nAt the same time, the letter should mention the impact of science and technology on the economy, such as economic growth, job creation, etc., but it should be presented in a positive and encouraging way, so that the daughter can feel the benefits of science and technology, rather than a simple digital game. \n\nFinally, the ending part should be warm, express her pride and expectation, and encourage her to pursue the future bravely and become a leader in science and technology. \n\nIn general, this letter needs to be educational, interesting and encouraging, using simple and clear language, combined with specific examples of future technology, so that my daughter can feel the charm of technology and the importance of learning in a relaxed reading. \n</think>\n\nDear Future 2035: \n\nHello!  \n\nFirst, I want to tell you a good news: the earth has entered a new era!  By 2035, technology will no longer be the story of science fiction, but part of our every day life. Today, I am writing this letter to tell you some secrets about the future and how you should live and learn in this world of rapid development of science and technology. \n\n### 1. **Technology is around you**\n In 2035, technology is everywhere. Each of us can have an intelligent assistant, like an always-available teacher, ready to answer your questions. With a simple app, you can control the smart home devices in your home: turn on and off the lights, adjust the temperature, and even cook, all on your instruction!  \n   \n   Also, you may have heard about it: intelligent robots. These robots can not only help us to complete the tedious work, but also play a great part in learning and entertainment. They can chat with you, study with you, and even help you solve math problems!  Imagine that when you encounter a difficult problem, the robot will patiently teach you how to solve the problem step by step, isn't it great?  \n\n### 2. ** the importance of learning science and technology **\n in the future 2035, science and technology has become the main driving force to promote social development. Every industry is being transformed by technology: doctors can use advanced medical equipment early to detect illnesses; teachers can use online classrooms to enable students to learn global knowledge without leaving home; farmers can use smart devices to accurately manage their fields and ensure that every tree receives the best care. So, I want to tell you that learning technology is the most important task for every child. Science and technology can not only make you master more knowledge, but also make you become the future master. You will have the opportunity to create new technologies and change our lives!  \n\n### 3. **Be the master of science and technology**\n In 2035, the world of science and technology needs everyone's strength. You don't need to be a company executive, just be yourself. You can use your wisdom and hands to promote the development of science and technology. For example, you can participate in technological innovation competitions in schools and design smarter robots; you can invent some small inventions at home to make life more convenient. \n\n   It is important that you have the courage to try new things and explore the unknown. The world of science and technology is infinitely vast, and everyone can find their place here. \n\n### 4. ** About Economy **\n In 2035, the economy will become more prosperous due to the development of science and technology. Smart cities will make our lives more efficient, new energy vehicles will make our travel more environmentally friendly, and medical technology will better protect our health. \n\n   So, when you stand at the beginning of this era, you should know that technology is not only changing the way we live, but also creating opportunities for the future. \n\n### 5. **My expectations**\n    I hope that in the future you can love science and technology, understand science and technology, master science and technology. Not only do you have to learn how to use technology, but you have to understand the principles and the stories behind it. When you grow up, you may become a leader in the field of science and technology, leading us to a brighter future. \n\n   The future world needs you!  Are you ready for the challenge?  \n\nFinally, I want to tell you that you are smarter, braver and more potential than anyone else today. Although the road ahead is very long, as long as you are willing to work hard, you will certainly be able to realize your dream. \n\nDear daughter in 2035, fight!  \n \nYour grandpa ","tool_calls":[]},"logprobs":null,"finish_reason":"stop","stop_reason":null}],"usage":{"prompt_tokens":40,"total_tokens":1034,"completion_tokens":994,"prompt_tokens_details":null}}

(オプション) ステップ 4: 環境を削除する

推論サービスが不要になった場合は、速やかに環境を削除してください。

  1. 推論ワークロードとサービスを削除します。

    kubectl delete deployment deepseek-r1
    kubectl delete service deepseek-r1
  2. PV と PVC を削除します。

    kubectl delete pvc llm-model
    kubectl delete pv llm-model

    予期される結果:

    persistentvolumeclaim "llm-model" deleted
    persistentvolume "llm-model" deleted

関連情報