# How to start two (or more) instances of Julia on different CPU cores?

**URL:** <https://discourse.julialang.org/t/how-to-start-two-or-more-instances-of-julia-on-different-cpu-cores/54610>\
**Category:** General Usage\
**Created:** [February 4, 2021, 10:40am UTC](https://discourse.julialang.org/t/how-to-start-two-or-more-instances-of-julia-on-different-cpu-cores/54610 "2021-02-04T10:40:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Martin](https://discourse.julialang.org/u/Martin)\
**Post date:** [February 4, 2021, 10:40am UTC](https://discourse.julialang.org/t/how-to-start-two-or-more-instances-of-julia-on-different-cpu-cores/54610/1 "2021-02-04T10:40:08Z")

</div>

I want to start several instances of Julia and run some pretty time consuming (different) simulations. The underlying hardware has several CPU cores and I would like to make sure that each instance uses a different core, to make things a bit parallel.

However, I am uncertain if this is something I can decide _after_ I have started each instance, or if there is some system variable I should change in the bash terminal from where I start a particular instance? I am working from a Linux system if that matters.

Any help would be much appreciated!

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [February 4, 2021, 2:05pm UTC](https://discourse.julialang.org/t/how-to-start-two-or-more-instances-of-julia-on-different-cpu-cores/54610/2 "2021-02-04T14:05:59Z")

</div>

If you just start 2 instances of Julia (or any other program), and start doing cpu intensive did on them the operating system will do this for you.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 4, 2021, 2:12pm UTC](https://discourse.julialang.org/t/how-to-start-two-or-more-instances-of-julia-on-different-cpu-cores/54610/3 "2021-02-04T14:12:48Z")

</div>

What Oscar said was true. But it seems to me you’re better offnot spaming terminal with a bunch of `julia script.jl` and just do everything from 1 place:

`run.jl`:

```julia
@everywhere include("utils.jl")
@spawnat 2 experiment(param1)
@spawnat 3 experiment(param2)
@spawnat 4 experiment(param3)

# write a loop to wait

```

and then you can start julia with multiple processes by:

```julia
julia -p 3 runall.jl

```
