如何设置 sagemaker triton 推理的配置文件?

问题描述 投票:0回答:1

我一直在寻找示例,并从aws遇到了这个,https://github.com/aws/amazon-sagemaker-examples/blob/main/sagemaker-triton/ensemble/sentence-transformer-trt/examples/ensemble_hf/ bert-trt/config.pbtxt。基于这个例子,我们需要定义输入和输出,以及这些输入和输出的数据类型。该示例不清楚暗淡(可能是维度)代表什么,它是输入数组中的元素数量吗?另外,max_batch_size 是什么?在底部,我们必须指定实例组并将种类设置为 KIND_GPU,我假设如果我们使用基于 cpu 的实例,我们可以将其更改为 cpu。我们需要指定我们要使用多少个 cpu 吗?

name: "bert-trt"
platform: "tensorrt_plan"
max_batch_size: 16
input [
  {
    name: "token_ids"
    data_type: TYPE_INT32
    dims: [128]
  }...
]
output [
  {
    name: "output"
    data_type: TYPE_FP32
    dims: [128, 384]
  }...
]
instance_group [
    {
      kind: KIND_GPU
    }
  ]

我已经测试了给定的示例,但是如果我们想使用基于文本的输入并在服务器中进行标记化,那么这个 config.pbtxt 文件是什么样的?

nvidia amazon-sagemaker inference tritonserver triton
1个回答
0
投票

max_batch_size
条目指定与 Triton 动态批处理一起使用的最大批量大小。 Triton 会将多个请求合并到一个批次中,以提高吞吐量。

如果将

max_batch_size
设置为零,则需要在 config.pbtxt 中定义批次维度,即

name: "bert-trt"
platform: "tensorrt_plan"
max_batch_size: 0
input [
  {
    name: "token_ids"
    data_type: TYPE_INT32
    dims: [-1, 128]
  }...
]

在这种情况下-1意味着批次维度是可变的(您也可以将序列维度设置为-1)

为了在服务器上进行标记化,您需要创建一个 python 后端和一个集成模型,或者对标记器和模型使用 python

name: "tokenizer"
max_batch_size: 0
backend: "python"

input [
    {
        name: "text"
        data_type: TYPE_STRING
        dims: [ -1 ]
    }
]

我发现 triton-ensemble-model-for-deploying-transformers-into-product 是一个很好的资源。

© www.soinside.com 2019 - 2024. All rights reserved.