Julia on Google Colab: Free GPU-Accelerated Shareable Notebooks

I just tried this. However, I have another error while using CuArrays

BoundsError(a=Array{Core.Compiler.BasicBlock, (32,)}[
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=1, last=7), preds=Array{Int64, (1,)}[32], succs=Array{Int64, (1,)}[2]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=8, last=14), preds=Array{Int64, (1,)}[1], succs=Array{Int64, (2,)}[5, 3]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=15, last=20), preds=Array{Int64, (1,)}[2], succs=Array{Int64, (1,)}[4]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=21, last=21), preds=Array{Int64, (1,)}[3], succs=Array{Int64, (1,)}[7]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=22, last=28), preds=Array{Int64, (1,)}[2], succs=Array{Int64, (1,)}[6]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=29, last=29), preds=Array{Int64, (1,)}[5], succs=Array{Int64, (1,)}[7]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=30, last=47), preds=Array{Int64, (2,)}[4, 6], succs=Array{Int64, (2,)}[9, 8]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=48, last=49), preds=Array{Int64, (1,)}[7], succs=Array{Int64, (0,)}[]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=50, last=50), preds=Array{Int64, (1,)}[7], succs=Array{Int64, (1,)}[10]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=51, last=52), preds=Array{Int64, (1,)}[9], succs=Array{Int64, (1,)}[11]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=53, last=53), preds=Array{Int64, (1,)}[10], succs=Array{Int64, (1,)}[12]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=54, last=54), preds=Array{Int64, (1,)}[11], succs=Array{Int64, (1,)}[13]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=55, last=56), preds=Array{Int64, (1,)}[12], succs=Array{Int64, (1,)}[14]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=57, last=65), preds=Array{Int64, (1,)}[13], succs=Array{Int64, (1,)}[15]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=66, last=71), preds=Array{Int64, (1,)}[14], succs=Array{Int64, (2,)}[17, 16]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=72, last=74), preds=Array{Int64, (1,)}[15], succs=Array{Int64, (0,)}[]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=75, last=82), preds=Array{Int64, (1,)}[15], succs=Array{Int64, (2,)}[19, 18]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=83, last=84), preds=Array{Int64, (1,)}[17], succs=Array{Int64, (0,)}[]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=85, last=85), preds=Array{Int64, (1,)}[17], succs=Array{Int64, (1,)}[20]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=86, last=87), preds=Array{Int64, (1,)}[19], succs=Array{Int64, (1,)}[21]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=88, last=88), preds=Array{Int64, (1,)}[20], succs=Array{Int64, (1,)}[22]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=89, last=89), preds=Array{Int64, (1,)}[21], succs=Array{Int64, (1,)}[23]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=90, last=90), preds=Array{Int64, (1,)}[22], succs=Array{Int64, (1,)}[24]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=91, last=92), preds=Array{Int64, (1,)}[23], succs=Array{Int64, (1,)}[25]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=93, last=93), preds=Array{Int64, (1,)}[24], succs=Array{Int64, (1,)}[26]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=94, last=94), preds=Array{Int64, (1,)}[25], succs=Array{Int64, (1,)}[27]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=95, last=95), preds=Array{Int64, (1,)}[26], succs=Array{Int64, (2,)}[29, 28]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=96, last=98), preds=Array{Int64, (1,)}[27], succs=Array{Int64, (0,)}[]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=99, last=102), preds=Array{Int64, (1,)}[27], succs=Array{Int64, (2,)}[31, 30]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=103, last=103), preds=Array{Int64, (1,)}[29], succs=Array{Int64, (1,)}[32]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=104, last=104), preds=Array{Int64, (1,)}[29], succs=Array{Int64, (1,)}[32]),
  Core.Compiler.BasicBlock(stmts=Core.Compiler.StmtRange(first=105, last=107), preds=Array{Int64, (2,)}[30, 31], succs=Array{Int64, (1,)}[1])], i=(0,))
rec_backtrace at /buildworker/worker/package_linux64/build/src/stackwalk.c:94
record_backtrace at /buildworker/worker/package_linux64/build/src/task.c:246
jl_throw at /buildworker/worker/package_linux64/build/src/task.c:577
jl_bounds_error_ints at /buildworker/worker/package_linux64/build/src/rtutils.c:187
getindex at ./array.jl:731
jfptr_getindex_1600.clone_1 at /usr/lib/julia/sys.so (unknown line)
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
replace_code_newstyle! at ./compiler/ssair/legacy.jl:80
optimize at ./compiler/optimize.jl:208
typeinf at ./compiler/typeinfer.jl:35
typeinf_ext at ./compiler/typeinfer.jl:567
typeinf_ext at ./compiler/typeinfer.jl:604
jfptr_typeinf_ext_1.clone_1 at /usr/lib/julia/sys.so (unknown line)
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1536 [inlined]
jl_apply_with_saved_exception_state at /buildworker/worker/package_linux64/build/src/rtutils.c:257
jl_type_infer at /buildworker/worker/package_linux64/build/src/gf.c:275
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:1784 [inlined]
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1828
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1536 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:268
unknown function (ip: 0xffffffffffffffff)

Does anyone know how to use CuArrays in colab?

I never had this issue. I recently updated the notebook to Julia 1.1 and all worked fine. Here is these updated notebook (Julia 1.1 but still using cuda 9.0):


To get a notebook in Julia, download the following and re-upload in the notebook window where Julia was installed (otherwise you will get an error message that Julia in an unknown language).



hi, i would love to use julia kernel with colab.

I also wish it were possible to embed Colab as a react component

I also wish it were possible to run Colab notebooks offline by transpiling Python/Julia/R/Scala etc into Chromium V8 code … but that might be difficult. Anyone else interested to push Colab into more languages and offline/embedded environments?

I really like the ability to use colab, thanks a lot!
Would it also be possible to use Julia in Kaggle kernels?

Hello, I do have the same error. Do you have any updates on this regard?

I have no idea about that bug, but if you want to try out running Julia online with a GPU, you can also remix this article:

1 Like

Interesting! Maybe we can get a diffeq example up and running on NextJournal.

1 Like

Sure, lets add it to https://nextjournal.com/julia! :slight_smile:
Could also try to create an ahead of time compiled image with PackageCompiler.

1 Like

I am using google colab for the first time. The first link you have shared works without any errors. However, the second one, when I try to upload the notebook, the previous session gets terminated and it throws the following error:

File “”, line 1

using Pkg
SyntaxError: invalid syntax

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

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


Now I just get error

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

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


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?


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

1 Like

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?

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


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