如何加载 Sagemaker 中不可用的 python 模块? [英] How do I load python modules which are not available in Sagemaker?
本文介绍了如何加载 Sagemaker 中不可用的 python 模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想安装 Sagemaker 平台中不提供的 spacy.我应该如何 pip 安装它?
I want to install spacy which is not available as part of the Sagemaker platform. How should can I pip install it?
推荐答案
在创建模型时,您可以将 requirements.txt 指定为环境变量.
When creating you model, you can specify the requirements.txt as an environment variable.
例如.
env = {
'SAGEMAKER_REQUIREMENTS': 'requirements.txt', # path relative to `source_dir` below.
}
sagemaker_model = TensorFlowModel(model_data = 's3://mybucket/modelTarFile,
role = role,
entry_point = 'entry.py',
code_location = 's3://mybucket/runtime-code/',
source_dir = 'src',
env = env,
name = 'model_name',
sagemaker_session = sagemaker_session,
)
这将确保在创建 docker 容器之后运行需求文件,然后再在其上运行任何代码.
This would ensure that the requirements file is run after the docker container is created, before running any code on it.
这篇关于如何加载 Sagemaker 中不可用的 python 模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文