从Lambda函数或Sagemaker Lifecycle Config运行.ipynb文件

时间:2018-09-12 04:13:30

标签: jupyter-notebook amazon-sagemaker

启动Sagemaker实例时 ipynb文件。 当前状态是: Cloudwatch(成功)-> Lambda(成功)-> Sagemaker实例(成功)->运行特定笔记本(失败)

1。我尝试将“ Sagemaker生命周期”配置与代码结合使用

jupyter nbconvert --execute prediction-12hr.ipynb --ExecutePreprocessor.kernel_name=conda_tensorflow_p36

但出现错误

[NbConvertApp] Converting notebook prediction-12hr.ipynb to html [NbConvertApp] Executing notebook with kernel: conda_tensorflow_p36
...
raise NoSuchKernel(kernel_name) jupyter_client.kernelspec.NoSuchKernel: No such kernel named conda_tensorflow_p36

正在运行

`!conda env list'
conda environments:

base * /home/ec2-user/anaconda3
JupyterSystemEnv /home/ec2-user/anaconda3/envs/JupyterSystemEnv
chainer_p27 /home/ec2-user/anaconda3/envs/chainer_p27
chainer_p36 /home/ec2-user/anaconda3/envs/chainer_p36
mxnet_p27 /home/ec2-user/anaconda3/envs/mxnet_p27
mxnet_p36 /home/ec2-user/anaconda3/envs/mxnet_p36
python2 /home/ec2-user/anaconda3/envs/python2
python3 /home/ec2-user/anaconda3/envs/python3
pytorch_p27 /home/ec2-user/anaconda3/envs/pytorch_p27
pytorch_p36 /home/ec2-user/anaconda3/envs/pytorch_p36
tensorflow_p27 /home/ec2-user/anaconda3/envs/tensorflow_p27
tensorflow_p36 /home/ec2-user/anaconda3/envs/tensorflow_p36

Also tried injecting a python/bash code to run the instance startup, pausing the start-up code to wait untill conda instance is setup by sagemaker.
Still no luck

有人可以建议一个计划以任何方式运行.ipynb文件。

2 个答案:

答案 0 :(得分:0)

尝试激活笔记本计算机依赖的相关Python virtualenv。

source /home/ec2-user/anaconda3/envs/tensorflow_p36/bin/activate
jupyter nbconvert --execute ...

了解更多How to activate virtualenv?

答案 1 :(得分:0)

您可以尝试在该环境中激活tensorflow_p36 env并执行笔记本文件吗?这样,您不必指定内核。

source activate tensorflow_p36
jupyter nbconvert --execute prediction-12hr.ipynb