Julia on Google Colab: Free GPU-Accelerated Shareable Notebooks

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

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

2 Likes

Now I just get error

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

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

image

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?

2 Likes

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.

3 Likes

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"
    },
[...]
2 Likes

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

1 Like

@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