Setup Julia with Jupyter notebook on Google Cloud Platform

yash patel
Jun 14 · 5 min read

Julia is high performance dynamically-typed programming language. It is build especially for scientific and numerical computing. Jupyter notebook can run Julia so it becomes a reliable medium to code in Julia on Google cloud platform (GCP). GCP is a suite of public cloud computing services provided by Google, it helps us to compute, store or develop our programs or applications on Google hardware.

Sometimes it becomes difficult to compute things in our local computer. For such situations, GCP becomes a great option. Their are a lot of articles available for other programming languages to setup GCP but for Julia their is lack of articles which become makes hard for Julia users to setup Julia in GCP. I faced the same issue and hence wanted to help people facing similar problem.

In this blog, I will show to setup things on Ubuntu 16.04 OS, but the for other systems the procedure will be same.

Procedure:

  1. Create a GCP VM instance.
  2. Set external IP address static for created instance.
  3. Create a firewall rule with a tcp port.
  4. Open Secure Shell (SSH).
  5. Install Jupyter notebook and configure it.
  6. Install Julia and add IJulia library.

Create a GCP VM instance:

Set External IP address static:

Creating firewall rule:

Open Secure shell:

Install Jupyter notebook:

In Ubuntu to install pip , first we need to update it:

sudo apt-get update

Installing pip:

sudo apt-get install python-pip

After installing to install jupyter it is better to upgrade pip:

pip install --upgrade pip

Before install Jupyter notebook, install six package (version > = 1.11.0):

python -m pip install --user six==1.11.0

Then install Jupyter notebook:

python -m pip install --user jupyter

Now, we need to configure jupyter notebook so that we can access it through local machine in our browser. For that first we have to generate configure file for jupyter notebook:

jupyter notebook --generate-config

Now, open that configure file using any of favorite editor (nano, vim etc):

vim  ~/.jupyter/jupyter_notebook_config.py

Then add these line to the file:

c = get_config()
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 5000

NOTE: In front of port line, you have to enter the tcp port number which you had set in the firewall rule.

Now, I would suggest to set password for jupyter notebook, so that you won’t have to give token again and again to open jupyter notebook later. To set password use:

jupyter notebook password

Now, you are fully set to start jupyter notebook, simply type:

jupyter notebook

Then go to your favorite browser, and type:

<external IP address of that instance >:<TCP port number>

35.229.156.225:5000
External IP address

Installing Julia:

To download julia, use wget tool:

wget <copied link>

wget https://julialang-s3.julialang.org/bin/linux/x64/1.1/julia-1.1.1-linux-x86_64.tar.gz

For Linux, first extract Julia for tar file:

tar -xvzf <downloaded file name>

tar -xvzf julia-1.1.1-linux-x86_64.tar.gz

Now, we need to add the bin folder path to the PATH environment variable and also add that to ~bashrc file:

echo 'export PATH=$PATH:<path to directory where the julia is extracted>/julia-1.1.1/bin' >> ~/.bashrcsource ~/.bashrc

Now, we can open julia by simply tying:

julia

Now, to use Jupyter Notebook with Julia, we need to install IJulia package by julia package manager:

julia> using Pkg
julia> Pkg.import("IJulia")

This finishes all installations and now we can use jupyter notebook with julia:

julia> using IJulia
julia> notebook()

Then go to your browser and again type (in URL section):

<external IP address>:<TCp port>

35.229.156.225:5000