Skip to content

Instantly share code, notes, and snippets.

@fauberso
Last active October 1, 2021 10:46
Show Gist options
  • Save fauberso/b4f7e632dd32262ce604c28fc67ec591 to your computer and use it in GitHub Desktop.
Save fauberso/b4f7e632dd32262ce604c28fc67ec591 to your computer and use it in GitHub Desktop.
SageMaker: Auto Stop instance, and add Conda packages from conda-forge
#!/bin/bash
set -e
# PARAMETERS
IDLE_TIME=7200
echo "Fetching the autostop script"
wget https://raw.githubusercontent.com/aws-samples/amazon-sagemaker-notebook-instance-lifecycle-config-samples/master/scripts/auto-stop-idle/autostop.py
echo "Starting the SageMaker autostop script in cron"
(crontab -l 2>/dev/null; echo "*/5 * * * * /usr/bin/python $PWD/autostop.py --time $IDLE_TIME --ignore-connections") | crontab -
echo "Installing Dependencies"
export PATH="/home/ec2-user/anaconda3/condabin:$PATH"
conda config --add channels conda-forge
conda config --set channel_priority strict
conda install --yes numpy-indexed smart_open &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment