JUSTUS2/Software/Julia: Difference between revisions

From bwHPC Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 18: Line 18:
|-
|-
| Links
| Links
| [https://julialang.org/ Project homepage] | [https://docs.julialang.org/en/v1/ Documentation]n]
| [https://julialang.org/ Project homepage] | [https://docs.julialang.org/en/v1/ Documentation]
|-
|-
| Graphical Interface
| Graphical Interface
Line 26: Line 26:
== Introduction ==
== Introduction ==


Julia is a high-level, high-performance, dynamic programming language, being designed with scientific computing in mind.
Julia is a high-level, high-performance, dynamic programming language, being designed with scientific computing in mind. Parallel programming features, such as multi-threading are included in the core language, while there also exit packages leveraging the power of MPI and CUDA.

There are no packages preinstalled besides the Julia language core, please use the Julia package manager to install any required Julia package.

The Julia module on Justus loads suitable versions of CUDA and OpenMPI and the corresponding Julia packages CUDA.jl and MPI.jl will be automatically configured to use these libraries after being installed by the user. Any changes, either by loading modules with different MPI and/ or CUDA versions as well as using the ones that come as Julia artifacts are likely to lead to errors.

== Environments and Package Installation ==

It is highly recommended to use an separate Julia environment for every project. If Julia is started with the option <code>--project=.</code> the current folder will be used as environment and the <code>Project.toml</code> file containing the information on the installed packages will be created, if not yet present.

In an interactive Julia session, the [https://pkgdocs.julialang.org/v1/getting-started/#Basic-Usage package manager] is activated by entering <code>]</code>. The most importent commands are
* <code>add PACKAGENAME</code> install package PACKAGENAME in the current environment
* <code>instantiate</code>: install all packages with dependencies as stated in Project.toml and Manifest.toml, e.g. after copying the existing code to the cluster
* <code>activate PATH_TO_ENV</code>: use the environment located at the path <code>PATH_TO_ENV</code> and initialize it, if necessary.


== Interactive Example ==

Load Julia module and start interactive REPL session with 8 threads, using the environment in the current directory:

<pre>
$ module load math/julia
$ julia -t 8 --project=.
</pre>

Enter ']' to go into package manager and install package [https://github.com/JuliaPlots/UnicodePlots.jl?tab=readme-ov-file <code>UnicodePlots</code>].
<pre>
add UnicodePlots
</pre>

Leave the package manager with the backspace key.

Create a vector with 64 elements set to 0 and fill it using all 8 threads with the corresponding tread id number.

<pre>
vec = zeros(64)
Threads.@threads for i in eachindex(vec)
vec[i]= Threads.threadid()
end
</pre>

Load the <code>UnicodePlots</code> package and draw a scatter plot of the contents of <code>vec</code>

<pre>
using UnicodePlots
scatterplot(vec)
</pre>


== Further documentation ==

* [https://github.com/carstenbauer/JuliaHLRS24 Julia Workshop at HLRS]: The material of this workshop is in large parts also valid for the Justus cluster (on Justus you only need the module math/julia).

== Tips & Tricks ==

* [[JUSTUS2/Software/Julia/Parallel_Programming|Parallel Programming]]

Latest revision as of 15:07, 5 November 2024

The main documentation is available via module help math/julia on the cluster. Most software modules for applications provide working example batch scripts.


Description Content
module load math/julia
Availability bwUniCluster | JUSTUS2
License MIT License
Citing [1]
Links Project homepage | Documentation
Graphical Interface No

Introduction

Julia is a high-level, high-performance, dynamic programming language, being designed with scientific computing in mind. Parallel programming features, such as multi-threading are included in the core language, while there also exit packages leveraging the power of MPI and CUDA.

There are no packages preinstalled besides the Julia language core, please use the Julia package manager to install any required Julia package.

The Julia module on Justus loads suitable versions of CUDA and OpenMPI and the corresponding Julia packages CUDA.jl and MPI.jl will be automatically configured to use these libraries after being installed by the user. Any changes, either by loading modules with different MPI and/ or CUDA versions as well as using the ones that come as Julia artifacts are likely to lead to errors.

Environments and Package Installation

It is highly recommended to use an separate Julia environment for every project. If Julia is started with the option --project=. the current folder will be used as environment and the Project.toml file containing the information on the installed packages will be created, if not yet present.

In an interactive Julia session, the package manager is activated by entering ]. The most importent commands are

  • add PACKAGENAME install package PACKAGENAME in the current environment
  • instantiate: install all packages with dependencies as stated in Project.toml and Manifest.toml, e.g. after copying the existing code to the cluster
  • activate PATH_TO_ENV: use the environment located at the path PATH_TO_ENV and initialize it, if necessary.


Interactive Example

Load Julia module and start interactive REPL session with 8 threads, using the environment in the current directory:

$ module load math/julia
$ julia -t 8 --project=.

Enter ']' to go into package manager and install package UnicodePlots.

add UnicodePlots

Leave the package manager with the backspace key.

Create a vector with 64 elements set to 0 and fill it using all 8 threads with the corresponding tread id number.

vec = zeros(64)
Threads.@threads for i in eachindex(vec)
    vec[i]= Threads.threadid()
end

Load the UnicodePlots package and draw a scatter plot of the contents of vec

using UnicodePlots
scatterplot(vec)


Further documentation

  • Julia Workshop at HLRS: The material of this workshop is in large parts also valid for the Justus cluster (on Justus you only need the module math/julia).

Tips & Tricks