View a markdown version of this page

Neuron タスク定義の例 - Amazon Elastic Container Service

Neuron タスク定義の例

マネージドデバイスの割り当ての例

次の例は、resourceRequirements パラメータを使用してインスタンス上のすべての Neuron デバイスをリクエストするタスク定義を示しています。このアプローチは、マネージドインスタンスでのみ使用できます。

{ "family": "ecs-neuron", "requiresCompatibilities": ["MANAGED_INSTANCES"], "networkMode": "awsvpc", "cpu": "8192", "memory": "16384", "executionRoleArn": "${YOUR_EXECUTION_ROLE}", "containerDefinitions": [ { "name": "neuron-inference", "image": "763104351884.dkr.ecr.us-east-1.amazonaws.com/huggingface-vllm-inference-neuronx:0.11.0-optimum0.4.5-neuronx-py310-sdk2.26.1-ubuntu22.04", "essential": true, "command": [ "--model", "${YOUR_HUGGING_FACE_MODEL_ID}", "--port", "8080", "--tensor-parallel-size", "2", "--allow-non-cached-model" ], "portMappings": [ { "containerPort": 8080, "protocol": "tcp" } ], "resourceRequirements": [ { "type": "NeuronDevice", "value": "ALL" } ] } ] }

この例では、コンテナイメージに AWS Neuron 用に最適化された vLLM 推論サーバーが含まれます。イメージのエントリポイントは、HuggingFace からモデルをダウンロードして Neuron 用にコンパイルし、ポート 8080 で OpenAI 互換 API サーバーを起動します。${YOUR_HUGGING_FACE_MODEL_ID} をお使いの HuggingFace モデル ID に置き換えます。

手動デバイスの仕様の例

次の例は、EC2 起動タイプと linuxParameters.devices を使用して Neuron デバイスパスを指定するための inf1.xlarge の Linux タスク定義を示しています。

{ "family": "ecs-neuron", "requiresCompatibilities": ["EC2"], "placementConstraints": [ { "type": "memberOf", "expression": "attribute:ecs.os-type == linux" }, { "type": "memberOf", "expression": "attribute:ecs.instance-type == inf1.xlarge" } ], "executionRoleArn": "${YOUR_EXECUTION_ROLE}", "containerDefinitions": [ { "entryPoint": [ "/usr/local/bin/entrypoint.sh", "--port=8500", "--rest_api_port=9000", "--model_name=resnet50_neuron", "--model_base_path=s3://amzn-s3-demo-bucket/resnet50_neuron/" ], "portMappings": [ { "hostPort": 8500, "protocol": "tcp", "containerPort": 8500 }, { "hostPort": 8501, "protocol": "tcp", "containerPort": 8501 }, { "hostPort": 0, "protocol": "tcp", "containerPort": 80 } ], "linuxParameters": { "devices": [ { "containerPath": "/dev/neuron0", "hostPath": "/dev/neuron0", "permissions": [ "read", "write" ] } ], "capabilities": { "add": [ "IPC_LOCK" ] } }, "cpu": 0, "memoryReservation": 1000, "image": "763104351884.dkr.ecr.us-east-1.amazonaws.com/tensorflow-inference-neuron:1.15.4-neuron-py37-ubuntu18.04", "essential": true, "name": "resnet50" } ] }