我想安装 Sagemaker 平台不提供的 spacy。我应该如何 pip 安装它?
问问题
2323 次
2 回答
10
创建模型时,您可以将 requirements.txt 指定为环境变量。
例如。
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 容器之后运行需求文件,然后再在其上运行任何代码。
于 2018-04-05T15:23:55.117 回答
5
拉曼给出了很好的答案。我想添加另一种在训练实例中指定所需 python 模块的方法,以防有人在寻找。
tf_estimator = TensorFlow(entry_point='tf-train.py', role='SageMakerRole',
training_steps=10000, evaluation_steps=100,
train_instance_count=1,
source_dir='./',
requirements_file='requirements.txt',
train_instance_type='ml.p2.xlarge')
source_dir
并且requirements_file
必须定义两者才能使其正常工作。路径是笔记本实例。如果requirements.txt
与笔记本在同一目录下,则只需使用 './'
文档在这里。
于 2018-09-05T05:36:30.010 回答