Julia: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
No edit summary
(language cleanup)
Line 1: Line 1:
[[Category:Software]]
[[Category:Software]]
{{Draft}}


[https://julialang.org Julia] is a programming language that was designed from the beginning for performance, ease of use and portability. It is is available as a [[Utiliser_des_modules/en | module]] on Compute Canada clusters.
[https://julialang.org Julia] is a programming language that was designed from the beginning for performance, ease of use and portability. It is is available as a [[Utiliser_des_modules/en | module]] on Compute Canada clusters.
{{Draft}}


= Compiling packages =


= Compiling Packages =
When compiling packages for Julia, files will normally be added to <code>~/.julia</code>.  However, you may run into problems if the package depends on system-provided libraries.  For instance, [https://github.com/JuliaIO/JLD.jl JLD] depends on a system-provided HDF5 library.  On a personal computer, Julia attempts to install such a dependency using [https://en.wikipedia.org/wiki/Yum_(software) yum] or [https://en.wikipedia.org/wiki/APT_(Debian) apt] with [https://en.wikipedia.org/wiki/Sudo sudo].  This will not work on a Compute Canada cluster; instead, some extra information must be provided to allow Julia's package manager (Pkg) to find the HDF5 library.
Julia should be have properly when compiling packages: files will be added to <code>~/.julia</code>; but you may run into problems if the package depends on system-provided libraries.  For instance, [https://github.com/JuliaIO/JLD.jl JLD] depends on a system-provided HDF5 library.  On a desktop, Julia attempts to install such a dependency by spawning yum/apt operations with sudo.  This doesn't work on ComputeCanada systems; instead, some extra information must be provided to allow the Pkg build system to find the HDF5 library.


  [hahn@gra-login2 ~]$ module load gcc/7.3.0 hdf5 julia/1.0.2
  [hahn@gra-login2 ~]$ module load gcc/7.3.0 hdf5 julia/1.0.2
Line 16: Line 17:
  julia> using JLD
  julia> using JLD


This example happens to work on Graham without the <code>Libdl.DL_LOAD_PATH</code>, because Graham happens to have a copy of HDF5 installed system-wide from Centos.  It fails on Cedar because Cedar's base image doesn't happen to include HDF5.  And the real point is that we should probably want to use the ComputeCanada version anyway, which we load via "module", and works uniformly on all systems.  (The HDF5 module provides the <code>HDF5_DIR</code> environment setting, which we use to show Pkg how to find and load via <code>Libdl</code>.)
If we were to omit the <code>Libdl.DL_LOAD_PATH</code> line from the above example, it would happen to work on Graham because Graham has HDF5 installed system-wide.  It would fail on Cedar because Cedar does not.  The best practice on ''any'' Compute Canada system, though, is that shown above: Load the appropriate [[Utiliser_des_modules/en | module]] first, and use the environment variable defined by the module (<code>HDF5_DIR</code> in this example) to extend <code>Libdl.DL_LOAD_PATH</code>. This will work uniformly on all systems.


= Package file usage (and storage quotas) =
= Package files and storage quotas =
In the example above, installing just the JLD package creates a <code>~/.julia</code> tree with 18673 files/directories and using 236M of space (4-5% of a standard user quota for /home).  It's worth remembering that installing a lot of packages will consume a lot of space.


In the example above, installing just the JLD package creates a <code>~/.julia</code> tree with 18673 files and directories and using 236M of space, almost 5% of a standard user's quota for /home.  It's worth remembering that installing a lot of packages will consume a lot of space.


= Available Versions =  
= Available Versions =  


We had to remove earlier versions of Julia (< 1.0) because the old package manager was creating vast numbers of small files which would cause performance issues on the parallel file systems.  Please start using Julia 1.0.2 and newer.
We have removed earlier versions of Julia (< 1.0) because the old package manager was creating vast numbers of small files which in turn caused performance issues on the parallel file systems.  Please start using Julia 1.0.2, or newer versions.


{{Command
{{Command
Line 42: Line 43:
}}
}}


== Transitioning code from Julia 0.x to 1.x ==
== Porting code from Julia 0.x to 1.x ==
In summer 2018 Julia released version 1.0, at which point they have stabilized the language API and removed deprecated (outdated) functionality.
 
To help updating Julia-code for version 1.0, the developers have also released version 0.7.0 (which will soon be available as a [[Using_modules | module]] as well).   
In the summer of 2018 the Julia developers released version 1.0, in which they stabilized the language API and removed deprecated (outdated) functionality.
Julia 0.7.0 contains all new functionality of 1.0 as well as the outdated functionalities from 0.x versions, which will give [https://en.wikipedia.org/wiki/Deprecation deprecation warnings] when used.
To help updating Julia programs for version 1.0, the developers also released version 0.7.0 (which will soon be available as a [[Using_modules | module]] as well).   
Code that runs in Julia 0.7 without warnings should be compatible Julia 1.0.
Julia 0.7.0 contains all the new functionality of 1.0 as well as the outdated functionalities from 0.x versions, which will give [https://en.wikipedia.org/wiki/Deprecation deprecation warnings] when used.
Code that runs in Julia 0.7 without warnings should be compatible with Julia 1.0.

Revision as of 18:24, 1 March 2019



This article is a draft

This is not a complete article: This is a draft, a work in progress that is intended to be published into an article, which may or may not be ready for inclusion in the main wiki. It should not necessarily be considered factual or authoritative.




Julia is a programming language that was designed from the beginning for performance, ease of use and portability. It is is available as a module on Compute Canada clusters.

Compiling packages

When compiling packages for Julia, files will normally be added to ~/.julia. However, you may run into problems if the package depends on system-provided libraries. For instance, JLD depends on a system-provided HDF5 library. On a personal computer, Julia attempts to install such a dependency using yum or apt with sudo. This will not work on a Compute Canada cluster; instead, some extra information must be provided to allow Julia's package manager (Pkg) to find the HDF5 library.

[hahn@gra-login2 ~]$ module load gcc/7.3.0 hdf5 julia/1.0.2
[hahn@gra-login2 ~]$ julia
julia> using Libdl
julia> push!(Libdl.DL_LOAD_PATH, ENV["HDF5_DIR"] * "/lib")
julia> using Pkg
julia> Pkg.add("JLD")
julia> using JLD

If we were to omit the Libdl.DL_LOAD_PATH line from the above example, it would happen to work on Graham because Graham has HDF5 installed system-wide. It would fail on Cedar because Cedar does not. The best practice on any Compute Canada system, though, is that shown above: Load the appropriate module first, and use the environment variable defined by the module (HDF5_DIR in this example) to extend Libdl.DL_LOAD_PATH. This will work uniformly on all systems.

Package files and storage quotas

In the example above, installing just the JLD package creates a ~/.julia tree with 18673 files and directories and using 236M of space, almost 5% of a standard user's quota for /home. It's worth remembering that installing a lot of packages will consume a lot of space.

Available Versions

We have removed earlier versions of Julia (< 1.0) because the old package manager was creating vast numbers of small files which in turn caused performance issues on the parallel file systems. Please start using Julia 1.0.2, or newer versions.

Question.png
[name@server ~]$ module spider julia
--------------------------------------------------------
  julia: julia/1.0.2
--------------------------------------------------------
[...]
    You will need to load all module(s) on any one of the lines below before the "julia/1.0.2" module is available to load.

      nixpkgs/16.09  gcc/7.3.0
[...]
Question.png
[name@server ~]$ module load gcc/7.3.0 julia/1.0.2

Porting code from Julia 0.x to 1.x

In the summer of 2018 the Julia developers released version 1.0, in which they stabilized the language API and removed deprecated (outdated) functionality. To help updating Julia programs for version 1.0, the developers also released version 0.7.0 (which will soon be available as a module as well). Julia 0.7.0 contains all the new functionality of 1.0 as well as the outdated functionalities from 0.x versions, which will give deprecation warnings when used. Code that runs in Julia 0.7 without warnings should be compatible with Julia 1.0.