Julia
Julia was created as an open source alternative to MATLAB and Octave.
External Links:
Julia website
Learning Julia
Loading Julia
There are various versions of Julia on Hazel. To see the various versions available, type module avail julia.
To set the environment, load the module. This will load the latest version of Julia (1.12.6).
module load juliaTo load a specific version of Julia.
module load julia/1.11.6
Running Julia
Do not use Julia on a login node. Submit Julia scripts with a batch submission file, and use the HPC-VCL if doing interactive visualization with Julia.
Batch Serial Julia Job
Here is an example batch script. For more information on submitting batch scripts, see the documentation on running jobs.
For a sample Julia script called my_code.jl containing
# a simple Julia code
using LinearAlgebra
a = [1,2,4];
println("a",a)
b = normalize(a)
println("normalize(a)",b)
println("norm(b)",norm(b))
and a sample submission script submit.sh
#!/bin/bash #SBATCH --ntasks=1 #SBATCH --time=00:30:00 #SBATCH --output=out.%j #SBATCH --error=err.%j module load julia julia my_code.jl
a batch job is submitted as
sbatch submit.sh
Script submit.sh requests the use of 1 core (--ntasks=1) for up to 30 minutes (--time=00:30:00). The output in out.JOBID is
a[1, 2, 4] normalize(a)[0.2182178902359924, 0.4364357804719848, 0.8728715609439696] norm(b)1.0Check the documentation on running jobs to customize the batch script.
Batch Shared Memory Parallelization (Multithreading) Julia Job
If your Julia script takes advantage of multithreading (i.e., using more than one core on just one node for parallelization), then you need to change your batch submission file accordingly.
Here is an example "Hello World" .jl script for multithreading called test_multithread.jl:
import Printf N=4 Threads.@threads for i in 1:N sleep(1) Printf.@printf "Hello from thread %d\n" i end
Here is a sample submission script submit.sh. It is important to note that shared memeory jobs can only be run with the latest version of Julia (1.12.6), which is the default version of Julia on the cluster.
#!/bin/bash #SBATCH --ntasks=1 #SBATCH --cpus-per-task=4 #SBATCH --time=00:30:00 #SBATCH --mem=20G #SBATCH --output=out.%j #SBATCH --error=err.%j module load julia julia test_multithread.jl
The batch job is submitted as
sbatch submit.sh
Script submit.sh requests the use of 4 cores (--cpus-per-task=4) and 20 GB of RAM (--mem=20G) for up to 30 minutes (--time=00:30:00). The output in out.JOBID looks similar to (order of threads differs each time)
Hello from thread 1 Hello from thread 2 Hello from thread 4 Hello from thread 3
Batch Distributed Memory Parallelization (MPI) Julia Job
If your Julia script takes advantage of MPI (i.e., using multiple cores on multiple nodes for parallelization), then you need to change your batch submission file accordingly.
Here is an example "Hello World".jl script for MPI: example
Here is the submission script submit.sh for 04-sendrecv.jl. Similar to the shared memory jobs, it is important to note that distributed memory jobs can only be run with the latest version of Julia (1.12.6), which is the default version of Julia on the cluster.
#!/bin/bash #SBATCH --ntasks=4 #SBATCH --cpus-per-task=1 #SBATCH --time=00:30:00 #SBATCH --output=out.%j #SBATCH --error=err.%j module load julia srun julia 04-sendrecv.jl
A batch job is submitted as
sbatch submit.sh
and the output in out.JOBID looks similar to (order may be different, in fact, it may be different every time you run it)
Loading julia/1.12.6 Loading requirement: openmpi-gcc/openmpi5.0.9-gcc11.5.0-slurm 1: Sending 1 -> 2 = [1.0, 1.0, 1.0, 1.0] 3: Sending 3 -> 0 = [3.0, 3.0, 3.0, 3.0] 0: Sending 0 -> 1 = [0.0, 0.0, 0.0, 0.0] 0: Received 3 -> 0 = [3.0, 3.0, 3.0, 3.0] 2: Sending 2 -> 3 = [2.0, 2.0, 2.0, 2.0] 3: Received 2 -> 3 = [2.0, 2.0, 2.0, 2.0] 2: Received 1 -> 2 = [1.0, 1.0, 1.0, 1.0] 1: Received 0 -> 1 = [0.0, 0.0, 0.0, 0.0]Check the documentation on running jobs to customize the batch script.
Installing Julia packages
Additional packages outside of the base Julia install must be installed by the user. See the instructions for request a space for user maintained software.
The basic process to install a new Julia package is to use Pkg.add from a login node. By default, Julia will install the packages in the home directory in ~/.julia. That will quickly fill the home directory. The Research Storage is a good option: OIT Research Storage
The generic path /path/to/pkgs will be used below as a placeholder below. Use the appropriate path you have access to.
Personal Research Storage
If you have your own research storage space, your path will be /rs1/researchers/<first_letter_of_your_username>/$USER/
PI's Research Storage
If you are a member of a PI's research group, your path will be /rs1/researchers/<first_letter_of_your_PI_username>/<PI_username>/
Before installing packages, set the location for the installs by setting JULIA_DEPOT_PATH to the user maintained software directory.
mkdir -p /path/to/pkgs/.julia export JULIA_DEPOT_PATH=/path/to/pkgs/.julia
module load julia
julia
import Pkg
Pkg.add("whatever")
Check the Julia documentation on setting environment variables.
Last modified: September 01 2026 21:22:40.