# Running Julia with multi-threading with \`qsub\`

**URL:** <https://discourse.julialang.org/t/running-julia-with-multi-threading-with-qsub/89850>\
**Category:** Performance\
**Tags:** parallel, multithreading, cluster, threads\
**Created:** [November 6, 2022, 8:11pm UTC](https://discourse.julialang.org/t/running-julia-with-multi-threading-with-qsub/89850 "2022-11-06T20:11:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rick](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@Rick](https://discourse.julialang.org/u/Rick)\
**Post date:** [November 6, 2022, 8:11pm UTC](https://discourse.julialang.org/t/running-julia-with-multi-threading-with-qsub/89850/1 "2022-11-06T20:11:16Z")

</div>

Hi everyone!!

I have a question on what is the correct way to run Julia with multithreads with `qsub`. I am trying to submit a job to the cluster to run Julia with multiple threads. I did the followings:

```bash
julia "test.jl" --threads 16

```

But it ended up running with 1 thread instead. I think it used 1 thread only because I call `nthreads()` inside the `test.jl` script and asks the code to export it.

Should I call Julia differently inside the `.qsub` script?

If I intend to use 16 threads, would it also be the best to use the followings to assign CPU as well (suppose I want 64 gb memory)?

```bash
#PBS -l nodes=1:ppn=16,mem=64gb

```

Thanks:)

---

<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:** [November 6, 2022, 8:16pm UTC](https://discourse.julialang.org/t/running-julia-with-multi-threading-with-qsub/89850/2 "2022-11-06T20:16:53Z")

</div>

The right syntax is

```julia
julia --threads 16 "test.jl"

```

You were passing arguments to the script `test.jl` in the form of [`Base.ARGS`](https://docs.julialang.org/en/v1/base/constants/#Base.ARGS), not to the Julia process itself. In general, the syntax is

```julia
julia [arguments to julia process] [script name] [arguments to the script]

```

---

<div class="post-metadata">

**Author:** ![Rick](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@Rick](https://discourse.julialang.org/u/Rick)\
**Post date:** [November 6, 2022, 8:20pm UTC](https://discourse.julialang.org/t/running-julia-with-multi-threading-with-qsub/89850/3 "2022-11-06T20:20:57Z")

</div>

I see, thanks @giordano 🙂
