# How to set number of threads for VS Code?

**URL:** <https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434>\
**Category:** New to Julia\
**Tags:** vscode\
**Created:** [September 28, 2020, 7:29pm UTC](https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434 "2020-09-28T19:29:33Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![DShiu](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@DShiu](https://discourse.julialang.org/u/DShiu)\
**Post date:** [September 28, 2020, 7:29pm UTC](https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434/1 "2020-09-28T19:29:33Z")

</div>

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](https://global.discourse-cdn.com/julialang/original/3X/2/7/2726adb3d52eac0efccda6ff21371988abda1c47.png)  
The documentation ([Multi-Threading · The Julia Language](https://docs.julialang.org/en/v1.5/manual/multi-threading/)) says that we can set the number of threads with

```julia
$ julia --threads 4

```

However, when I enter this in my REPL,  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/9/699bdbbc95e1354e98af7e530e2326bef1596663.png)  
Or if I follow other users’ comments and do  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/1/315eaf2372896fbabdd351ccb0ccc6fcad5a3c04.png)  
I also tried these in cmd, but not working either.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 28, 2020, 7:30pm UTC](https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434/2 "2020-09-28T19:30:58Z")

</div>

I believe it is `julia -t 4`.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 28, 2020, 7:32pm UTC](https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434/3 "2020-09-28T19:32:36Z")

</div>

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

```julia
set JULIA_NUM_THREADS=4
julia

```

Or, with Git bash:

```julia
export JULIA_NUM_THREADS=4
julia

```

Or, start `cmd` and type

```julia
julia -t 4

```

---

<div class="post-metadata">

**Author:** ![danielw2904](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielw2904/32/10890_2.png) [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Post date:** [September 28, 2020, 7:52pm UTC](https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434/4 "2020-09-28T19:52:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DShiu](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@DShiu](https://discourse.julialang.org/u/DShiu)\
**Post date:** [September 28, 2020, 7:52pm UTC](https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434/5 "2020-09-28T19:52:57Z")

</div>

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

```julia
set JULIA_NUM_THREADS=4

```

and then enter

```julia
julia

```

to start Julia. Now indeed I get  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/3/13c86c4fbdb273c6cf773b9b41d4bf0eff9d8d77.png)  
However, in VS Code REPL, I still see  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/b/cb53cec52348c08e28665d71037be65ca7c75b27.png)

---

<div class="post-metadata">

**Author:** ![DShiu](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@DShiu](https://discourse.julialang.org/u/DShiu)\
**Post date:** [September 28, 2020, 7:58pm UTC](https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434/6 "2020-09-28T19:58:01Z")

</div>

This works and it’s much more convenient!

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [September 28, 2020, 8:01pm UTC](https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434/7 "2020-09-28T20:01:01Z")

</div>

btw, first result of google search:

> [@JULIA\_NUM\_THREADS in VS Code (Windows 10 + WSL)](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/6):
>
> You can find it now in the settings of the Julia extension of vscode. [grafik]

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 28, 2020, 8:08pm UTC](https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434/8 "2020-09-28T20:08:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PennyL](https://avatars.discourse-cdn.com/v4/letter/p/ed8c4c/32.png) [@PennyL](https://discourse.julialang.org/u/PennyL)\
**Post date:** [February 5, 2021, 12:44pm UTC](https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434/9 "2021-02-05T12:44:13Z")

</div>

This thread is really helpful, and led me to the environment settings in VS code where I have changed the thread number to 4, for user and workspace. However, julia is apparently still using one thread. I

 ![vscodejuliathreadcheck](https://global.discourse-cdn.com/julialang/original/3X/e/c/ec224ea2c4519d6cbbed8b5cbec320de42c04c4b.jpeg) ![vscodejuliathreadsettings](https://global.discourse-cdn.com/julialang/original/3X/8/b/8b9aa8d0c9ad6a4fe81aee0dac3850e5e578ea5e.jpeg) have closed and reopened VS code, closed all the julia files in VS code, then closed and reopened VS code, but without anything improving. Setings shows 4 threads but Threads.nthreads() still shows 1.  
Pretty sure I’m being stupid, can anyone help me!?

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [March 8, 2023, 3:06pm UTC](https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434/10 "2023-03-08T15:06:02Z")

</div>

I managed to “somehow” install VSCode on our remote server under JupiterHub… but the num thread option doesn’t compare in the settings… where could I did wrong ?

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [March 29, 2023, 9:29am UTC](https://discourse.julialang.org/t/how-to-set-number-of-threads-for-vs-code/47434/11 "2023-03-29T09:29:59Z")

</div>

Make sure you switch to the “Remote” tab in the settings:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/6/c6c58ecac1951609649447d0218a6270a6fa8b84.png)
