Multi-Threading Bug on Windows: setting Threads.nthreads() = 6 for using BlackBoxOptim

Hallo,

I am trying to take advantage of Multithreaded and Parallel Function Evaluation of BlackBoxOptim.jl which requires Threads.nthreads() > 2 by using Julia 1.4.1

BlackBoxOptim.jl

Nevertheless on Windows 10 I am not able to set the number of Threads.nthreads() > 1

Following
Multi-Threading (Experimental)

I type the following commands:

set JULIA_NUM_THREADS=6

It successfully accepts the code.
But when I type

julia> Threads.nthreads()
 1

I will be ever so grateful if you could inform me what I am doing wrong?

Also in VScode I have the option:

Julia: Num Threads
Number of threads to use for Julia processes =6
1 Like

after set JULIA_NUM_THREADS=6, start julia in the same command window (by typing julia)

That was really simple thanks

My question is why the option in VScode of Num Threads does not work?

How can I automatically at the start of Julia force JULIA_NUM_THREADS=6?

Thanks

I am using this in startup.jl

ENV["JULIA_NUM_THREADS"] = 6

but I am not working on windows, so I am not sure whether it will work for you that way.

Are you using Julia VS Code extension version 0.15.29?

I’m on Windows and in this version setting the extension’s julia.NumThreads setting works.

I don’t think that works because that file is loaded (by virtue of it being a julia file) after julia has started.

You are right, thanks for the correction. I copied that from some other thread on discourse and never verified whether it works or not. And yes, it does not work.

In the upcoming 1.5 release it is possible to use julia --threads=6 for example.

4 Likes

Thanks hsm mine julia.NumThreads setting does not work. May be it works for Distributed package with addprocs(). Kristoffer solved my problem:

In the upcoming 1.5 release it is possible to use julia --threads=6 for example.

1 Like