How to start numerous threads on windows

In the manual it says to use

$ JULIA_NUM_THREADS=4 ./julia

But how to invoke threads on windows with the julia icon?

Step 1: Create a .cmd file with

set JULIA_NUM_THREADS=4
D:\Julia\Julia-1.3.0\bin\julia.exe

(change the path as required)

Step 2: right-click the Julia icon, go to “properties” and point to the .cmd file

2 Likes

Paul is of course right, just two additional options:

  1. With Windows terminal, the terminal experience is improving, so I’ve moved to actually starting Julia from the terminal (in which case you can do what’s in the manual, just slightly modified):
PS C:\Users\ngudat> $env:JULIA_NUM_THREADS = 4
PS C:\Users\ngudat> julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.0-rc5.1 (2019-11-17)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> Threads.nthreads()
4
  1. Juno is by default setting the number of threads to the number of cores on your system, so if you’re using Julia through Juno there’s nothing to be done.
1 Like

Thanks. Can I not start more Threads than cores on my CPU?
If I set threads to 8 in the batchfile, the number of threads
Threads.nthreads()
will still give 4?

https://docs.julialang.org/en/v1/manual/environment-variables/index.html#JULIA_NUM_THREADS-1

Right. Is it possible to run Threads on my GPU?

That is actually a damn good question…
The short answer: https://juliagpu.gitlab.io/CuArrays.jl/tutorials/generated/intro/