A Jupyter notebook allows you to run live code, embed visualization, and explanatory text In its environment, being an open-source web application, it gives you a lot of flexibility, It supports dozens of programming languages such as PHP, Ruby on Rails, Spark, Matlab, etc. But installing the Jupyter notebook in a local system may not be the best idea, it requires intensive resources and costly maintenance, but you can save yourself this stress by running a Jupyter notebook on Google cloud instance, it is free to get started also and you only pay once you start using it. In this guide, we shall be using the anaconda distribution.
i: Creating your GCP account: The first step is to create your Google cloud platform account, but if you already have a GCP account, simply log in. - Visit cloud.google.com and click on get started for free. - You will be required to provide your Gmail account and a password. - Once your information has been confirmed, you will have an access to the Google cloud console, you will be awarded a $300 free credit to get started. we can get started with setting up our Jupyter notebook with the free google cloud account.
ii. Create a GCP project: To create a GCP project, go to the manage resources page on the cloud console>create project>new project, Enter a project name and a parent organization, thereafter, click create.An Illustration Is given below
iii. Set up a Virtual Machine (VM) instance: You must first enable billing before you can set up a VM instance, this can be done from: compute engine>vm instance>enable billing
After clicking on create, configure your VM instance by naming your instance, selecting a region and time zone, Machine type ( a “8vCPUs 30GB memory, n1-standard-8” is recommended).
– Boot disk: Ubuntu 16.04 LTS, standard persistent disk type, with a size of 10GB
– “Identity and API access” should be left at the default.
For firewall, allow HTTP and HTTPS traffic:Go to the Disk section by clicking “management, security, disk, networking, sole tenancy”, then uncheck “delete boot disk when the instance is deleted”. Thereafter, click create, and your instance is ready.
iv. Set External IP to static: We won’t be able to access the Jupyter notebook unless we make external IP static.
Go to networking>VPC network>external IP addresses.
Change your instance external IP from Ephemeral to Static. Following the pop-up, give your IP address a name and click reserve, the name given should be noted as it will be required later.
v. Create a firewall rule: Give the firewall a name, for target, select “all instances in the network”, for source IP range, input 0.0.0.0/0 for protocols and ports select “specified protocols and ports”. You can use 8888 for TCP or any other port number.
Go to Networking>VPC Network>Firewall rules>Create firewall rule.
Thereafter, click on ” create” button.
vi. Install Anaconda in VM instance: Go to compute>compute engine>VM instance then click on SSH
Enter the following command in the terminal.
wget https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh bash Anaconda3-4.2.0-Linux-x86_64.sh
Follow the on-screen instruction, and confirm the installation of anaconda into PATH. Thereafter, install other software, by executing the following command:
source ~/.bashrc pip install tensorflow pip install keras
vii. Set up the Virtual Machine (VM) Server: Create and configure the Jupyter configuration file by entering the following command into your VM terminal:
jupyter notebook --generate-config vi ~/.jupyter/jupyter_notebook_config.py
Add the following line of code into the configuration file by pressing “i”.
c = get_config() c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False c.NotebookApp.port = 8888
The port number is in correlation to our previous setting in creating firewall rule, it can be changed.
Press Esc and type wq to save and exit the file.
viii. Launch Jupyter Notebook: To launch Jupyter notebook, input this command:
Thereafter, you can launch Jupyter notebook from your browser by typing:
You will need to input the name of the external Ip address that you are previously advised to note down and your port number, click enter and you will be taken to your Jupyter notebook page. To avoid continuous billing, it is advisable to stop your VM instance whenever you are not using it by clicking on “stop” in the 3 dot menu. Once you get to this step, you have successfully launch Jupyter notebook on google cloud instance.