Skip to content

Setting up and using a Virtual Machine on Google Cloud Platform

Ngan Vu edited this page Dec 10, 2018 · 1 revision

Set up a Virtual Machine on Google Cloud Platform

We used a VM on GCP to train and run this project. To ensure that you have the same experience, you can set up your own VM to be similar to ours. Setting up a VM is hard if you're doing it for the first time. Google has a sort-of-good documentation here, which gets you a VM with Tensorflow already installed.

1. Create a GCP project

2. Create a VM based on Deep Learning VM

From the main menu, under "Compute", choose "Compute Engine" then "VM instances".

Click on "Create Instance" from the top bar, then choose "Marketplace" from the left bar.

Search for and choose "Deep Learning VM". Click "Launch on Compute Engine".

Configure the VM as below, then click "Deploy".

Wait for a minute or two, then you will have your VM ready!

3. Set up Cloud SDK

The Cloud SDK (gcloud) is the preferred command line tool for interfacing with your instance. Download it here.

4. Create an SSH connection to your machine

From the main menu, under "Tools", choose "Deployment Manager" then "Deploy". Note that you can pin this category for quick access.

Click on your VM instance, then under "Suggested next steps" on the right bar, copy the command line to SSH into the VM and forward port 8080 on the VM to port 8080 on your local machine. Modify the command so that it forward port 5000 on the VM to port 5000 on your local machine instead (because we are using a Flask app, which by default runs on port 5000 in development). Run that command line.

Congratulations! Your GCP VM is now ready.

Train and run the program on your GCP VM

Once you SSH'ed into your GCP VM:

1. git clone the project

2. Install all requirements

Note: You have to use pip3! Otherwise flask will complain.

pip3 install -r MagicBrush/app/requirements.txt

3. Get our training checkpoints

Get our training checkpoints from Google Cloud and put them in the directory.

cd MagicBrush/app
mkdir checkpoints
gsutil cp -r gs://transformer-results-bucket/MagicBrush/* checkpoints

4. Run the webserver

FLASK_APP=app.py flask run

5. Play with the app

You should be able to see MagicBrush at localhost:5000!