# JULIA\_NUM\_THREADS in VS Code (Windows 10 + WSL)

**URL:** <https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794>\
**Category:** VS Code\
**Tags:** multithreading\
**Created:** [September 15, 2019, 3:38pm UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794 "2019-09-15T15:38:34Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ininterrompue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ininterrompue/32/5594_2.png) [@Ininterrompue](https://discourse.julialang.org/u/Ininterrompue)\
**Post date:** [September 15, 2019, 3:38pm UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/1 "2019-09-15T15:38:34Z")

</div>

I recently came across this thread:

> [@How to change the number of threads?](https://discourse.julialang.org/t/how-to-change-the-number-of-threads/6169):
>
> 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?

about setting the environment variable JULIA\_NUM\_THREADS in Windows, and was wondering if anyone know how this would work in VS Code (context: I am using a computer with Windows 10 and the Linux subsystem). The only way I have gotten Julia to start with multiple threads is to start a new bash session in the same directory as julia.exe, but this is inconvenient for when I am writing code (VS Code by default starts a session in the workspace directory).

Any assistance would be appreciated. Thanks.

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [September 16, 2019, 4:19pm UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/2 "2019-09-16T16:19:48Z")

</div>

You can set additional env variables for the julia REPL via the `julia.additionalArgs` setting of the Julia extension in VS Code.

---

<div class="post-metadata">

**Author:** ![chrism32](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@chrism32](https://discourse.julialang.org/u/chrism32)\
**Post date:** [December 10, 2019, 5:09pm UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/3 "2019-12-10T17:09:41Z")

</div>

I apologize if this is obvious, but could be more specific about what to add to the setting.json?

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [December 10, 2019, 6:47pm UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/4 "2019-12-10T18:47:55Z")

</div>

> [@davidanthoff](#):
>
> You can set additional env variables for the julia REPL via the `julia.additionalArgs` setting of the Julia extension in VS Code.

What argument should be added there? just `julia.JULIA_NUM_ThREADS` ?

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [December 11, 2019, 5:26pm UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/5 "2019-12-11T17:26:03Z")

</div>

I think we added an explicit setting for the number of threads now, but it might currently only be on the alpha build for the next version, which you can try [here](https://github.com/julia-vscode/julia-vscode/releases/tag/v0.13.0-alpha.1). That is also the only version that works with Julia 1.3 currently.

---

<div class="post-metadata">

**Author:** ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Post date:** [January 8, 2020, 10:15am UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/6 "2020-01-08T10:15:01Z")

</div>

You can find it now in the settings of the Julia extension of vscode.  
 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/4/3/4344a5d558caab3304fd7a20bc921a1fd0299808.png)

---

<div class="post-metadata">

**Author:** ![tro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tro3/32/12355_2.png) [@tro3](https://discourse.julialang.org/u/tro3)\
**Post date:** [January 11, 2020, 4:11pm UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/7 "2020-01-11T16:11:09Z")

</div>

This extension setting works for me in the REPL, but it does not extend to the Run Tests (w/wo Coverage) Task. I don’t know the VS codebase, but I’ll take a look to see if it is an easy PR.

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [January 11, 2020, 5:01pm UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/8 "2020-01-11T17:01:43Z")

</div>

Yes, good point, we are not currently picking it up for the test runner. It should be an easy PR, the point where you would add this is [here](https://github.com/julia-vscode/julia-vscode/blob/master/src/tasks.ts#L51). PR would be great!

---

<div class="post-metadata">

**Author:** ![tro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tro3/32/12355_2.png) [@tro3](https://discourse.julialang.org/u/tro3)\
**Post date:** [January 11, 2020, 5:43pm UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/10 "2020-01-11T17:43:31Z")

</div>

PR in place. [https://github.com/julia-vscode/julia-vscode/pull/930](https://github.com/julia-vscode/julia-vscode/pull/930). I’m not able to run the test suite on my machine, but the Travis builds are passing, in any case. I did test the functionality on my machine by directly editing the extension JS files. Let me know if you need anything done.

---

<div class="post-metadata">

**Author:** ![JamesK](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jamesk/32/8989_2.png) [@JamesK](https://discourse.julialang.org/u/JamesK)\
**Post date:** [September 27, 2020, 6:26pm UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/11 "2020-09-27T18:26:54Z")

</div>

> I apologize if this is obvious, but could be more specific about what to add to the setting.json?

This was never answered, and I’m using an old version of the Julia extension due to the problem and suggested solution here: [Ctrl-C doesn't interrupt Alt-Enter code · Issue #767 · julia-vscode/julia-vscode · GitHub](https://github.com/julia-vscode/julia-vscode/issues/767), so I do not have access to the the GUI Num Threads setting in the extension.

What exactly should one add to the setting.json to set the number of threads? Thank you.

Edit: If it makes a difference, I am on Ubuntu 18.04, not Windows 10.

---

<div class="post-metadata">

**Author:** ![JamesK](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jamesk/32/8989_2.png) [@JamesK](https://discourse.julialang.org/u/JamesK)\
**Post date:** [September 28, 2020, 9:25pm UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/12 "2020-09-28T21:25:42Z")

</div>

> > I apologize if this is obvious, but could be more specific about what to add to the setting.json?

I did not figure out how to do this, but, for anyone in a similar situation, you can simply edit your .bashrc file to set the environment variable. Add `export JULIA_NUM_THREADS=4` (replace 4 with desired number) as a line at the bottom of your .bashrc file, restart your computer (logging out and in might be enough), and you are all set.

---

<div class="post-metadata">

**Author:** ![Philogicatician](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/philogicatician/32/34172_2.png) [@Philogicatician](https://discourse.julialang.org/u/Philogicatician)\
**Post date:** [March 24, 2022, 1:36am UTC](https://discourse.julialang.org/t/julia-num-threads-in-vs-code-windows-10-wsl/28794/13 "2022-03-24T01:36:51Z")

</div>

Just to answer this for anyone that finds this thread, I was using 1.7.2 Julia and the VSCode Julia extension v.1.6.6, and the nice box to change the number of threads wasn’t there. Instead there was a “Edit in settings.json” link.

I could change the threads in the terminal instance of Julia but it wouldn’t register in my Jupyter notebooks within VS Code. Eventually, I figured out the solution.

Here’s what I added to the `settings.json` file:

```julia
"julia.NumThreads": 12,
    "settingsSync.ignoredSettings": [
        "-julia.NumThreads"
    ],

```

Altogether, the `settings.json` file should look something like the following:

```julia
{
    # Probably has some settings for 
    # color schemes, zoomlevel, etc.

    # Then you should add these lines:
    "julia.NumThreads": 12,
    "settingsSync.ignoredSettings": [
        "-julia.NumThreads"
    ],
    
    
}

```
