How to change the number of threads?

parallel
multithreading
#1

How to change the number of threads? Currently it is one for me:

julia> Threads.nthreads()
1

Is there a function/command line flag to add more threads? Is this documented somewhere?

1 Like

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

Set the JULIA_NUM_THREADS environment variable. See https://docs.julialang.org/en/stable/manual/parallel-computing/#Multi-Threading-(Experimental)-1 and https://docs.julialang.org/en/stable/manual/environment-variables/#JULIA_NUM_THREADS-1.

3 Likes

#3

In case anyone is searching for this, the correct links are now
https://docs.julialang.org/en/v1.0/manual/parallel-computing/#Multi-Threading-(Experimental)-1
and
https://docs.julialang.org/en/v1.0/manual/environment-variables/#JULIA_NUM_THREADS-1

3 Likes

#4

Any idea, if I’m using visual studio code (VS code), how do I set JULIA_NUM_THREADS=n before firing up julia?

I’ve tried changing settings to

“julia.executablePath”: “cd C:\Users\home\AppData\Local\Julia-1.0.3\bin\ & set JULIA_NUM_THREADS=20 & julia.exe”

but the command does not work like it would in command line.

0 Likes