Run relax at Google Cloud Computing

From relax wiki
Jump to: navigation, search

The Google Cloud Platform is a cloud computing platform that can be used for cheaply running relax on a cluster.


This follows the same idea as from Run relax at

Make a rapid deployment of relax on a google computer cluster, and calculate for 2 months with 8 CPU's, for free.


For this example of Google Cloud Computing, we wan't to have access to as many computer cores as possible

At November 2015, google give free trial of 300$.

Note, there are some limitations:

For this time, the most important limitation is 8 CPUs.

8 CPU's

For the price calculation of:

  • 1 server
  • using Free: Debian, CentOS, ...
  • with a regular VM Class
  • Instance type of (HIGH CPU) n1-highcpu-8 (vCPUs: 8, RAM: 7.20 GB)
  • 0 SSD
  • Datacenter location United States
  • Average days per month each server is running: 1 days, per month.

This 1 day price was of November 2015, $8.06. Constantly running is $171.70 per month.

This essentially gives you 2 months of free computation with 8 CPU's.

Start free trial

Please first see this video:

Go to: and click Start your free trial.

You need to sign up with a credit card. To prevent mis-abuse from robots and hackers.

Then go to:

  • You should already have a project called My First Project.
  • Create a new project in top right corner of the browser under the dropdown of My First Project.
  • Call the new project name relax, Project ID relax-1, App Engine location at us-central. NOTE: App engine HAS TO BE located in united states, if datalab should be enabled later.

Create a Virtual Machine instance


# List all compute instances in the project
gcloud compute instances list
gcloud compute zones list
gcloud compute machine-types list | grep us-central1-f
gcloud compute machine-types list | grep us-central1-f | sort -k3 -n
gcloud compute images list
# Create instance
gcloud compute instances create relax --zone us-central1-f --machine-type n1-highcpu-4 --image ubuntu-14-04 --boot-disk-size 10GB 
gcloud compute instances list
# Or
gcloud compute instances create relax --zone us-central1-f --machine-type n1-highcpu-4 --image rhel-6-v20160921 --boot-disk-size 10GB

Then you can SSH into the instance

gcloud compute --project $PROJ ssh --zone $ZONE $PRID
gcloud compute --project "relax-1" ssh --zone "us-central1-f" "instance-1"

Access Virtual Machine instance

Install packages at server

For rapid deployment use this command. This will install current version of relax and trunk.

See the list of deploy scripts here

Then download the script that matches the system.

# Select a version script
# Redhat Version 6
# Centos Version 6
# Redhat Version 7
# Ubuntu
# Then set download URL
# Download and readl
sudo yum -y install wget
wget $URL $VERS
cat $VERS
# Load functions
source $VERS
# Do installation

Check installation of relax

mpirun --np 2 relax_trunk --multi='mpi4py'
relax_trunk --time -x

Test openmpi

For BASH shell
See the script here

wget $URL
# Source functions

For TCSH shell
See the script here

alias get 'set noglob; wget; mv*;unset noglob'
# Source functions

Transfer files back and forth to the server

See here

Install gcloud on your local computer


On your own computer

cd $HOME/Downloads
curl | bash
source $HOME/.bash_profile
gcloud init

This will start a browser to authenticate you. When it ask for a ID, just write "test" and say no to cloning.

ssh-config with gcloud


gcloud compute config-ssh makes SSHing to virtual machine instances easier by adding an alias for each instance to the user SSH configuration (~/.ssh/config) file.

gcloud compute --project $PROJ config-ssh
cat $HOME/.ssh/config
# Use sed to change value of your local computes ssh config file
sed -i.bak "s/$PRID.$ZONE.$PROJ/$GCC/g" $HOME/.ssh/config
ls -l $HOME/.ssh/config*
grep "$GCC" $HOME/.ssh/config
ssh $GCC

Use scp and rsync when gcloud has been ssh-config configured

#First fast check
cd $HOME/Downloads
touch test2.txt
scp test2.txt $GCC:
ssh $GCC
rm test2.txt
rm test2.txt
# Or use rsync
mkdir deletethisdir
rsync --progress -avzhe ssh ./deletethisdir $GCC:
ssh $GCC
rmdir deletethisdir
rmdir deletethisdir

Use relax on a test dataset from a tutorial

This follows some example data from the tutorial here Tutorial for sorting data stored as numpy to on resonance R1rho_analysis

Overview of directory

Copy data to local dir

cd $HOME
cp -r $HOME/relax_trunk/test_suite/shared_data/dispersion/Paul_Schanda_2015_Nov .
cd Paul_Schanda_2015_Nov

Prepare data

ls -latr

Run analysis

mpirun --np 2 relax_trunk --multi='mpi4py'
ls -latr

Run clustered analysis

mpirun --np 2 relax_trunk --multi='mpi4py' 
ls -latr

See results

cd results_cluster/final
ls -latr
cat phi_ex.out
cat kex.out

STOP the google instance after test to stop the billing of computation


By browser

Go to:

By terminal

# Get at list of projects
gcloud compute --project $PROJ instances list
# Start it, it takes 30 seconds.
gcloud compute --project $PROJ instances start --zone $ZONE $PRID
ssh $GCC
# Stop it through terminal
gcloud compute --project $PROJ instances stop --zone $ZONE $PRID
# This should now not work
ssh $GCC

Upgrade account

To use 32 CPU's you need to upgrade your account


Deploy google datalab to your server

Warning  This does not work

Read more here:

Note: Cloud Datalab uses AppEngine and Managed VMs beta, which is available in the US region only.
You cannot change the location after the project has been created.
See Location at:

Stop your server:

gcloud compute --project $PROJ instances stop --zone $ZONE $PRID

Cloud Datalab is deployed as an Google App Engine application module in a Google Developers Console project.
Click here to → Enable the Google Compute Engine API.


Do the following

  • Launch datalab
  • Sign in
  • Deploy to your project.

See also