[PYTHON] How to perform learning in SageMaker without session timeout

Trouble content

When I use SageMaker's jupyter Notebook for several hours, the session expires in 12h and the cell output disappears.

solution

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.

reference

AWS Developer Forums: Jupyter Notebook Session Expiring after ...

Recommended Posts

How to perform learning in SageMaker without session timeout
How to handle session in SQLAlchemy
How to improve model metric monitoring in Amazon SageMaker
How to develop in Python
How to adapt multiple machine learning libraries in one shot
[TensorFlow 2 / Keras] How to run learning with CTC Loss in Keras
[Python] How to do PCA in Python
How to use classes in Theano
How to write soberly in pandas
How to collect images in Python
How to update Spyder in Anaconda
Deep learning to start without GPU
How to reflect CSS in Django
How to kill processes in bulk
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
How to run TensorFlow 1.0 code in 2.0
How to handle Japanese in Python
People memorize learned knowledge in the brain, how to memorize learned knowledge in machine learning
How to log in to Docker + NGINX
How to collect machine learning data
How to call PyTorch in Julia
How to install Deep Learning framework Caffe on Mac in CPU mode
How to use calculated columns in CASTable
[Introduction to Python] How to use class in Python?
How to suppress display error in matplotlib
scikit-learn How to use summary (machine learning)
How to collect Twitter data without programming
How to access environment variables in Python
How to dynamically define variables in Python
How to do R chartr () in Python
How to delete expired sessions in Django
[Itertools.permutations] How to put permutations in Python
How to use Google Test in C
How to implement nested serializer in drf-flex-fields
How to study deep learning G test
How to execute commands in jupyter notebook
How to do'git fetch --tags' in GitPython
How to get a stacktrace in python
How to display multiplication table in python
How to extract polygon area in Python
How to reassign index in pandas dataframe
How to check opencv version in python
How to enable SSL (TLS) in Apache
How to use Anaconda interpreter in PyCharm
How to specify non-check target in Flake8
How to handle consecutive values in MySQL
How to switch python versions in cloud9
How to adjust image contrast in Python
How to use __slots__ in Python class
How to dynamically zero pad in Python
How to enjoy Coursera / Machine Learning (Week 10)
How to do Server-Sent Events in Django
How to use regular expressions in Python
How to implement Scroll View in pythonista 1
How to convert DateTimeField format in Django
How to use Map in Android ViewPager
How to display Hello world in python
How to read CSV files in Pandas