# Trouble Enabling Multithreading within Jupyter Notebook

**URL:** <https://discourse.julialang.org/t/trouble-enabling-multithreading-within-jupyter-notebook/107411>\
**Category:** New to Julia\
**Created:** [December 11, 2023, 4:17am UTC](https://discourse.julialang.org/t/trouble-enabling-multithreading-within-jupyter-notebook/107411 "2023-12-11T04:17:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdas123](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdas123/32/32142_2.png) [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Post date:** [December 11, 2023, 4:17am UTC](https://discourse.julialang.org/t/trouble-enabling-multithreading-within-jupyter-notebook/107411/1 "2023-12-11T04:17:21Z")

</div>

When I execute the following command:

```julia
using IJulia
installkernel("Julia (4 threads)", env=Dict("JULIA_NUM_THREADS"=>"4"))
Threads.nthreads()

```

I only get 1 thread. Is there a way to increase the number of threads within a Jupyter Notebook without using the terminal?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [December 11, 2023, 7:04am UTC](https://discourse.julialang.org/t/trouble-enabling-multithreading-within-jupyter-notebook/107411/2 "2023-12-11T07:04:19Z")

</div>

Are you running all of this in the REPL? You need to check the number of cores in an actual notebook that uses this kernel.

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [December 11, 2023, 7:06am UTC](https://discourse.julialang.org/t/trouble-enabling-multithreading-within-jupyter-notebook/107411/3 "2023-12-11T07:06:38Z")

</div>

And if you’re executing this in a Jupyter Notebook, you have to change to the new kernel afterwards.

---

<div class="post-metadata">

**Author:** ![bdas123](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdas123/32/32142_2.png) [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Post date:** [December 11, 2023, 7:25am UTC](https://discourse.julialang.org/t/trouble-enabling-multithreading-within-jupyter-notebook/107411/4 "2023-12-11T07:25:28Z")

</div>

I am trying to execute the commands in the Jupyter Notebook itself

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [December 11, 2023, 8:40am UTC](https://discourse.julialang.org/t/trouble-enabling-multithreading-within-jupyter-notebook/107411/5 "2023-12-11T08:40:28Z")

</div>

Then Carsten’s answer applies. You can’t change the number of threads in a running kernel (just like you can’t do it in any running Julia instance), so you need to switch to the newly installed kernel afterwards. You probably also have to restart Jupyter (or at a minimum refresh the page) to see the new kernel in the list of available kernels.

---

<div class="post-metadata">

**Author:** ![bdas123](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdas123/32/32142_2.png) [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Post date:** [December 11, 2023, 1:10pm UTC](https://discourse.julialang.org/t/trouble-enabling-multithreading-within-jupyter-notebook/107411/6 "2023-12-11T13:10:48Z")

</div>

Oh I see. Yup, a new kernel appeared in the drop-down. Thank you!
