Configuring Google Compute Engine

Creating a VM

Connecting to your VM

Setting up your machine

All the base software comes with the disk image oxdnn-master that you’ll be using to create your own VM instance. This image includes the NVIDIA driver for Tesla K80 GPUs, basic miniconda installation, htop, tmux and comes with the MNIST and CIFAR-10 dataset pre-loaded. You’ll need to setup your miniconda environment by executing the bash script in this zip file. The instructions to setup your environment are as follow:

First we need to get the setup scripts in the link above. The easiest way to get this file in your Google Cloud VM is by using the wget command as follows:

$ wget ""

Then unzip the file by doing:

$ unzip

You can now delete the zip file if you wish. To launch the setup process describe in follow the code lines below. Note there is a . before executing the bash script. Don’t miss it! At some point you will be prompted to introduce a password. This password will be use to access the Jupyter Notebooks that we’ll be using for the practicals in this course. Chose any password you like but make sure to remember it. After doing this, the setup will continue and a SSL certificate will be generated and prompt you for some details (feel free to skip all these by typing intro in all of them).

$ cd setup # this gets you in the directory
$ . ./

(if you are curious to know exactly what the script is doing, you can print it on your terminal by typing cat

Once the process is completed a tmux session will be spawned. Tmux is a terminal multiplexer and allows you to split a terminal window in to multiple terminals without needing for a new UI window. You can check all the basic commands on how to use it here. Now let’s start with practical one:

First you’ll need to activate the miniconda environment that the script configured before. The name of the environment is Pytorch:

$ source activate Pytorch

Now let’s create a new directory for the practicals of day one and download the Jupyter Notebook for the practical. As you see below, we are using wget command to download a file listed in the section of practicals below. To get the path to that file just do right-click on Practical 1 and copy it (depending on your browser the option may be called copy link, copy link location or copy link address):

$ mkdir dayOne # this creates the directory
$ cd dayOne
$ wget "copy link to practical here"

Now that we have the Jupyter Notebook file, we just need to launch Jupyter Notebook. To do so type:

$ jupyter notebook

This will launch a no-browser instance of Jupyter Notebook running on port 7001. To connect to that port you’ll need to go to your Google VM Instances panel and click on the IP under External IP. This will open an new tab in your browser. Edit the address opened by appending :7001 after the last number of the IP (if there’s a ‘/’, remove it). Then click intro. This will alert you of unsecured connection. Ignore this and click on add exception (again, the message you’ll see depends on your browser). You won’t be able to precede if you are using Safari and you don’t have admin privileges in the machine you are using. Please use either Firefox or Chrome if you encounter this issue. After adding the security exception to connect to your VM, you’ll be asked to introduce your Jupyter Notebook password. Now you should be able to see the jupyter landing panel and open the practical for day one.

Launching TensorBoard

Assuming you are in a Tmux session running Jupyter Notebook, you’ll need to split the terminal into two. You can do this by pressing [ctrl]+[b] and then % for a horizontal split (if you prefer, you can press " instead for a vertical view split). Once you have your new terminal running, probably you’ll need to reactivate the Pytorch environment. You can do so by typing source activate Pytorch then, insert the command below to launch Tensorboard on port 7002:

$ tensorboard --logdir . --port 7002

The above command will make tensorboard see all experiments stored in your current directory.

Create a Snapshot of your VM

In Practical 2c we’ll be doing multi-GPU training. Concretely, we’ll be using 4 NVIDIA K80 GPUs. The VM we’ve been using so far was configured to have a single K80. We need to create a new VM with 4x K80 GPUs. You could follow exactly the same steps as you did yesterday to create your first VM. However, doing so means you’ll have to execute the script again. We can avoid that by creating a snapshot of your current (single-GPU) VM and use it as boot disk for your the VM you are going to create. Below are the steps needed to create the snapshot image:

Once the snapshot is ready, it’s time to create a VM with 4 GPUs. In order to do that follow the steps above, select 4 GPUs instead and, for boot disk, on the panel that pops up go to Snapshots and click on the snapshot you have generated. Complete the rest of the configuration of the VM as we did for the first VM (i.e. firewall traffic and IP forwarding).

Once you complete your practicals, please remember to STOP your VMs otherwise, even though you are not using them, you’ll be charged.