Multi-threading not possible

Hello all, I’ve been trying to increase the number of threads being used by julia in visual code. I tried initally through Julia to increase it,
I have also tried using CMD (set JULIA_NUM_THREADS=4) as a new user can’t use more than one screen shot, it still hasn’t increased, I’m sure I’m typing in the code wrong but any help will be much appreciated

Using export
You should set the number of threads outside the julia REPL itself (and use export to export an environment variable), like so:

export JULIA_NUM_THREADS=4 (in your terminal)
then you can open julia:
and check the threads

Start julia with --threads
Alternatively, you can also start julia passing the number of threads:
julia --threads 4
The difference with export is that you would have to pass --threads every time you start the julia REPL, whereas with export you don’t (at least as long as you use the same terminal in which you exported)

Hope that’s clear :slight_smile:

You need to start Julia with a command line switch to enable more threads.

In the VScode Julia Extension settings, edit the “Julia: Num Threads” settings in settings.json. Mine is set to:

    "julia.NumThreads": "auto",

This should select as many threads as possible, or you can manually enter a number. Then restart the REPL.

On my machine, this results in:

julia> Threads.nthreads()
1 Like

Thanks a lot thats work perfectly