How to set number of threads for VS Code?

There are quite a few topics about this question but I am still confused after reading them. I am using VS Code for Julia Version 1.5.0. Currently,
image
The documentation (https://docs.julialang.org/en/v1.5/manual/multi-threading/) says that we can set the number of threads with

$ julia --threads 4

However, when I enter this in my REPL,
image
Or if I follow other users’ comments and do
image
I also tried these in cmd, but not working either.

I believe it is julia -t 4.

Oh, I see. You need to start Julia like this, it cannot be set in the REPL.
So start a cmd and do

set JULIA_NUM_THREADS=4
julia

Or, with Git bash:

export JULIA_NUM_THREADS=4
julia

Or, start cmd and type

julia -t 4
2 Likes

You can set the threads in the extension settings in vs code.

1 Like

Just to clarify: I first go to cmd, find the directory of Julia, and enter

set JULIA_NUM_THREADS=4

and then enter

julia

to start Julia. Now indeed I get
image
However, in VS Code REPL, I still see
image

This works and it’s much more convenient!

1 Like

btw, first result of google search:

2 Likes

I think VS Code can control the number of threads in the settings. I am not in front of my computer so So can’t tell you precisely which, but open the settings and you will find it.

1 Like