Part 1: Setup Virtual Machine

First you need a server (or servers) to work with your software. Now this part can take a lot of time which is why there are efforts to simplify and remove setup. For this post and for now, we are going manual on server setup. Below is one approach, and there are plenty of variations on how you can setup a VM based on what your needs are.

The following walkthrough takes place in a standard terminal and the Google Cloud Console which is a web UI. Setting up a VM on GCE covers these key steps:

Pre-config: Add GPUs & Setup Firewall Access

Define & Start Customized Instance

Access VM, Configure & Manage

Side note about Names (GCP and GCE)

On GCP, the section that gives access to spinning up a VM is labeled Google Compute Engine (GCE). When I use GCP, I’m referring to Cloud at Google in general, and this covers data products like Bigtable & Storage to management tools like Stackdriver and any Google Cloud product. GCE specifically refers to VMs, Container Engine and App Engine products which all fall under the broader GCP umbrella. Note, if you use anything under the machine learning product section of GCP then those products are using VMs from GCE but you don’t have to deal with the setup steps below.

Add GPUs (if no quota available)

Because new accounts start with zero GPU quota, you need to add by taking the following steps:

Set up billing in GCP account

Fill out the quota request form (also on GCE Quota page under Request)

Requests processed almost immediately with billing history

Cannot be added with a free trial period

GPUs are only available in these regions

Setup Firewall for Jupyter Notebook

Use this walk-though for help on how to setup firewall rules for remote access. In this case, we want to run some of our examples on the VM we setup with Jupyter Notebook.

Under GCP Networking section, choose Firewall rules.

Use the following configuration for Jupyter to setup the firewall rule:

You will reference the name of this rule when setting up the VM.

Setup Customized VM

Now we get to the good stuff of setting up a virtual machine and there are great resources on how to get a VM setup. Below steps through key points related to this post. First go to your Compute Engine VM instances dashboard:

Select Create Instance and under Machine type choose Customize

Make sure the Zone is set to where GPU quota exists

Adjust Cores and Memory as needed (more memory is helpful with ML)

Expand GPUs and choose how many to add

Under Boot disk, change to one that aligns to your needs. There are several options and some instances have Kubernetes and Docker pre-installed

Change Boot disk type and Size as needed

(Optional) For Jupyter firewall access, expand Management, disks, networking, SSH keys link

(Optional) Choose Networking and write in the jupyter tag

Finally Choose Create to start instance

Once you’ve created the instance it will take a couple minutes to launch.

Access Instance

Options for accessing the VM include:

GCloud SDK

Browser Command Line (use the drop down next to SSH to open)

Local Command Line (check Connecting using SSH on Linux or OSX workstations section)

Note: Review generating SSH key-pair if you haven’t done that before.

Configure Instance

This is where the fun begins because configuration can take a lot of time getting all the software you need setup properly. Some options to get your instance configured include:

Startup script (add during Create VM step)

Apply during Create VM

Snapshots (choose when changing boot disk)

Install script (run from server command line)

Docker image

Manually configure

I’m giving just a list of the options and encourage you to explore outside of this post. The main challenge in our setup is getting the GPU’s configured and the software setup.

For the examples in the next post, I’ve created an install script that sets up GPUs and needed libraries especially for Python ML as noted below:

Run with the following in your server’s command line to download and configure the VM:



$ source gce-install-gpu.sh $ wget https://raw.githubusercontent.com/nyghtowl/mixed-tape/master/alpha-track/gce-install-gpu.sh $ source gce-install-gpu.sh

The install script will ask to define a password for Jupyter. Remember this password because you will need it for the examples in the next blog post about running models.

Manage Instance

Once the instance is up and running and configured then you can manage the VM so that it isn’t running and charging you when you are not using it.

In the GCE Instances dashboard, select your VM and use Start, Stop, Reset and Delete commands at the top for management. Note, you are charged for a minimum of 10 minutes when the instance is started and then on a per minute basis while its running.

Additional Thoughts

What I’ve covered above gets you started, but as stated in the beginning there are many variations on how you can and should approach setup. This is not optimized for all the unique projects and problems you will work with. Spend time understanding what system setup you need.

Also as noted, there is a push within Google and without to simplify machine learning especially in regards to the setup above. In GCP, there are ML APIs and the ML Engine that enable skipping this type of setup when using TensorFlow. Pushing for removing setup steps frees us up to ramp quickly in actual ML research and delve into areas we haven’t explored. That is where things are moving.

Still its not all plug and play yet, and its important to understand the problem you are solving because that will guide software and hardware setup.

References

Thanks for the pointers on setup: Wendy Kan, Jeff Moser, Allen Day