25

I am trying to setup Julia with Google Colab. Installation instructions as in https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319 have been followed. Despite that, I am unable to launch Julia.

I am trying to use Julia with Google Colab. I followed the following steps:

  1. Install CUDA
!wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
!dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
!apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
!apt update -q
!apt install cuda gcc-6 g++-6 -y -q
!ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
!ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++
  1. Install Julia 1.2.0
!curl -sSL "https://julialang-s3.julialang.org/bin/linux/x64/1.2/julia-1.2.0-linux-x86_64.tar.gz" -o julia.tar.gz
!tar -xzf julia.tar.gz -C /usr --strip-components 1
!rm -rf julia.tar.gz*
!julia -e 'using Pkg; pkg"add IJulia; add CuArrays; add Flux; precompile"'

The above two steps run perfectly fine. I am unable to initiate a Julia session. I tried:


!julia

With this, the Julia start-up screen keeps showing with no command-line.

user3856486
  • 515
  • 1
  • 4
  • 16
  • 2
    You need to launch a _new_ notebook after installing Julia. Be careful not to reset the environment — you need those changes you just made to stick around. They'll stay around as long as your session lasts, which was about 2 hours last I checked. – mbauman Oct 07 '19 at 15:15
  • 1
    On trying to launch a new notebook, two options show up - leave page or stay on page. The leave page option resets the current session. – user3856486 Oct 07 '19 at 15:26
  • 2
    Hm, something has changed. I can confirm it no longer works for me, but it definitely has worked in the past. – mbauman Oct 07 '19 at 15:43
  • I figured that once you mount the google drive [https://medium.com/lean-in-women-in-tech-india/google-colab-the-beginners-guide-5ad3b417dfa], we can run Julia scripts stored in the folder using the following command, `!julia /content/Drive/Colab/filename.jl` – user3856486 Oct 10 '19 at 07:16
  • @user3856486 if this solves your problem, could you please turn your comment into a proper answer? :-) – giordano Oct 10 '19 at 15:52

3 Answers3

14

The easiest option is to use this Colab notebook template.

It supports any Julia version, and also has GPU support.

MiniQuark
  • 46,633
  • 36
  • 147
  • 183
  • It doesn't work. Please bring an update if you can. – Shayan Oct 26 '22 at 05:18
  • @Shayan , the notebooks have been fixed now. – MiniQuark Oct 27 '22 at 03:45
  • Still, it doesn't work. I get an error after trying to install the `Plots` package. I created a Stack overflow chat room here and posted the screenshot of the error. I would appreciate you if you check it: https://chat.stackoverflow.com/transcript/message/55434556#55434556 – Shayan Oct 27 '22 at 07:24
  • Hi @Shayan, indeed, everything works well except for the Plots.jl package on GPU runtimes (it works fine on CPU runtimes though). It looks like GR_dll.jl (which Plots.jl depends on) can't find libGL.so. I'll investigate. – MiniQuark Nov 02 '22 at 02:35
7

Turns out that it was just the sequence of steps that was wrong. Very helpful video posted https://www.youtube.com/watch?v=xpZo3L2dYTY. Just to reiterate:

  1. Save the following as .ipynb file, and upload it on Google Colab:

{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Julia on Colab.ipynb",
      "version": "0.3.2",
      "provenance": []
    },
    "kernelspec": {
      "name": "julia-1.2",
      "display_name": "Julia 1.2"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "metadata": {
        "id": "oMSuTc3pDlHv",
        "colab_type": "code",
        "colab": {}
      },
      "cell_type": "code",
      "source": [
        ""
      ],
      "execution_count": 0,
      "outputs": []
    }
  ]
}
  1. Install CUDA in the same notebook using the commands mentioned in the question.
  2. Install Julia 1.2.0 in the same notebook using the commands mentioned above.
  3. Configure the settings as demonstrated in the video and you are all set!
user3856486
  • 515
  • 1
  • 4
  • 16
4

In addition to the answer by user3856486: you can now skip the CUDA installation step (mentioned here). That saves a lot of time, especially since you have to rerun these steps whenever you close the notebook/the runtime disconnects.

ita
  • 115
  • 1
  • 7