# Using Julia on Cluster

**URL:** https://discourse.julialang.org/t/using-julia-on-cluster/95592
**Category:** New to Julia
**Tags:** question
**Created:** [March 6, 2023, 5:49am UTC](https://discourse.julialang.org/t/using-julia-on-cluster/95592 "2023-03-06T05:49:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![legendaryh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/legendaryh/32/47423_2.png) [@legendaryh](https://discourse.julialang.org/u/legendaryh)
#### Post date: [March 6, 2023, 5:49am UTC](https://discourse.julialang.org/t/using-julia-on-cluster/95592/1 "2023-03-06T05:49:11Z")

</div>

I am new to HPC. I am trying to run Julia on a cluster that uses slurm, but there’s no julia module pre-installed in it. Although I have installed Julia in my directory, I don’t know how to write the sbatch file that calls julia from my directory and then runs the .jl file. Anyone have any idea how to do it?

---

<div class="post-metadata">

### Author: ![KajWiik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kajwiik/32/199_2.png) [@KajWiik](https://discourse.julialang.org/u/KajWiik)
#### Post date: [March 6, 2023, 7:37am UTC](https://discourse.julialang.org/t/using-julia-on-cluster/95592/2 "2023-03-06T07:37:08Z")

</div>

See e.g.

> [@Running Julia in a SLURM Cluster](https://discourse.julialang.org/t/running-julia-in-a-slurm-cluster/67614):
>
> I’m looking to provide an explicit explanation of the simplest way to get a Julia program running in parallel across multiple nodes in a SLURM cluster (basically a minimal working example that illustrates the logic). My impression so far is that there are two primary ways to run Julia in a SLURM cluster. Suppose I want to define a function and run it in a parallel for-loop on N cores distributed across M nodes in the cluster: Option 1 The first option comes from [this Stackoverflow post](https://stackoverflow.com/questions/65250900/julia-parallel-processing-on-pbs-multiple-nodes). Basic…

---

<div class="post-metadata">

### Author: ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)
#### Post date: [March 6, 2023, 7:37am UTC](https://discourse.julialang.org/t/using-julia-on-cluster/95592/3 "2023-03-06T07:37:11Z")

</div>

What’s unclear to you? Something like the following should do it.

```julia
#!/bin/bash
#SBATCH -t 1:00:00
#SBATCH -N 1
#SBATCH -n 1
#SBATCH -J "my julia computation"
#SBATCH -p normal
#SBATCH -A myaccount

export PATH=/path/to/my/custom/julia/:$PATH
srun julia myscript.jl

```

Of course, you likely need not change the sbatch parameters, like the partition and account name.
