如何加载Sagemaker中不可用的python模块? [英] How do I load python modules which are not available in Sagemaker?

查看:210
本文介绍了如何加载Sagemaker中不可用的python模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想安装Sagemaker平台不提供的spacy.我应该如何点安装它?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆