How to query the current maximum number of threads?

I have just found JULIA_NUM_THREADS in the documentation, and I wonder if Julia is already doing a good job on picking up the number of CPU cores on my laptop. Is there a command to find the number of threads available?

Threads.nthreads(). It doesn’t add threads by default, but Juno does.

I tried setting the variable JULIA_NUM_THREADS on my .juliarc.jl file but it doesn’t affect Threads.nthreads(). Is it already implemented?

That won’t work.

JULIA_NUM_THREADS is supposed to be an environment variable set before Julia is opened.

1 Like

Thank you all, I have the variable set on my .bashrc, and it works now. Though I think this should be widely spread to other Julians, I’d have set this variable a long time ago.

No please don’t. It is highly experimental.

What is not highly experimental in Julia? :slight_smile:

Well, there are the kind of code that is expected to work and there are features that aren’t.

1 Like