You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* multinode multi process and hybrid jobs
* julia minor and major version, fixes
* activate project when spawning new worker process
* improved threads code, restructuring
* improved description, web interface
* restructuring titles
* restructuring
* improvements
* added julia tutorial to list, title and description
* moved pkg.instantiate to batch scripts
* restructuring
* improvement
* fix
* Fixed misspelling of 'everywhere'
* added julia web interface documentation
* grammar
* refactoring, julia on lumi available
* refactoring, LUMI examples
* changed gpu example
* single node mahti example using interactive partition
* fixed typo
* improvements
* threading, mkl, linear algebra
* glossary, grammar
* glossary
* fixed sbatch option
---------
Co-authored-by: Jaan Tollander de Balsch <jaan.tollander.de.balsch@csc.fi>
Co-authored-by: Joonas Somero <joonas.somero@csc.fi>
Co-authored-by: Rasmus Kronberg <43936697+rkronberg@users.noreply.github.com>
Co-authored-by: Joonas Somero <50655931+joonas-somero@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/apps/julia.md
+66-26Lines changed: 66 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
---
1
+
2
2
tags:
3
3
- Free
4
4
---
@@ -16,7 +16,15 @@ Julia language is licensed under free and open source [MIT license](https://gith
16
16
17
17
18
18
## Available
19
-
Julia language is available on Puhti and Mahti using the [module system](../computing/modules.md).
19
+
Julia language is available on Puhti, Mahti, and LUMI using the [module system](../computing/modules.md).
20
+
On Puhti and Mahti, the Julia module is included on the module path by default.
21
+
On LUMI, we must add the module files under CSC's local directory to the module path as follows.
22
+
23
+
```bash
24
+
module use /appl/local/csc/modulefiles
25
+
```
26
+
27
+
We can check the available versions as follows.
20
28
21
29
```bash
22
30
module avail julia
@@ -55,31 +63,56 @@ Julia's REPL and Pkg, the package manager, are two important packages within the
55
63
The [Pkg documentation](https://pkgdocs.julialang.org/) provides more information on how to use Julia's package manager.
56
64
57
65
66
+
### More information
67
+
We can print details about paths and environment variables set by the Julia module as follows.
68
+
69
+
```bash
70
+
module show julia
71
+
```
72
+
73
+
We can also print useful information about the Julia version, platform and environment in the REPL as follows.
74
+
75
+
```julia
76
+
using InteractiveUtils # automatically load in the REPL
77
+
versioninfo()
78
+
```
79
+
80
+
58
81
### Using environments
59
82
Julia manages dependencies of projects using environments.
60
83
An environment consists of two files, `Project.toml` and `Manifest.toml`, which specify dependencies for the environment.
61
-
We define project metadata, dependencies, and compatibility constraints in `Project.toml` file.
84
+
We define project metadata, dependencies, and compatibility constraints in the `Project.toml` file.
62
85
Adding or removing packages using the package manager manipulates the `Project.toml` file in the active environment.
63
-
Furthermore, the package manager maintains a full list of dependencies in `Manifest.toml` file.
86
+
Furthermore, the package manager maintains a full list of dependencies in the `Manifest.toml` file.
64
87
It creates both of these files if they don't exist.
65
88
Let's consider a Julia project structured as follows.
66
89
67
90
```
68
-
project
91
+
project/
69
92
├── script.jl
70
93
├── Project.toml
71
94
└── Manifest.toml
72
95
```
73
96
74
-
We can activate an environment using the `--project` option when starting Julia or use the `Pkg.activate` function in existing Julia session.
97
+
We can activate an environment using the `--project` option when starting Julia or use the `Pkg.activate` function in the existing Julia session.
75
98
For example, we can open the Julia REPL with the project's environment active as follows:
76
99
77
100
```bash
78
101
julia --project=.
79
102
```
80
103
104
+
We can call the `Base.active_project()` function to retrieve a path to the active project, that is, `Project.toml` file.
105
+
81
106
Activating an environment does not automatically install the packages defined by `Manifest.toml` or `Project.toml`.
82
-
For that, we need to invoke the `Pkg.instantiate` function with the project's environment active as follows:
107
+
For that, we need to instantiate the project as follows:
108
+
109
+
```julia
110
+
using Pkg
111
+
Pkg.activate(".")
112
+
Pkg.instantiate()
113
+
```
114
+
115
+
Alternatively, we can use the following one-liner:
83
116
84
117
```bash
85
118
julia --project=. -e 'using Pkg; Pkg.instantiate()'
@@ -92,7 +125,7 @@ julia --project=. script.jl
92
125
```
93
126
94
127
Julia will activate the default environment if we don't specify an environment.
95
-
We should always use a unique environment for Julia projects instead of the default environment.
128
+
Preferably, we should use a unique environment for Julia projects instead of the default environment.
96
129
That way, we can manage the dependencies of different Julia projects separately.
97
130
98
131
@@ -103,8 +136,14 @@ On the Julia REPL, we can use the package manager by importing it.
103
136
using Pkg
104
137
```
105
138
139
+
We can activate a Julia environment on the current working directory as follows.
140
+
141
+
```julia
142
+
Pkg.activate(".")
143
+
```
144
+
106
145
We can add packages to the active environment using the `Pkg.add` function.
107
-
For example, we can add `ArgParse` package as follows.
146
+
For example, we can add the `ArgParse` package as follows.
108
147
109
148
```julia
110
149
Pkg.add("ArgParse")
@@ -124,34 +163,35 @@ Pkg.compat("julia", "1.8")
124
163
```
125
164
126
165
127
-
### Depot and load paths
166
+
### Code loading and the shared environment
128
167
The Julia constants [`Base.DEPOT_PATH`](https://docs.julialang.org/en/v1/base/constants/#Base.DEPOT_PATH) and [`Base.LOAD_PATH`](https://docs.julialang.org/en/v1/base/constants/#Base.LOAD_PATH) constants control the directories where Julia loads code.
129
168
To set them via the shell, we use the `JULIA_DEPOT_PATH` and `JULIA_LOAD_PATH` environment variables.
169
+
We can call the `Base.load_path()` function to retrieve the expanded load path.
130
170
The Julia module automatically appends the default depot and load paths to ensure the standard library and shared depots are available.
131
-
The CSC-specific shared depots are installed in the `JULIA_CSC_DEPOT` directory, and the shared environment is in the `JULIA_CSC_ENVIRONMENT` directory.
132
-
We can look up the shared packages and their versions using the package manager as follows:
171
+
172
+
The first directory on the depot path controls where Julia stores installed packages, compiled files, log files, and other depots.
173
+
We can change the directory by prepending the `JULIA_DEPOT_PATH` with a different directory.
174
+
For example, we can use the following by replacing the `<project>` with your CSC project.
133
175
134
176
```bash
135
-
julia --project="$JULIA_CSC_ENVIRONMENT" -e 'using Pkg; Pkg.status()'
The first directory on the depot path controls where Julia stores installed packages, compiled files, log files, and other depots.
139
-
140
-
!!! warning "Changing the default depot directory"
141
-
The default depot directory is `$HOME/.julia`.
180
+
!!! warning "Changing the default depot directory."
181
+
By default, the first depot directory in the depot path is `$HOME/.julia`.
142
182
However, the home directory has a fixed quota for Puhti and Mahti.
143
-
Therefore, we recommend changing the directory to a directory under Projappl or Scratch to avoid running out of quota because some packages install a large amounts of files.
144
-
Afterwards, you can safely remove the default depot directory using `rm -r $HOME/.julia`.
183
+
Therefore, we recommend changing the directory to a directory under Projappl or Scratch to avoid running out of quota because some packages install a large number of files.
184
+
Afterward, you can safely remove the default depot directory using `rm -r $HOME/.julia`.
145
185
146
-
We can change the directory by prepending the `JULIA_DEPOT_PATH` with a different directory.
147
-
For example, we can use the following by replacing the `<project>` with your CSC project.
186
+
The CSC-specific shared depots are installed in the `CSC_JULIA_DEPOT_DIR` directory, and the shared environment is in the `CSC_JULIA_ENVIRONMENT_DIR` directory.
187
+
We can look up the shared packages and their versions using the package manager as follows:
julia --project="$CSC_JULIA_ENVIRONMENT_DIR" -e 'using Pkg; Pkg.status()'
151
191
```
152
192
153
193
154
-
### Creating a package with command line interface
194
+
### Creating a package with a command line interface
155
195
We should package the code as a code base grows instead of running standalone scripts.
156
196
A Julia package includes a module file, such as `src/Hello.jl`, and the `Project.toml` file.
157
197
Including a command line interface in your program, such as `src/cli.jl`, is also wise.
@@ -195,7 +235,7 @@ export say
195
235
end
196
236
```
197
237
198
-
We can use `ArgParse` package to create a command line interface `src/cli.jl` for the package.
238
+
We can use the `ArgParse` package to create a command line interface `src/cli.jl` for the package.
199
239
For example, the command line interface below defines an option `--say` whose value is parsed into a string and supplied to the `say` function imported from the `Hello` module.
200
240
201
241
```julia
@@ -221,8 +261,8 @@ julia --project=. src/cli.jl --say "Hello world"
221
261
We should define and use a command line interface because it is more flexible than hard-coding values to the scripts.
222
262
223
263
224
-
### Running Julia jobs on Puhtiand Mahti
225
-
We explain how to run serial, parallel and GPU jobs with Julia on Puhtiand Mahti in the [**Running Julia jobs on Puhtiand Mahti clusters**](../support/tutorials/julia.md)section.
264
+
### Running Julia jobs on Puhti, Mahti, and LUMI clusters
265
+
We explain how to run serial, parallel, and GPU jobs with Julia on Puhti, Mahti, and LUMI in the [**Running Julia jobs on Puhti, Mahti, and LUMI clusters**](../support/tutorials/julia.md)tutorial.
0 commit comments