# Julia on Google Colab: Free GPU-Accelerated Shareable Notebooks

**URL:** <https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319>\
**Category:** GPU\
**Tags:** announcement, notebooks\
**Created:** [September 21, 2018, 11:00pm UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319 "2018-09-21T23:00:02Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![matthieu](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@matthieu](https://discourse.julialang.org/u/matthieu)\
**Post date:** [September 21, 2019, 3:14pm UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/22 "2019-09-21T15:14:56Z")

</div>

This worked for me. Thanks, that’s very nice.

---

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [September 21, 2019, 5:04pm UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/23 "2019-09-21T17:04:05Z")

</div>

Probably best to put our acts together in this product feature request.

> **[Will kaggle include Julia? | Kaggle](https://www.kaggle.com/discussions/product-feedback/83644)**
>
> Will kaggle include Julia?.

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [September 27, 2019, 2:39am UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/24 "2019-09-27T02:39:32Z")

</div>

Now I just get error

```julia
  File "<ipython-input-1-93593d386988>", line 1
    using Pkg
            ^
SyntaxError: invalid syntax

```

---

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [September 30, 2019, 7:45pm UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/25 "2019-09-30T19:45:35Z")

</div>

I’m trying this out, installing Julia seems to work fine and from the install notebook I see e.g.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/0/302e2ef9a8c458e2b76faee0b6751fc98d675d0b.png)

But I can’t get a second notebook started “in this same runtime” such that it sees the `julia-1.2` kernel. I’ve tried the hyperlink suggestion from above which doesn’t work (maybe I got the URL wrong?) and I’ve tried uploading into the install session (but then how do I load the new notebook?). In all cases it gives me the `Unrecognized runtime "julia-1.2"; defaulting to "python3"` error. Any tips?

---

<div class="post-metadata">

**Author:** ![ennvvy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ennvvy/32/7816_2.png) [@ennvvy](https://discourse.julialang.org/u/ennvvy)\
**Post date:** [October 9, 2019, 12:49pm UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/26 "2019-10-09T12:49:52Z")

</div>

I have elaborately written about my issue in this link [https://stackoverflow.com/questions/58270424/julia-in-google-colab](https://stackoverflow.com/questions/58270424/julia-in-google-colab). I hope some help will come my way?

---

<div class="post-metadata">

**Author:** ![ennvvy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ennvvy/32/7816_2.png) [@ennvvy](https://discourse.julialang.org/u/ennvvy)\
**Post date:** [October 10, 2019, 5:20am UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/27 "2019-10-10T05:20:46Z")

</div>

> [@jekbradbury](#):
>
> { “nbformat”: 4, “nbformat\_minor”: 0, “metadata”: { “colab”: { “name”: “Julia on Colab.ipynb”, “version”: “0.3.2”, “provenance”: }, “kernelspec”: { “name”: “julia-1.0”, “display\_name”: “Julia 1.0” }, “accelerator”: “GPU” }, “cells”: [{ “metadata”: { “id”: “oMSuTc3pDlHv”, “colab\_type”: “code”, “colab”: {} }, “cell\_type”: “code”, “source”: [“”], “execution\_count”: 0, “outputs”: } ] }

When you insert a hyperlink, is there a preceding command like - !wget or something else - to be able to run the script in the link?

---

<div class="post-metadata">

**Author:** ![ninjin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ninjin/32/58_2.png) [@ninjin](https://discourse.julialang.org/u/ninjin)\
**Post date:** [October 16, 2019, 10:16am UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/28 "2019-10-16T10:16:21Z")

</div>

Based on conversations in `#gpu`, it seems that the original hack broke last month due to changes in how Colaboratory handles associating “runtimes” (VMs) and notebooks. The best solution I managed to come up with was to craft a notebook that claims to be a Julia notebook, just like @jekbradbury’s original hack, and then have a cell at the top of each notebook that installs Julia and IJulia. One you run that cell, you can simply reload the page and things mostly work as expected as Colaboratory picks up on your IJulia installation. Here is [a link to the notebook I am currently providing to my students for a class](https://colab.research.google.com/drive/1gMhnrMNP-het4rexXLXHzaOytfDpUxgR). While it may sound awful to have to install Julia and IJulia each time the runtime disconnects, it happens only after an hour or so in practice and it also seems that a complete CUDA stack is installed by default, so there is no need to install CUDA anymore which cuts down the installation time to just over a minute.

Known issues are code completion and syntax highlighting, I lack to expertise/time to look into this so any and all help is more than helpful.

---

<div class="post-metadata">

**Author:** ![Alexander-Barth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexander-barth/32/3692_2.png) [@Alexander-Barth](https://discourse.julialang.org/u/Alexander-Barth)\
**Post date:** [November 5, 2019, 7:56pm UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/29 "2019-11-05T19:56:04Z")

</div>

Thanks a lot! It works also for Julia 1.2 for me (changing the URL for download and the kernelspec section locally in the ipynb file):

```julia
{
  "nbformat": 4,
  "nbformat_minor": 0,
 "metadata": {
    "kernelspec": {
      "name": "julia-1.2",
      "display_name": "Julia 1.2"
    },
[...]

```

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [November 18, 2019, 7:03am UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/30 "2019-11-18T07:03:18Z")

</div>

@ninjin Two suggestions for the notebook template: maybe use Julia 1.1 or 1.2, since 1.0 has a bug that displays a nasty (but harmless) stacktrace when importing CuArrays. You also should do `@benchmark CuArrays.@sync ...` or you’re just measuring kernel launch time.

---

<div class="post-metadata">

**Author:** ![ninjin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ninjin/32/58_2.png) [@ninjin](https://discourse.julialang.org/u/ninjin)\
**Post date:** [November 18, 2019, 9:49am UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/31 "2019-11-18T09:49:29Z")

</div>

@maleadt Duly noted, I had wondered for some time why that scary stacktrace showed up from time to time, yet had no effect on the actual usage of CuArrays. While I have updated the benchmarking code, I will stick to 1.0 for now as the class is in full swing.

---

<div class="post-metadata">

**Author:** ![GdMacmillan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdmacmillan/32/8839_2.png) [@GdMacmillan](https://discourse.julialang.org/u/GdMacmillan)\
**Post date:** [December 3, 2019, 4:07am UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/32 "2019-12-03T04:07:08Z")

</div>

Works for me!

---

<div class="post-metadata">

**Author:** ![Sayantan\_Das](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sayantan_das/32/12455_2.png) [@Sayantan\_Das](https://discourse.julialang.org/u/Sayantan_Das)\
**Post date:** [January 31, 2020, 10:25am UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/33 "2020-01-31T10:25:04Z")

</div>

I saw that many people in this discourse were getting confused on how to upload the notebook to enable Julia, here is a blog(attached with video) I made. [Blog also contains link to the Youtube video on Walkthrough](https://ucalyptus.github.io/Blog/2020/01/31/Julia).

---

<div class="post-metadata">

**Author:** ![GdMacmillan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdmacmillan/32/8839_2.png) [@GdMacmillan](https://discourse.julialang.org/u/GdMacmillan)\
**Post date:** [February 4, 2020, 7:59pm UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/34 "2020-02-04T19:59:10Z")

</div>

I posted over in the flux forum but since this has to do with Colab, I’ll ref that post here: [[ANN] Flux v0.10 - #38 by GdMacmillan](https://discourse.julialang.org/t/ann-flux-v0-10/31660/38)

---

<div class="post-metadata">

**Author:** ![Dsantra92](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dsantra92/32/21432_2.png) [@Dsantra92](https://discourse.julialang.org/u/Dsantra92)\
**Post date:** [February 20, 2020, 6:09pm UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/35 "2020-02-20T18:09:33Z")

</div>

Your code works really fine … CUDA gets precompiled without any problems

---

<div class="post-metadata">

**Author:** ![Dsantra92](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dsantra92/32/21432_2.png) [@Dsantra92](https://discourse.julialang.org/u/Dsantra92)\
**Post date:** [March 9, 2020, 9:44pm UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/36 "2020-03-09T21:44:08Z")

</div>

I tried solving the problem the problem for the Julia in Google Collab.The Julia 1.3.1 notebook works completely fine with GPU functionality.The notebook contains step by step information for the execution of code.  
visit this repository:

> **[GitHub - Dsantra92/Julia-on-Colab: Notebook for running Julia on Google Colab](https://github.com/Dsantra92/Julia-on-Colab)**
>
> Notebook for running Julia on Google Colab. Contribute to Dsantra92/Julia-on-Colab development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![SambitMishra98](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sambitmishra98/32/14263_2.png) [@SambitMishra98](https://discourse.julialang.org/u/SambitMishra98)\
**Post date:** [May 20, 2020, 8:29pm UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/37 "2020-05-20T20:29:42Z")

</div>

> [@Dsantra92](#):
>
> visit this repository

I tried what you mentioned in the repository, and got stuck after the first step. I am not able to find any options which can change the runtime type (Initially, I used to see Python 2 and Python 3 as options). The option for Julia 1.x is not shown in Notebook settings (I remember the option existing before). I only see the option which lets me change the accelerator (None, GPU, TPU). Can you tell if there is any other method to shift to Julia in this step? I think Colab has stopped giving us options to change runtime type, and has started using Python 3 by default.  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/0/a0b360cd6dd12cdbde517fce6da578db316817d4.png)

---

<div class="post-metadata">

**Author:** ![Dsantra92](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dsantra92/32/21432_2.png) [@Dsantra92](https://discourse.julialang.org/u/Dsantra92)\
**Post date:** [June 10, 2020, 5:57pm UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/38 "2020-06-10T17:57:34Z")

</div>

This kind of error can occurr when you try to just copy the contents of the first cell into another notebook and run it.This notebook is a template to work on.  
Try using the notebook in the repository directly.

---

<div class="post-metadata">

**Author:** ![321bwa](https://avatars.discourse-cdn.com/v4/letter/3/e56c9b/32.png) [@321bwa](https://discourse.julialang.org/u/321bwa)\
**Post date:** [June 11, 2020, 6:13pm UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/39 "2020-06-11T18:13:29Z")

</div>

Hello,

It works for me, but I’m curious on why that kind of error happens?

---

<div class="post-metadata">

**Author:** ![ageron](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ageron/32/15465_2.png) [@ageron](https://discourse.julialang.org/u/ageron)\
**Post date:** [June 23, 2020, 7:05am UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/40 "2020-06-23T07:05:58Z")

</div>

Hi Julians,

I created a [Colab notebook template](https://colab.research.google.com/github/ageron/julia_notebooks/blob/master/Julia_Colab_Notebook_Template.ipynb), inspired by the notebooks above, but which supports **easily setting the version of Julia** (any version since 0.7.0 up to the latest version), and **changing the list of Julia packages to be installed**.

I hope this helps!

---

<div class="post-metadata">

**Author:** ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Post date:** [June 23, 2020, 11:20am UTC](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319/41 "2020-06-23T11:20:50Z")

</div>

> [@ageron](#):
>
> Hi Julians,
> 
> I created a [Colab notebook template](https://colab.research.google.com/github/ageron/julia_notebooks/blob/master/Julia_Colab_Notebook_Template.ipynb), inspired by the notebooks above, but which supports **easily setting the version of Julia** (any version since 0.7.0 up to the latest version), and **changing the list of Julia packages to be installed**.
> 
> I hope this helps!

Hi ageron,

Some feedback for you regarding your post above

1. Please add the package Plots to your colab notebook template by default
2. Please make it clear to the user that “Reload this page and continue to the next section.” means press the RELOAD button on your webbrowser. I spent too much time looking for the option to reload the page on the google website
3. Inform your user that to write new julia code on colab notebook, they first need to click on the “+ Code” button on the top of the page and then look for the new code section to add in the julia code. Not every newbie is familiar with Google colab notebook
4. Inform the user, that they need to have a google account, to use google drive. The easiest way is to set up a gmail account even if they do not use gmail.

By the way, I appreciate the work you have done to get julia to work with colab

[Previous page](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319.md?page=1)

[Next page](https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319.md?page=3)
