Skip to main content

Using Julia

Julia is installed as a public Mamba environment. To use it, either use the julia-1.12.2 kernel in the Jupyter Notebook on Sol Web Portal, or activate the environment by running the following command in the terminal:

module load mamba/latest
module load cuda-13.0.1-gcc-12.1.0 # if CUDA is needed
source activate julia-1.12.2
julia

Using Julia in Jupyter Notebook

This environment and the corresponding Jupyter kernel have some common Julia packages pre-installed and CUDA-enabled, if you would like to install additional Julia packages, please contact the ASU Research Computing team.

Building Julia

Below is a build script to install a Julia to a private Mamba environment, and also create a private Jupyter kernel. The installation should be executed in an interactive session on a compute node.

Click here to expand...
!#/bin/bash

# Clean up old installations
rm -rf ~/.local/share/jupyter/kernels/julia*

# Create directories
mkdir -p ~/.conda/envs/julia-1.12.2/share/julia-depot
mkdir -p ~/.conda/envs/julia-1.12.2/share/project

# Set environment
export JULIA_DEPOT_PATH=~/.conda/envs/julia-1.12.2/share/julia
export JULIA_CPU_TARGET="generic"
export JULIA_NUM_THREADS="auto"
export JULIA_CONDAPKG_BACKEND="Null"

# If CUDA is needed
module load cuda-13.0.1-gcc-12.1.0

# Create and activate mamba env
module load mamba
mamba create -n julia-1.12.2 -c conda-forge python=3 julia=1.12.2
source activate julia-1.12.2

# Install IJulia for Jupyter Notebook functionalities
julia -e 'using Pkg; Pkg.add("IJulia")' # Add more packages here if needed

# Install the Jupyter kernel
julia -e '
using IJulia
installkernel("julia-1.12.2",
env=Dict(
"JULIA_DEPOT_PATH" => "~/.conda/envs/julia-1.12.2/share/julia",
"JULIA_CPU_TARGET" => "generic",
"JULIA_NUM_THREADS" => "auto",
"JULIA_CONDAPKG_BACKEND" => "Null"
)
)
'
# Verify the kernel spec
cat ~/.local/share/jupyter/kernels/julia*/kernel.json

Below is an example Jupyter kernel spec file, please modify your kernel spec file accordingly:

Click here to expand...
{
"display_name": "julia-1.12.2",
"argv": [
"~/.conda/envs/julia-1.12.2/bin/julia",
"-i", "--color=yes",
"--project=~/.conda/envs/julia-1.12.2/share/julia/environments/julia-1.12.2",
"-e", "import IJulia; IJulia.run_kernel()",
"{connection_file}"
],
"language": "julia",
"env": {
"JULIA_CPU_TARGET": "generic",
"JULIA_CONDAPKG_BACKEND": "Null",
"JULIA_DEPOT_PATH": "~/.conda/envs/julia-1.12.2/share/julia",
"JULIA_NUM_THREADS": "auto",
"CUDA_HOME": "/packages/apps/spack/21/opt/spack/linux-rocky8-zen3/gcc-12.1.0/cuda-13.0.1-x5y4dihvo7xwxgmwwdhedmrmcrjm3cjh"
},
"interrupt_mode": "signal"
}

Once the Mamba environment and the Jupyter kernel are set up correctly, you would be able to install more Julia packages via command line and don't need to regenerate the kernel.