These instructions will walk you through starting a Google Compute Engine (GCE) VM with Docker installed, and starting the TensorFlow container there. This is a good option if you have difficulty installing TensorFlow on your laptop, or if you prefer to work in the Cloud.
Sign up for a free trial of Google Cloud Platform (GCP). You will need a credit card to sign up, and you will receive $300 of free credits. Note: at the time of writing, you will not be billed unless you decide to renew after the trial ends.
- Go to the Google Cloud console: console.cloud.google.com
- Select or create a project using the project drop-down at upper-left ('My First Project' in image below)
- Click on the “hamburger” menu at upper-left, and then “API Manager”.
- On the left nav, choose "Dashboard" if not already selected, then choose "+Enable API" in the top-middle of page.
- Enter "Google Compute Engine API" in the search box and click it when it appears in the list of results.
- Click on “Enable” (top-middle of page).
Click on the Cloud Shell icon (leftmost icon in the set of icons at top-right of the page).
Click on "Start Cloud Shell" on the bottom right of the pop-up screen. You should now see a terminal at the bottom of your window for the Cloud Shell with the text "Welcome to Cloud Shell! Type "help" to get started."
Run this command in the Cloud Shell.
gcloud compute instances create workshop \
--image-family gci-stable \
--image-project google-containers \
--zone us-central1-b --boot-disk-size=100GB \
--machine-type n1-standard-1
After you run this command, you can ignore the "I/O performance warning for disks < 200GB".
4. Set up a firewall rule for your project that will allow access to the IPython notebook server and TensorBoard
gcloud compute firewall-rules create workshop --allow tcp:8888,tcp:6006
- Click on the “hamburger” menu at upper-left, and then “Compute Engine”
- Find your instance in the list (mid-page)
- Write down the "External IP", this is the IP of your Cloud instance
- Logon to instance by clicking on the “SSH” pulldown menu on the right. Select “Open in browser window”.
- A new browser window will open, with a command line into your GCE instance. Confirm that you wish to initiate an SSH connection to the instance.
In the SSH browser window that's connected to the GCE instance, run this command to download and run the container:
$ docker run -it -p 8888:8888 -p 6006:6006 tensorflow/tensorflow:1.3.0 bash
When this command completes, the terminal in your SSH browser window will be connected to the running container.
Note: you can find a list of tensorflow containers on Dockerhub here.
Clone this workshop inside the container. In the SSH browser window that's connected to the container, run:
# git clone https://github.com/random-forests/tensorflow-workshop.git
In this step, we will start an IPython Notebook server that runs inside the container. We will then connect to it using a web browser on your laptop (or Chromebook). In the SSH browser window that's connected to the container, run:
# cd tensorflow-workshop
# jupyter notebook
You will see output on your terminal to indicate the server is running. If you want to stop the notebook server later, press Control-C (but do not do this now).
Step 8a) Copy the login token.
When the Jupyter server starts, you'll see a lot of console output. One one of the last lines, you'll see a login token. Copy this; you will need it in a moment to connect to the server.
Step 8b) Use a web browser on your laptop to connect to the notebook server
Open a web browser on your laptop. Use the "External IP" of your your Cloud VM from step #5 followed by :8888, i.e. <External_IP>:8888
in the address bar.
Paste the login token you coped in the previous step to connect to the server (if you copy/paste, make sure there is no newline splitting the token value, i.e. that you are pasting the token value printed on a single line).
Step 8c) Test your install
Open the examples
folder, and click on 00_test_install.ipynb. You should be able to run the notebook without issue.
That's it! You're ready to begin the workshop. Leave the container and Jupyter Notebook server running.
Once you’re done with the workshop, you can stop or delete your GCE instance. If you think you might return to it later, you might prefer to just stop it. (A stopped instance does not incur charges, but all of the resources that are attached to the instance will still be charged). You can do this from the cloud console, or via command line from the Cloud Shell as follows:
gcloud compute instances delete --zone us-central1-b workshop
Or:
gcloud compute instances stop --zone us-central1-b workshop
Then later:
gcloud compute instances start --zone us-central1-b workshop
Delete the firewall rule as well:
gcloud compute firewall-rules delete workshop