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

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!

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.

3 Likes

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:

@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 -p 3 runall.jl
5 Likes