Setting up new GCP VM Instance for Machine Learning
- neovijayk
- Jul 6, 2020
- 3 min read
In this article, I am going to show steps to set up Google Cloud Platform Instance to experiment Machine Learning Algorithms on it. We are going to use Ubuntu as the OS and going to install Anaconda-Jupyter notebook (for Python) on it.
STEPS ARE:
Creating new GCP Instance with Ubuntu running on it
Creating Firewall Rules
Start New VM Instance. Your VM Instance is ready !!!
Stop GCP VM Instance safely
Prerequisite:
To follow the above steps you need to have Google Cloud Platform Account. Which you can create by visiting the site (As of now you will get 300$ free account for full 1 year)
1. Creating new Instance on GCP
Login to your Google Cloud Platform. Go to Console

Go to Google Cloud Console
From this Console create a New Project or continue in one of the existing Projects
Go to Compute Engine and then select VM Instances.

Create a new instance
Click on “Create new instance“. Here we have to describe information about the new instance that we want to create. This information will be as per our requirements that we want in a new instance.
First, provide a Name to our new instance then select Region
Now in Machine type select memory at least 7.5 GB memory or more.
Note that you can increase or decrease memory as per your requirement after the creation of an instance.
Its always good practice to reduce memory size to lowest available/remove instance once you finish your practice experimenting with ML algorithms it will save you money.
For our example, we are going to select the Boot disk as Ubuntu 16.04 LTS
In Identity and API access for our example, we are going to select Service account as Compute Engine default service account and in Access, scopes select Allow full access to all Cloud APIs.
In the Firewall section select both Allow HTTP traffic and Allow HTTPS traffic. Then click on create button.

Example instance information filled.
Hence we have created our new instance. Now we will create Firewall Rule.
2. Create Firewall Rule
Now go to Networking and select Firewall rules from VPC network

In Firewall rules window select CREATE FIREWALL RULE Button and follow below steps:
Provide Name and Optionally provide a description (good practice to write down description)
Now directly jump to Targets and do as shown in the following image:

3. Note down the number that you’re going to provide as tcp port number e.g. in the above picture we have provided 5000. This number we are going to use to run our Jupyter Notebook. 4. Now click on the Create button. It will create a new Firewall rule.
3. Start New VM Instance. Your VM Instance is ready !!!
Now we will start our newly created GCP instance. Jump to Compute Engine -> VM Instances. Here you will see the new instance. Select that instance and click Start Button. Note that after starting the instance here External IP will appear (if not then refresh the webpage). The external IP address is important we are going to need it to connect with Jupyter notebook running on this Google VM Instance in the next article.

Start instance
Now click on SSH under Connect Button. It will open a terminal in the new window. Our New VM Instance is ready to work now 🙂 !!!
4. Stop GCP VM Instance safely
Close the terminal. Now stop the VM Instance by clicking on Stop button from VM Instancespage
Note that
Whenever you finish the work on VM Instance and you don’t need it for a short period of time then you should stop the VM Instance safely from VM Instances page by selecting the VM Instance and clicking on Stop button. Also by clicking on VM Instance, you can change memory settings to the lowest available memory setting (0.6 GB) for that instance this will minimize the cost. (You can restore/change the Settings of Memory in the same way to the Original i.e. 7.5 GB or more as per requirement before starting the VM instance next time).
And if you are not going to use this instance for a long period of time then you can create an image/snapshot of the instance and delete the VM Instance. In this way, we will be billed for the image storage cost only and not for the VM Instance.
Now using this terminal we will install Anaconda-Jupyter notebook on this instance in the next article:
Please check my other blogs as well if you like this article share it, like it. If you have any questions feel free to ask me below. 🙂
To know more about GCP & Google Cloud: Google Official Doc
Also check this article: Attaching Static IP address to the Ubuntu VM instance on GCP
Comentários