Threads.nthreads(): different results in Atom and in Julia built-in REPL

Hi,

I am using Julia 0.6.4 and my Windows 10 computer has 4 cores.
If I write Threads.nthreads() in Atom’s REPL, I get as an answer:

julia> Threads.nthreads()
4

However, if I start the Julia built-in-REPL (I hope it’s clear, I mean if I simply start Julia without using a code editor like Atom), and run the same line I get:

julia> Threads.nthreads()
1

What can this be due to?

By the way, I have already read https://discourse.julialang.org/t/how-to-change-the-number-of-threads/6169, and followed the steps, that is:

  • opening the Command Prompt
  • changing the directory
  • typing set JULIA_NUM_THREADS=4.
    I click Enter, and nothing happens, so I presume it works. But if I then open Julia built-in-REPL I still get:
julia> Threads.nthreads()
1

Please let me know if you have any ideas!

When you say you opened the Julia REPL, did you type the name of the executable into the Command prompt where you set JULIA_NUM_THREADS, or just click a shortcut? The variable set in the command prompt will only be seen by things run from that prompt. If you want something that can be seen by Julia started from shortcut, search for environment variables and add JULIA_NUM_THREADS as a new variable.

1 Like

Thank you very much for your feedback!
I was unaware of this, and was opening Julia from the desktop shortcut. Instead, if I open it from the prompt, by simply typing julia, setting the number of threads works!