有没有办法在笔记本启动时使用 sagemaker 生命周期配置 运行 EMR 集群
Is there a way to use sagemaker lifecycle configuration to run an EMR cluster on notebook start
我想在每次启动 sagemaker notebook 时启动一个 EMR 集群。
但是,我发现生命周期配置脚本不能 运行 超过 5 分钟。遗憾的是,我的 EMR 集群需要超过 5 分钟才能启动。这是一个问题,因为我需要等待集群启动才能检索主 IP 地址(该 IP 地址随后用于配置 sagemaker notebbok 和集群之间的连接)。
下面是生命周期配置脚本中 运行 代码的摘录。
是否有人遇到过类似的问题并找到了解决方案?
job_flow_id = client.run_job_flow(**CLUSTER_CONFIG)['JobFlowId']
...
...
# Retrieve private Ip of master node for later use
master_instance = client.list_instances(ClusterId=job_flow_id, InstanceGroupTypes=['MASTER'])['Instances'][0]
master_private_ip = master_instance['PrivateIpAddress']
# Send to sagemaker the config file in order to tell him how to communicate with spark
s3 = boto3.client('s3')
file_object = s3.get_object(Bucket='dataengine', Key='emr/example_config.json')
data = json.loads(file_object['Body'].read().decode('utf-8'))
data['kernel_python_credentials']['url'] = 'http://{}:8998'.format(master_private_ip)
data['kernel_scala_credentials']['url'] = 'http://{}:8998'.format(master_private_ip)
data['kernel_r_credentials']['url'] = 'http://{}:8998'.format(master_private_ip)
with open('./sparkmagic/config.json', 'w') as outfile:
json.dump(data, outfile)```
AWS CloudFormation 将为您自动化所有这些,并让您也传递 IP 地址。
你似乎喜欢 Python,我推荐对流层:https://github.com/cloudtools/troposphere。编写Python代码,生成一个CloudFormation模板,运行它:)
朱利安 (AWS)
您还可以考虑在生命周期配置中使用 nohup 在后台执行您的脚本,这样您就不会被 5 分钟限制阻塞。
如果您还有其他需要帮助的地方,请告诉我们。
谢谢,
汉族
我想在每次启动 sagemaker notebook 时启动一个 EMR 集群。 但是,我发现生命周期配置脚本不能 运行 超过 5 分钟。遗憾的是,我的 EMR 集群需要超过 5 分钟才能启动。这是一个问题,因为我需要等待集群启动才能检索主 IP 地址(该 IP 地址随后用于配置 sagemaker notebbok 和集群之间的连接)。
下面是生命周期配置脚本中 运行 代码的摘录。
是否有人遇到过类似的问题并找到了解决方案?
job_flow_id = client.run_job_flow(**CLUSTER_CONFIG)['JobFlowId']
...
...
# Retrieve private Ip of master node for later use
master_instance = client.list_instances(ClusterId=job_flow_id, InstanceGroupTypes=['MASTER'])['Instances'][0]
master_private_ip = master_instance['PrivateIpAddress']
# Send to sagemaker the config file in order to tell him how to communicate with spark
s3 = boto3.client('s3')
file_object = s3.get_object(Bucket='dataengine', Key='emr/example_config.json')
data = json.loads(file_object['Body'].read().decode('utf-8'))
data['kernel_python_credentials']['url'] = 'http://{}:8998'.format(master_private_ip)
data['kernel_scala_credentials']['url'] = 'http://{}:8998'.format(master_private_ip)
data['kernel_r_credentials']['url'] = 'http://{}:8998'.format(master_private_ip)
with open('./sparkmagic/config.json', 'w') as outfile:
json.dump(data, outfile)```
AWS CloudFormation 将为您自动化所有这些,并让您也传递 IP 地址。
你似乎喜欢 Python,我推荐对流层:https://github.com/cloudtools/troposphere。编写Python代码,生成一个CloudFormation模板,运行它:)
朱利安 (AWS)
您还可以考虑在生命周期配置中使用 nohup 在后台执行您的脚本,这样您就不会被 5 分钟限制阻塞。
如果您还有其他需要帮助的地方,请告诉我们。
谢谢,
汉族