Julia

The Julia language aims to provide a compromise between a high level interpreted language like Python and a high performance compiled language like C or Fortran. It is explicitly designed for numerical computing.

  1. Accessing Julia
  2. Running Julia scripts
  3. Installing Julia packages
  4. Julia interactive notebooks
  5. Parallelism in Julia

Accessing Julia

Julia can be downloaded and installed into your user home directory on Sulis. No administrative permissions are required to run the installer.

We also provide Julia centrally via the environment module system.

[user@login01(sulis) ~]$ module spider julia
    ----------------------------------------------------------------------------
      Julia: Julia/1.10.4-linux-x86_64
    ----------------------------------------------------------------------------
        Description:
        Julia is a high-level, high-performance dynamic programming language for 
        numerical computing

        This module can be loaded directly: module load Julia/1.10.4-linux-x86_64

Following the advice printed by that module spider output we can load the module and enter the Julia interpreter.

[user@login01(sulis) ~]$ module load Julia/1.10.4-linux-x86_64
[user@login01(sulis) ~]$ julia
                   _
       _       _ _(_)_     |  Documentation: https://docs.julialang.org
      (_)     | (_) (_)    |
       _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
      | | | | | | |/ _` |  |
      | | |_| | | | (_| |  |  Version 1.10.4-linux-x86_64
     _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
    |__/                   |

    julia> 

If you need a newer version of Julia than that installed centrally, feel free to request it be updated by contacting support.

Running Julia scripts

Scripts written in the Julia language are usually given the .jl extension and can be launched at the command line or within SLURM job scripts scripts by providing the name of the script as an argument to the julia command as follows.

[user@login01(sulis) ~]$ julia my_script.jl

In the above it is assumed that the Julia script my_script.jl exists in the working directory where julia is invoked.

Installing Julia packages

Users may need to install additional Julia packages. By default Julia tries to install these into the same location where Julia itself is installed. If using the installation of Julia provided centrally via the environment module system this will fail. Instead users need to set the JULIA_DEPOT_PATH environment variable` to a location in their home directory. Julia will then install new packages to that location. For example:

[user@login01(sulis) ~]$ export JULIA_DEPOT_PATH=~/julia

Users may wish to set this environment variable for use in all future sessions by modifying the appropriate login file (.bashrc).

With this variable set, installation of packages should be straightforward. For example to install the CSV package within the Julia interpreter:

    julia> import Pkg
    julia> Pkg.add("CSV")

The behaviour of Julia regarding where packages are installed by default does seem to change frequently and often doesn’t match that described in the official documentation. If in doubt contact support.

Julia interactive notebooks

Julia can be used as a kernel with the Jupyter system by installing the IJulia package. This will pull in a great number of dependencies. On Sulis systems we recommended only installing and using the IJulia package after loading JupyterNotebook and other environment modules which will already provide most of these dependencies.

[user@login01(sulis) ~]$ module purge
[user@login01(sulis) ~]$ module load GCC/13.2.0
[user@login01(sulis) ~]$ module load JupyterNotebook/GCC/13.2.0
[user@login01(sulis) ~]$ module load SciPy-bundle/2023.11 matplotlib/3.8.2
[user@login01(sulis) ~]$ module load Julia/1.10.4-linux-x86_64
[user@login01(sulis) ~]$ julia -e 'import Pkg;Pkg.add("IJulia")'

Notebook servers launched using the command jupyter notebook will then have the Julia kernel available.

Jupyter notebook servers should not be launched on the login node, but from within an interactive job on a compute node.

Please study the application note on Jupyter for information on how to connect to the remote notebook.

Parallelism in Julia

Two popular ways of exploiting parallelism within a single Julia script are documented at the relevant pages linked below.