# Getting started with HPC and Julia

**URL:** https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213
**Category:** General Usage
**Tags:** distributed
**Created:** [September 25, 2023, 9:43am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213 "2023-09-25T09:43:06Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![kerim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kerim/32/37844_2.png) [@kerim](https://discourse.julialang.org/u/kerim)
#### Post date: [September 25, 2023, 9:43am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/1 "2023-09-25T09:43:06Z")

</div>

Hi,

I’ve built small cluster (master node and 4 other nodes) on the cloud and now I need to check whether Julia Distributed is able to use it.

Setup:  
Julia dirpath: `~/julia` - all the nodes have it  
Single shared folder: `~/shared` - created on master node and mounted on all other nodes

When I lauch Julia and check the number of workers `nworkers()` it shows only 1.

I guess something doesn’t work as I expect.  
What are possible my mistakes?

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [September 25, 2023, 9:58am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/2 "2023-09-25T09:58:45Z")

</div>

> [@kerim](#):
>
> When I lauch Julia and check the number of workers `nworkers()` it shows only 1.

_How_ are you launching julia?

---

<div class="post-metadata">

### Author: ![kerim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kerim/32/37844_2.png) [@kerim](https://discourse.julialang.org/u/kerim)
#### Post date: [September 25, 2023, 9:59am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/3 "2023-09-25T09:59:44Z")

</div>

Hi,

julia executable is in the PATH env var so I just type `julia` on master node.

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [September 25, 2023, 10:03am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/4 "2023-09-25T10:03:52Z")

</div>

Julia by default starts with a single process:

```julia
% julia -E 'using Distributed; nprocs(), nworkers()'
(1, 1)

```

so there’s nothing surprising there. You may want to read the [documentation of the `Distributed` standard library](https://docs.julialang.org/en/v1/stdlib/Distributed/).

---

<div class="post-metadata">

### Author: ![kerim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kerim/32/37844_2.png) [@kerim](https://discourse.julialang.org/u/kerim)
#### Post date: [September 25, 2023, 10:08am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/5 "2023-09-25T10:08:15Z")

</div>

I know I can run `julia -p 5` but even if julia ca’nt see other nodes it will still be launched with 5 workers splitting single machine CPU by workers.

For now the main task is to understand whether Julia can actually see other nodes or not.  
I could probaly check it by IP of each worker but can’t find information on that.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [September 25, 2023, 10:24am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/6 "2023-09-25T10:24:54Z")

</div>

Worth sharing:

> **[GitHub - Arpeggeo/julia-distributed-computing: The ultimate guide to...](https://github.com/Arpeggeo/julia-distributed-computing)**
>
> The ultimate guide to distributed computing in Julia - GitHub - Arpeggeo/julia-distributed-computing: The ultimate guide to distributed computing in Julia

---

<div class="post-metadata">

### Author: ![kerim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kerim/32/37844_2.png) [@kerim](https://discourse.julialang.org/u/kerim)
#### Post date: [September 25, 2023, 10:40am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/7 "2023-09-25T10:40:29Z")

</div>

Thank you for sharing this!

I guess for now the main problem is that I can’t setup the cluster. Distributed can’t see other nodes ☹

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [September 25, 2023, 10:48am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/8 "2023-09-25T10:48:25Z")

</div>

Are you using the ClusterManagers.jl as explained in the resource above? Or creating the submission scripts? What is the resource manager installed in your cluster? Most Linux clusters I worked with use SLURM.

---

<div class="post-metadata">

### Author: ![kerim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kerim/32/37844_2.png) [@kerim](https://discourse.julialang.org/u/kerim)
#### Post date: [September 25, 2023, 10:50am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/9 "2023-09-25T10:50:57Z")

</div>

Oh I think I don’t have any cluster manager yet.  
I’m reading about SLURM now.Probably after setting it we will see some progress.

---

<div class="post-metadata">

### Author: ![kerim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kerim/32/37844_2.png) [@kerim](https://discourse.julialang.org/u/kerim)
#### Post date: [September 28, 2023, 9:41am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/10 "2023-09-28T09:41:19Z")

</div>

Hi,

It seems I successfully created small cluster and installed SLURM.  
`sinfo` outout:

```julia
PARTITION AVAIL TIMELIMIT NODES STATE NODELIST
debug* up infinite 3 idle cl1cfqj5m64qsem9ra43-ecaj.ru-central1.internal,cl1cfqj5m64qsem9ra43-ukeq.ru-central1.internal,master-fwi.ru-central1.internal

```

`srun -N3 hostname` produces:

```julia
cl1cfqj5m64qsem9ra43-ecaj.ru-central1.internal
master-fwi.ru-central1.internal
cl1cfqj5m64qsem9ra43-ukeq.ru-central1.internal

```

I hope it is working correctly and it took me 3 days to solve this 🙂

But then I return to Julia.  
First of all I must be sure that Julia can see all nodes (do I have to launch Julia on all nodes or it is enought that `julia` bin directory was in the `PATH` env var?).  
I installed `ClusterManagers.jl]` on all nodes and following its example I run:

```julia
using Distributed, ClusterManagers
addprocs(SlurmManager(2), partition="debug", t="00:5:00")

```

and then Julia hangs on:

```julia
connecting to worker 1 out of 2
srun: error: cl1cfqj5m64qsem9ra43-ecaj.ru-central1.internal: tasks 0-1: Exited with exit code 1

```

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [September 28, 2023, 9:51am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/11 "2023-09-28T09:51:04Z")

</div>

Can you try the tutorial I shared without ClusterManagers.jl first? Just create a SLURM submission script and see if it works as expected. If it doesn’t then other people can help setting up slurm and Julia correctly.

---

<div class="post-metadata">

### Author: ![kerim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kerim/32/37844_2.png) [@kerim](https://discourse.julialang.org/u/kerim)
#### Post date: [September 28, 2023, 10:05am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/12 "2023-09-28T10:05:54Z")

</div>

I cloned the directory you provided and `cd` into it.  
Then in julia after `Pkg.instantiate(); Pkg.precompile()` I get error:

```julia
Pkg.instantiate(); Pkg.precompile()
┌ Warning: The active manifest file has dependencies that were resolved with a different julia version (1.9.0). Unexpected behavior may occur.
└ @ ~/shared/dev/julia-distributed-computing/Manifest.toml:0
ERROR: MethodError: no method matching joinpath(::Nothing)
Closest candidates are:
  joinpath(::AbstractString) at path.jl:251
  joinpath(::AbstractString, ::AbstractString...) at path.jl:296
Stacktrace:
  [1] stat(path::Nothing)
    @ Base.Filesystem ./stat.jl:109
  [2] ispath(path::Nothing)
    @ Base.Filesystem ./stat.jl:311
  [3] download_source(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}, urls::Dict{Base.UUID, Vector{String}}; readonly::Bool)
    @ Pkg.Operations /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/Operations.jl:752
  [4] #download_source#57
    @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/Operations.jl:742 [inlined]
  [5] download_source
    @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/Operations.jl:740 [inlined]
  [6] instantiate(ctx::Pkg.Types.Context; manifest::Nothing, update_registry::Bool, verbose::Bool, platform::Base.BinaryPlatforms.Platform, allow_build::Bool, allow_autoprecomp::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Pkg.API /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/API.jl:1410
  [7] instantiate
    @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/API.jl:1325 [inlined]
  [8] #instantiate#252
    @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/API.jl:1321 [inlined]
  [9] instantiate()
    @ Pkg.API /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/API.jl:1321
 [10] top-level scope
    @ REPL[2]:1

```

Julia 1.6.7

---

<div class="post-metadata">

### Author: ![kerim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kerim/32/37844_2.png) [@kerim](https://discourse.julialang.org/u/kerim)
#### Post date: [September 28, 2023, 10:07am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/13 "2023-09-28T10:07:25Z")

</div>

I can see that in `Manifest.toml` the required Julia version is 1.9.0  
Probably this is an issue?

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [September 28, 2023, 10:12am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/14 "2023-09-28T10:12:40Z")

</div>

The error message is clear about the Julia version. Also the tutorial I shared doesn’t have a script to run on slurm.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [September 28, 2023, 10:13am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/15 "2023-09-28T10:13:36Z")

</div>

Can you read the README and follow the steps instead? You don’t need to clone the repository.

---

<div class="post-metadata">

### Author: ![kerim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kerim/32/37844_2.png) [@kerim](https://discourse.julialang.org/u/kerim)
#### Post date: [September 28, 2023, 11:05am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/16 "2023-09-28T11:05:48Z")

</div>

It seems I’ve found a way to run the code:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/b/9b2846e4a755da8649957288f89eef101df3d12b.png)

To run on multiple nodes I gues I ether have to prepare SLURM script or slightly modify julia script to add workers first right?  
As I don’t know yet how to write SLURM script I prefer to `addprocs(2)` in the julia script.  
But my nodes dont have `CSV` and `ProgressMeter` packages. How can I install these packages to all nodes?

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [September 28, 2023, 11:13am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/17 "2023-09-28T11:13:00Z")

</div>

Can you please continue reading the README?

---

<div class="post-metadata">

### Author: ![kerim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kerim/32/37844_2.png) [@kerim](https://discourse.julialang.org/u/kerim)
#### Post date: [September 28, 2023, 11:25am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/18 "2023-09-28T11:25:15Z")

</div>

I think we misunderstand each other…

I use julia 1.6.7 so it seems I can’t install this repo. Whe I use:

```julia
add https://github.com/Arpeggeo/julia-distributed-computing.git
     Cloning git-repo `https://github.com/Arpeggeo/julia-distributed-computing.git`
    Updating git-repo `https://github.com/Arpeggeo/julia-distributed-computing.git`
ERROR: expected a `name` entry in project file at `/tmp/jl_2cQn6c/Project.toml

```

So I don’t know why but I can’t install this package.

Then you say I don’t have to clone the package… Then to use it? The provided script uses `data/` and `result/` dir.

Reading README doesn’t give much sorry…

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [September 28, 2023, 11:34am UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/19 "2023-09-28T11:34:23Z")

</div>

The README **teaches** you how to do distributed computing. You don’t need to clone the repo, reproduce the example, or anything like that.

If you had read the README from beginning to end you would find out the last section explaining the creation of submission scripts. It is super easy to search online for SLURM submission script and reproduce the example.

I will let other people help you from here.

---

<div class="post-metadata">

### Author: ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)
#### Post date: [September 28, 2023, 2:51pm UTC](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213/20 "2023-09-28T14:51:21Z")

</div>

Stupid question - why are you using Julia 1.6.7 ?  
ALso another point - above you say that packages need to be installed on compute nodes.  
You should have a shared directory which is mounted on all nodes. If a packages is installed it should be available everywhere. Maybe I am misunderstanding this.

[Next page](https://discourse.julialang.org/t/getting-started-with-hpc-and-julia/104213.md?page=2)
