【问题标题】:Uploading additional files for inference from local - Sagemaker deploy从本地上传其他文件以进行推理 - Sagemaker 部署
【发布时间】:2022-02-23 09:22:27
【问题描述】:

我正在尝试将本地 tensorflow 模型部署到 sagemaker 端点。我想包含自定义推理代码来转换输入数据。鉴于模型已经过训练并且已经位于 S3 存储桶中,我可以运行以下命令,将模型正确部署到端点:

tensorflow_model = Model(
        model_data=saved_model,
        entry_point='src/development/document_matcher/inference.py',
        source_dir ='./src/development/document_matcher',      
        role=role, 
        framework_version=tf_framework_version
        )

推理文件工作正常;但是,我还需要模型的词汇表来正确转换传入的数据。这就是我要使用 source_dir 上传的内容。

我的目录结构如下:

- src
 - development
  -document_matcher
   - inference.py
   - total_vocab.pkl

我需要让我的推理脚本在运行时可以访问 total_vocab.pkl。但是,inference.py 无法找到它。我是否误解了 sagemaker 的工作原理?

【问题讨论】:

    标签: python amazon-web-services tensorflow amazon-sagemaker


    【解决方案1】:

    根据SageMaker TF container,您的total_vocab.pkl 应该在/opt/ml/model/code

    如果不是,看到你的 inference.py 文件正在运行,我建议添加一些打印语句来列出目录。

    【讨论】:

      猜你喜欢
      • 2021-01-15
      • 1970-01-01
      • 1970-01-01
      • 2013-05-16
      • 2018-08-12
      • 2012-08-15
      • 1970-01-01
      • 2019-11-12
      相关资源
      最近更新 更多