Skip to content

Instantly share code, notes, and snippets.

@BenFausch BenFausch/
Created May 16, 2018

What would you like to do?
Tensorflow setup for gcloud micro box including ssh
#config ssh:
#add to instance metadata
#1. go to gcloud instance, click edit
#2. go to 'custom metadata' section, add 'enable-oslogin':TRUE
#3. click 'show and edit' under SSH key section, add the contents outputted by command 'cat ~/.ssh/' to add your public ssh key (use the outputted username as the key here ex. benfausch)
#4. go to gcloud terminal through gcloud webpage, run 'mkdir .ssh && touch .ssh/authorized_keys', then authorized_keys > "your ouputted public ssh key here"
#5. go to normal terminal, then use same username gcloud uses in browser terminal (ex benjamin_fausch_gmail), your private SSH key, and the public IP of the instance
#=>=>=>=> ssh -i id_rsa benjamin_fausch@
#6. then you can just use ssh and create an alias
#check install python
which python
#tensorflow for ubuntu:
#install pip
sudo apt-get install python-pip python-dev
#create swap file====>
#check for no active swap
sudo swapon --show
free -h
#check for space
df -h
#create swapfile
sudo fallocate -l 1G /swapfile
#verify perms are -rw-r--r--
ls -lh /swapfile
#set to root only and verify
sudo chmod 600 /swapfile
ls -lh /swapfile
#mark as swap
sudo mkswap /swapfile
#turn on swap and verify
sudo swapon /swapfile
sudo swapon --show
free -h
#back up swap
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
#install tensorflow and keras if needed, use --no-cache-dir to avoid memoryerror
pip install tensorflow
pip --no-cache-dir install keras
#now you can run a python script with python *script*.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.