Skip to main content

Shutdown your SageMaker instance when it's not active

Project description

🥊 sagemaker-knockout

Knock the SageMaker instance out when it's not active!

❓ Why?

Are you enjoying big powerful, pricey SageMaker instances to experiment with your data, but often forget to shut it down after you're done? 💸💸💸😳

sagemaker-knockout will knock your machine out when it's inactive! 👾

⚙️ How does it work?

It tracks three metrics to detect the activity. If any of them report as active, machine will not shut down.

  • Jupyter connections - if Jupyter server has incoming connections opened, it means you have an open console or notebook tab (with laptop opened). We do not want to shut the machine down in that case
  • GPU usage - if you've left your laptop closed, but are running GPU intensive operations, we'll detect that (threshold is set to 5%)
  • GPU usage - if you've left your laptop closed, but are running CPU intensive operations, we'll detect that (threshold is set to 10%)

🧠 Setup

In order to make sure you don't need to remember to run this program to shut down your machine 😅, the most covenient setup is to change the SageMaker's lifecycle configuration.

Add this snippet of code to "Start notebook" script:

#!/bin/bash

# make the script fail if anything fails
set -e

# set up the language so we don't support just ASCII
export LC_ALL=en_US.utf-8
export LANG=en_US.utf-8

echo "Setting up 🥊 sagemaker-knockout..."
pip3 install sagemaker-knockout
python3 -m sagemaker_knockout run --daemonize --max-inactive-minutes 60
sleep 3
python3 -m sagemaker_knockout check-daemon

As you can guess, we are running this program in the background (daemonizing) and you can change the inactivity period after which the shutdown process kicks in. Feel free to change it to any number that suits you (yes, I do like long lunch breaks 🍔).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sagemaker-knockout-0.0.7.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sagemaker_knockout-0.0.7-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file sagemaker-knockout-0.0.7.tar.gz.

File metadata

  • Download URL: sagemaker-knockout-0.0.7.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.4

File hashes

Hashes for sagemaker-knockout-0.0.7.tar.gz
Algorithm Hash digest
SHA256 748dae5cdd5349422f6262dcf4725d5cc0c9fc39dfb8c397990b959c3a68bdfe
MD5 de881e50299642bced7c45d0aec27362
BLAKE2b-256 a242116c6aa80056052a78f2153d937379d0e3cac82c9b96dc88ccae5bbc6d42

See more details on using hashes here.

File details

Details for the file sagemaker_knockout-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: sagemaker_knockout-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.4

File hashes

Hashes for sagemaker_knockout-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a6764da626697097b3314157e229c56c5aedd3e0fe40b1589cecf859a41dfc2e
MD5 aba5d2595ed5ee71317738a1cf7e4ba6
BLAKE2b-256 af53759cd2bd9e75d97fde49c96d16868682045bffcaf527ea4eb3be3c727c8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page