logo

Changing the Number of Threads for parallel Computing in Julia on Windows 📂Julia

Changing the Number of Threads for parallel Computing in Julia on Windows

Guide

In Julia, parallel computing is commonly used, so it may be necessary to focus all of a computer’s resources on computation depending on the situation. Although there are various ways to change the number of threads, the most static and convenient method is to edit environmental variables.

Step 1. Edit System Environmental Variables

20201217\_122516.png

Press the Windows key or Windows+S to search for ‘Edit system environment variables’.

20201217\_122819.png

When the System Properties window appears, click on ‘Environment variables’.


Step 2. Find JULIA_NUM_THREADS

20201217\_123005.png

Find the variable as shown above in user variables. This value is the number of threads. If it exists, choose ‘Edit’, if not, select ‘New’ and proceed to Step 3..


Step 3. Modify Variable Value

20201217\_123329.png

In the area indicated in the screenshot above, type the desired number of threads. The appropriate number of threads varies depending on the specs of the computer, but since we are dealing with an example, let’s modify it to $5$ threads.


Step 4. Confirm

using Base.Threads
nthreads()

Let’s run the above code in the Julia console to check.

20201217\_123549.png

If it doesn’t reflect, try rebooting first. If that doesn’t work, then try modifying it in the system variables.

Environment

  • OS: Windows
  • julia: v1.5.0