Trouble Enabling Multithreading within Jupyter Notebook

When I execute the following command:

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?

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.

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

1 Like

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

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.

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