Last active
June 1, 2018 18:22
-
-
Save samwan/75673c2924aa4836315a7ad01d2414d5 to your computer and use it in GitHub Desktop.
Attempting auto-shutdown for Paperspace Gradient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Adapting this auto-shutdown tutorial to work with Gradient Notebooks, which don't provide ssh access: https://paperspace.zendesk.com/hc/en-us/articles/115002807447" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Update apt-get and install xprintidle. \n", | |
"# Pass \"-y\" argument to say Yes at the prompts, otherwise notebook will freeze.\n", | |
"!apt-get -y update\n", | |
"!apt-get -y install xprintidle" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Download shutdown script files and extract to root.\n", | |
"# Gradient notebooks run as root, so there's no need to sudo.\n", | |
"!curl https://s3.amazonaws.com/ps.public.resources/tools/idle_shutdown.tgz | tar -xzv -C /" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Update idle time\n", | |
"# !echo \"IDLE_TIME=1\" > /etc/default/idle_shutdown\n", | |
"!cat /etc/default/idle_shutdown" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# This doesn't work\n", | |
"!bash /usr/local/bin/idle_shutdown.sh" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [], | |
"source": [ | |
"# This doesn't work\n", | |
"import subprocess\n", | |
"subprocess.call(['/usr/local/bin/idle_shutdown.sh'], cwd=\"/\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# This doesn't work either \n", | |
"import os\n", | |
"import sys\n", | |
"os.system(\"bash /usr/local/bin/idle_shutdown.sh\")" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.4" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment