Skip to content

Instantly share code, notes, and snippets.

@tejashah88
Last active November 24, 2019 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tejashah88/2df54459c719a3979d465059a4ead93c to your computer and use it in GitHub Desktop.
Save tejashah88/2df54459c719a3979d465059a4ead93c to your computer and use it in GitHub Desktop.
A bash script that's helpful for setting up your GCP Deep Learning VM instance to work with Google Colab. Recommended to be used in host and VM computers.
# Usage: install-python <VERSION>
# Example: install-python 3.6.9
function install_python() {
VERSION=$1
sudo apt install gcc make zlib1g-dev
sudo apt install libssl-dev # needed for SSL support
sudo apt install libsqlite3-dev # needed for SQLite support
sudo apt-get install libbz2-dev # needed for BZ2 compression support
wget "https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tar.xz"
tar xJf "Python-$VERSION.tar.xz"
cd "Python-$VERSION"
./configure --enable-optimizations --enable-loadable-sqlite-extensions
sudo make
sudo make install
cd ..
sudo pip3 install --upgrade pip
python3 -V
pip3 -V
}
# Usage: setup-jupyter
function setup_jupyter() {
sudo pip3 install setuptools --upgrade
sudo pip3 install numpy scipy skikit-learn matplotlib
sudo pip3 install tensorflow-gpu keras
sudo pip3 install google-api-python-client
sudo pip3 install pandas
sudo pip3 install nbdime jupyter_tensorboard jupyterlab
sudo pip3 install jupyter_http_over_ws
jupyter serverextension enable --py jupyter_http_over_ws
}pygobject
# Usage: serve-jupyter <PORT>
# Example: serve-jupyter 8081
function serve_jupyter() {
PORT=$1
jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=$PORT --NotebookApp.port_retries=0 --no-browser
}
# Usage: login-gcp-instance <PROJECT_ID> <ZONE> <INSTANCE_NAME> <PORT>
# Example: login-gcp-instance mnist-project us-west1-b deep-learning-vm 8081
# List of all GCP zones: https://cloud.google.com/compute/docs/regions-zones/#locations
function login_gcp_instance() {
PROJECT_ID=$1
ZONE=$2
INSTANCE_NAME=$3
PORT=$4
gcloud compute ssh $INSTANCE_NAME --project $PROJECT_ID --zone $ZONE -- -L $PORT:localhost:$PORT
}
alias install-python=install_python
alias setup-jupyter=setup_jupyter
alias serve-jupyter=serve_jupyter
alias login-gcp-instance=login_gcp_instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment