Container Compute Service (ACS) は、効率的かつ柔軟なコンテナー管理およびオーケストレーション機能を提供し、大規模言語モデル (LLM) をデプロイして LLM 推論サービスを実行できるようにします。このトピックでは、ACS のコンテナーイメージから LLM 推論サービスをデプロイする方法について説明します。
準備
ACS に LLM 推論サービスをデプロイするためのコンテナーイメージの情報を入手します。
左側のナビゲーションウィンドウで、[artifact Center] をクリックします。
[リポジトリ名] 検索ボックスに
llm-inferenceと入力し、egslingjun/llm-inferenceまたはegslingjun/inference-nv-pytorchイメージを見つけます。egslingjun/llm-inferenceイメージとegslingjun/inference-nv-pytorchイメージは、vLLM 推論ライブラリと DeepGPU-LLM 推論エンジンをサポートしています。これらのイメージは、Llama モデル、ChatGLM モデル、Baichuan モデル、Qwen モデルなどの LLM の推論環境を迅速にセットアップするのに役立ちます。イメージは毎月更新されます。次の表に、コンテナーイメージの詳細を示します。イメージ名
イメージタグ
コンポーネント情報
イメージアドレス
llm-inference
vllm0.4.2-deepgpu-llm24.5-pytorch2.3.0-cuda12.1-ubuntu22.04
ベースイメージ: Ubuntu 22.04
Python 3.10
Torch 2.3.0
CUDA 12.1
vLLM 0.4.2
deepgpu-llm 24.5+pt2.3cu121
egslingjun-registry.cn-wulanchabu.cr.aliyuncs.com/egslingjun/llm-inference:vllm0.4.2-deepgpu-llm24.5-pytorch2.3.0-cuda12.1-ubuntu22.04
vllm0.4.3-deepgpu-llm24.6-pytorch2.4.0-cuda12.4-ubuntu22.04
ベースイメージ: Ubuntu 22.04
Python 3.10
Torch 2.4.0
CUDA 12.4.1
vLLM 0.4.3
deepgpu-llm 24.6+pt2.4cu124
egslingjun-registry.cn-wulanchabu.cr.aliyuncs.com/egslingjun/llm-inference:vllm0.4.3-deepgpu-llm24.6-pytorch2.4.0-cuda12.4-ubuntu22.04
vllm0.5.4-deepgpu-llm24.7-pytorch2.4.0-cuda12.4-ubuntu22.04
ベースイメージ: Ubuntu 22.04
Python 3.10
Torch 2.4.0
CUDA 12.4.1
vLLM 0.5.4
deepgpu-llm 24.7.2+pt2.4cu124
egslingjun-registry.cn-wulanchabu.cr.aliyuncs.com/egslingjun/llm-inference:vllm0.5.4-deepgpu-llm24.7-pytorch2.4.0-cuda12.4-ubuntu22.04
vllm0.6.3-post1-deepgpu-llm24.9-pytorch2.4.0-cuda12.4-ubuntu22.04
ベースイメージ: Ubuntu 22.04
Python 3.10
Torch 2.4.0
CUDA 12.4.1
vLLM 0.6.3.post1
deepgpu-llm 24.9+pt2.4cu124
egslingjun-registry.cn-wulanchabu.cr.aliyuncs.com/egslingjun/llm-inference:vllm0.6.3-post1-deepgpu-llm24.9-pytorch2.4.0-cuda12.4-ubuntu22.04
vllm0.6.4.post1-deepgpu-llm24.10-pytorch2.5.1-cuda12.4-ubuntu22.04-201412
ベースイメージ: Ubuntu 22.04
Python 3.10
Torch 2.5.1
CUDA 12.4.1
vLLM 0.6.4.post1
deepgpu-llm 24.10+pt2.5cu124
egslingjun-registry.cn-wulanchabu.cr.aliyuncs.com/egslingjun/llm-inference:vllm0.6.4.post1-deepgpu-llm24.10-pytorch2.5.1-cuda12.4-ubuntu22.04-201412
inference-nv-pytorch
25.01-vllm0.6.5-deepgpu-llm24.10-pytorch2.5-cuda12.4-20250121
ベースイメージ: Ubuntu 22.04
Python 3.10
Torch 2.5.1
CUDA 12.4.1
vLLM 0.6.5
deepgpu-llm 24.10+pt2.5cu124
egslingjun-registry.cn-wulanchabu.cr.aliyuncs.com/egslingjun/inference-nv-pytorch:25.01-vllm0.6.5-deepgpu-llm24.10-pytorch2.5-cuda12.4-20250121
NAS ファイルシステムを準備します。LLM は、モデルファイルを保存するために大量のディスク容量を必要とします。モデルファイルを保存するために NAS ボリュームを作成することをお勧めします。詳細については、「静的にプロビジョニングされた NAS ボリュームをマウントする」または「動的にプロビジョニングされた NAS ボリュームをマウントする」をご参照ください。この例では、静的にプロビジョニングされた NAS ボリュームを使用し、推奨ボリュームサイズは 20 GiB です。
次のパラメーターに基づいて PVC を作成します。詳細については、「PVC を作成する」をご参照ください。
パラメーター
例
[名前]
nas-test。
[割り当てモード]
[マウントターゲットドメイン名を使用する] を選択します。
[容量]
20 GiB。
[マウントターゲットドメイン名]
08cxxxxxxec-wxxxxxxcn-hangzhou.nas.aliyuncs.com
NAS ファイルシステムを ECS インスタンスにマウントします。詳細については、「NAS コンソールで NFS ファイルシステムをマウントする」をご参照ください。
次のコマンドを実行して、モデルを NAS ファイルシステムにダウンロードします。
cd /mnt pip install modelscope modelscope download --model Qwen/Qwen2.5-7B-Instruct --local_dir ./Qwen2.5-7B-Instruct説明この例で使用されている Qwen2.5-7B モデルのサイズは約 15 GB です。 100 Mbit/s でダウンロードするには 20 分かかります。より軽量な Qwen2.5-3B または Qwen2.5-0.5B モデルを選択できます。
modelscopeには Python 3.10 以降が必要です。デフォルトで Python 3.10 を使用しているため、Ubuntu 22.04 を実行する ECS インスタンスを購入することをお勧めします。Python 3.10 以降を使用するパブリックイメージまたはカスタムイメージを指定することもできます。
LLM 推論サービスをデプロイする
kubectl を使用して ACS クラスタに接続します。詳細については、「クラスタの kubeconfig ファイルを取得し、kubectl を使用してクラスタに接続する」をご参照ください。
次の内容に基づいて、your-deployment.yaml という名前のファイルを作成します。
説明この例で使用されている GPU モデルの詳細については、「GPU モデル」をご参照ください。
apiVersion: apps/v1 kind: Deployment metadata: labels: app: my-deployment name: my-deployment namespace: default spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: my-deployment template: metadata: labels: # GPU モデルを example-model に設定します。この値は参照用です。 alibabacloud.com/gpu-model-series: example-model # コンピューティングクラスを gpu に設定します。 alibabacloud.com/compute-class: gpu # BestEffort ポッドを使用する場合は、次のパラメーターを best-effort に設定します。 alibabacloud.com/compute-qos: default app: my-deployment spec: containers: - command: - sh - -c - python3 -m vllm.entrypoints.openai.api_server --model /mnt/Qwen2.5-7B-Instruct --trust-remote-code --tensor-parallel-size 1 --disable-custom-all-reduce image: egslingjun-registry.cn-wulanchabu.cr.aliyuncs.com/egslingjun/llm-inference:vllm0.5.4-deepgpu-llm24.7-pytorch2.4.0-cuda12.4-ubuntu22.04 imagePullPolicy: IfNotPresent #Always name: my-deployment resources: limits: cpu: 16 memory: 64Gi nvidia.com/gpu: "1" requests: cpu: 16 memory: 64Gi nvidia.com/gpu: "1" terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /mnt name: nas-test - mountPath: /dev/shm name: cache-volume dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 volumes: - name: nas-test persistentVolumeClaim: # PVC の内容。 claimName: nas-test - name: cache-volume emptyDir: medium: Memory sizeLimit: 64G --- apiVersion: v1 kind: Service metadata: annotations: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type: "internet" service.beta.kubernetes.io/alibaba-cloud-loadbalancer-ip-version: ipv4 labels: app: my-deployment name: svc-llm namespace: default spec: externalTrafficPolicy: Local ports: - name: serving port: 8000 protocol: TCP targetPort: 8000 selector: app: my-deployment type: LoadBalancer次のコマンドを実行して、LLM 推論タスクとサービスをデプロイします。
kubectl apply -f your-deployment.yamlイメージのサイズが原因で、モデルのデプロイには 20 分かかります。次のコマンドを実行して、デプロイの進行状況をクエリできます。
kubectl logs -f my-deployment-787b8xxxxx-xxxxx次の出力が返された場合、モデルは正常にデプロイされています。
INFO: Started server process [2] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) INFO 12-13 12:39:11 metrics.py:406] Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 0.0 tokens/s, Running: 0 reqs, Swapped: 0 reqs, Pending: 0 reqs, GPU KV cache usage: 0.0%, CPU KV cache usage: 0.0%. INFO 12-13 12:39:21 metrics.py:406] Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 0.0 tokens/s, Running: 0 reqs, Swapped: 0 reqs, Pending: 0 reqs, GPU KV cache usage: 0.0%, CPU KV cache usage: 0.0%. INFO 12-13 12:39:31 metrics.py:406] Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 0.0 tokens/s, Running: 0 reqs, Swapped: 0 reqs, Pending: 0 reqs, GPU KV cache usage: 0.0%, CPU KV cache usage: 0.0%. INFO 12-13 12:39:41 metrics.py:406] Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 0.0 tokens/s, Running: 0 reqs, Swapped: 0 reqs, Pending: 0 reqs, GPU KV cache usage: 0.0%, CPU KV cache usage: 0.0%.次のコマンドを実行して、サービスをクエリします。
kubectl get svc予期される結果:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 3h38m svc-llm LoadBalancer 10.0.143.103 112.xxx.xxx.177 8000/TCP 58sEXTERNAL-IPには、サービスを公開するために使用される IP アドレスが表示されます。テストのために、この IP アドレスを記録します。
LLM 推論サービスをテストする
次のコマンドを実行し、プロンプトを入力します。
export EXTERNAL_IP=112.xxx.xxx.177
curl http://$EXTERNAL_IP:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{ "model": "/mnt/Qwen2.5-7B-Instruct", "messages": [ {"role": "system", "content": "You are a friendly AI assistant"}, {"role": "user", "content": "Introduce deep learning"} ]}'予期される結果:
{"id":"chat-edab465b4b5547bda7xxxxxxxxxxxxxxx","object":"chat.completion","created":1734094178,"model":"/mnt/Qwen2.5-7B-Instruct","choices":[{"index":0,"message":{"role":"assistant","content":"Deep learning is a subset of machine learning that focuses on utilizing neural networks to process and study large amounts of data to enable computers to learn and make decisions as humans. Deep learning consists of CNN, RNN, and LSTM. These models can recognize and classify images, extract features, perform natural language processing, and event run speech recognition tasks. Deep learning applies to a wide array of industries, including image recognition, speech recognition, natural language processing, and computer vision.","tool_calls":[]},"logprobs":null,"finish_reason":"stop","stop_reason":null}],"usage":{"prompt_tokens":24,"total_tokens":130,"completion_tokens":106}}% この結果は、ACS GPU コンピューティング能力に基づいて LLM 推論サービスがデプロイされたことを示しています。
参考資料
vLLM の詳細については、「vllm-project」を参照してください。