Stream: helpdesk (published)

Topic: Adding processes and workers


view this post on Zulip QuBit (Mar 04 2021 at 14:54):

Hello:

I am using Julia v 1.5.3 operating on a machine with
4 cores.

I am attempting to add workers via the REPL using:

julia> $ julia  --threads  4

But I am returning the following error:

ERROR: syntax: invalid operator "--"

I have used -t, -p, ./julia combinations
but all have returned Syntax errors.

Any tips on this one?

view this post on Zulip Frederik Banning (Mar 04 2021 at 14:57):

you either start the julia REPL with keywords like -p
or you run using Distributed; addprocs() inside the REPL
on a sidenote: this whole process is documented nicely in the julia docs

view this post on Zulip QuBit (Mar 04 2021 at 15:25):

Frederik Banning said:

you either start the julia REPL with keywords like -p
or you run using Distributed; addprocs() inside the REPL
on a sidenote: this whole process is documented nicely in the julia docs

Thank you for this reply, I did look at the
documentation Multi-Threading previous
to this question but am having trouble
interpreting it.

My main goal is to add workers to reduce overhead
and to utilize a package that can scale better than
non-threaded packages.

view this post on Zulip Max Köhler (Mar 04 2021 at 15:27):

how do you open the repl? Do you click on a symbol?

view this post on Zulip QuBit (Mar 04 2021 at 15:31):

Max Köhler said:

how do you open the repl? Do you click on a symbol?

I open by clicking the application icon. I am not familiar
with the short symbol.

view this post on Zulip Max Köhler (Mar 04 2021 at 15:33):

Are you familiar with starting julia from a shell?

view this post on Zulip QuBit (Mar 04 2021 at 15:46):

Max Köhler said:

Are you familiar with starting julia from a shell?

Hi Max,

Sorry for not making my question clear.
Yes I know how to activate Julia from the
REPL:

  1. add Parralization Data Transfer library
  2. implement the library/package
  3. check number of processes (i.e. nproc)
  4. add the number of processes usually
    in step with the number of cores on the
    machine

  5. Pluto.run() to open web session on
    localhost:XXXX

view this post on Zulip Max Köhler (Mar 04 2021 at 15:54):

qu bit said:

julia> $ julia  --threads  4

This looks to me as if you want to start julia from the julia repl, but I'm asking if you can open the julia repl from an OS (Windows, Mac, Linux depends what you use) shell

view this post on Zulip QuBit (Mar 04 2021 at 15:59):

Max Köhler said:

qu bit said:

julia> $ julia  --threads  4

This looks to me as if you want to start julia from the julia repl, but I'm asking if you can open the julia repl from an OS (Windows, Mac, Linux depends what you use) shell

I am using the Windows Powershell REPL to activate
a Julia browser session, is this what you mean?

Yes -- initially I used that command on the
interpreter line, but it returned a syntax error.

I am using a package similar to Distributions
and added the processes using addprocs(n).

view this post on Zulip Max Köhler (Mar 04 2021 at 16:31):

ok, so if you want to use the command line argument as in the snippet julia --threads 4 you need to do it before starting julia, it's an argument to start julia. Otherwise, as @Frederik Banning suggested, you can add processes and threads by their corresponding packages, e.g.

using Distributed
addprocs(5)

view this post on Zulip Max Köhler (Mar 04 2021 at 16:32):

but since you write something about Pluto, it's a different scenario anyways. Do you want to have multiple procs/threads in Pluto?

view this post on Zulip QuBit (Mar 04 2021 at 16:38):

Max Köhler said:

but since you write something about Pluto, it's a different scenario anyways. Do you want to have multiple procs/threads in Pluto?

Yes -- My words before are confirming what you are saying.

Right now, I only have 1 worker running for my current session.
I wanted to have 4 workers running for a single Pluto session.

Does adding the processes via addproc(N) achieve this?

view this post on Zulip Max Köhler (Mar 04 2021 at 16:42):

I think this problem isn't solved yet. Pluto launches workers and your code is executed on a slave process, therefore it's (AFAIK) currently not possible.

view this post on Zulip Max Köhler (Mar 04 2021 at 16:43):

However, you can execute your Pluto notebook as normal julia code with multiple workers by

julia -p 5 notebook.jl

view this post on Zulip QuBit (Mar 04 2021 at 16:48):

Max Köhler said:

However, you can execute your Pluto notebook as normal julia code with multiple workers by

julia -p 5 notebook.jl

Okay -- thank you Max.

So I understand you clearly.

In the Windows Powershell, in order to run on multiple
workers during a Pluto.jl session, run

julia -p 5 notebook.jl

Where notebook.jl is the name of the notebook you want
to implement N workers on. Correct?

view this post on Zulip Max Köhler (Mar 04 2021 at 18:02):

no not during a Pluto.jl session but instead of a Pluto.jl session you can execute the notebook as "normal" julia code and thereby have workers, I wouldn't recommend it, try to prototype in Pluto and switch to a plain script when it comes to distributing stuff

view this post on Zulip QuBit (Mar 05 2021 at 08:29):

Max Köhler said:

no not during a Pluto.jl session but instead of a Pluto.jl session you can execute the notebook as "normal" julia code and thereby have workers, I wouldn't recommend it, try to prototype in Pluto and switch to a plain script when it comes to distributing stuff

Thank you for this explanation @Max Köhler

Will addprocs() in the powershell REPL
before running a Pluto session.


Last updated: Nov 06 2024 at 04:40 UTC