Julia on Google Colab: Free GPU-Accelerated Shareable Notebooks

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):

  "nbformat": 4,
  "nbformat_minor": 0,
 "metadata": {
    "kernelspec": {
      "name": "julia-1.2",
      "display_name": "Julia 1.2"

@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.


@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.

Works for me!

1 Like

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.


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

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

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:

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.

1 Like

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.



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

Hi Julians,

I created a Colab notebook template, 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

1 Like

Thanks for your kind words, Steven. I implemented your suggestions.

1 Like


This is great work!

I just tried the template and updated to Julia verson 1.5.0. Running the first cell generated the

Unrecognized runtime “julia”; defaulting to “python3” Notebook settings

but the template appears to work, however.

Success! Please reload this page and jump to the next section.

Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
** OS: Linux (x86_64-pc-linux-gnu)**
** CPU: Intel® Xeon® CPU @ 2.20GHz**
** WORD_SIZE: 64**
** LIBM: libopenlibm**
** LLVM: libLLVM-9.0.1 (ORCJIT, broadwell)**

Per instructions, I understand that we should run the template’s first cell in each new cola notebook.



Using Julia on google colab via SSH with vscode server

“Run VS Code on any machine anywhere and access it in the browser.” code-server

Please let me know if you have any suggestions for improving the script!


So this is another version agnostic solution I just came up with:

No major functionality difference to ageron’s template but I guess more readable because it’s much shorter :grinning_face_with_smiling_eyes:


Thanks all for this hack. I manage to run Julia on Google Colab. However, I cannot find a way to mount Google Drive to use with Julia (on Google Colab). I tried using PyCall like this:

using PyCall
googleDrive = pyimport("google.colab.drive")

but it gives the following error:

Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&scope=email%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdocs.test%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive.photos.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fpeopleapi.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive.activity.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fexperimentsandconfigs%20https%3a%2f%2fwww.googleapis.com%2fauth%2fphotos.native&response_type=code

Enter your authorization code:
PyError ($(Expr(:escape, :(ccall(#= /root/.julia/packages/PyCall/BD546/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'EOFError'>
EOFError('EOF when reading a line')
  File "/usr/local/lib/python3.7/dist-packages/google/colab/drive.py", line 260, in mount
    fifo_file.write(get_code(auth_prompt) + '\n')

Switching the runtime type to “Python” to mount Google Drive will just get rid of the “julia” runtime of the notebook.

Any idea is appreciated!

1 Like

@JohnnyChen94 is your repo for installing Julia on Colab working fine with Julia v1.6.2? I never used Colab before but apparently I can’t load any package after Julia is installed and the package is installed with Pkg.jl. For example, doing a simple Pkg.add("CSV") will install an old version of CSV.jl. I then force the installation of the latest version with Pkg.add(name="CSV", version="0.8.5") but when I try to using CSV in another cell I get load errors.

Any help is appreciated as we are doing a workshop this week and participants with less-powerful machines need a Colab instance to contribute more efficiently.

I don’t see any issues with my setup script.

For example, doing a simple Pkg.add("CSV") will install an old version of CSV.jl. I then force the installation of the latest version with Pkg.add(name="CSV", version="0.8.5") but when I try to using CSV in another cell I get load errors.

The only dependency that the notebook requires is IJulia, so if there are some version conflicts with IJulia, then this could happen. But I guess a refresh of the notebook page Ctrl-R or restarting kernels could resolve the issues.

For this very specific case and time point, I believe it’s because CSV hasn’t yet released a version compatible with Parsers@2; CSV@0.8.5 is compatible with Parsers@1 only

1 Like