When I use SageMaker's jupyter Notebook for several hours, the session expires in 12h and the cell output disappears.
Basically, there is no choice but to make it a script and then execute it.
In a regular notebook
!python xxxx.py >> log.txt
You can execute it as follows, but if you want to use any conda environment, you can activate it as follows.
sh-4.2$ conda info --envs
# conda environments:
#
base /home/ec2-user/anaconda3
JupyterSystemEnv * /home/ec2-user/anaconda3/envs/JupyterSystemEnv
R /home/ec2-user/anaconda3/envs/R
amazonei_mxnet_p27 /home/ec2-user/anaconda3/envs/amazonei_mxnet_p27
amazonei_mxnet_p36 /home/ec2-user/anaconda3/envs/amazonei_mxnet_p36
amazonei_tensorflow_p27 /home/ec2-user/anaconda3/envs/amazonei_tensorflow_p27
amazonei_tensorflow_p36 /home/ec2-user/anaconda3/envs/amazonei_tensorflow_p36
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
sh-4.2$ source /home/ec2-user/anaconda3/bin/activate pytorch_p36
(pytorch_p36) sh-4.2$
Now you can use any environment from the jupyterlab terminal.
AWS Developer Forums: Jupyter Notebook Session Expiring after ...
Recommended Posts