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
Press the Windows key or Windows+S to search for ‘Edit system environment variables’.
When the System Properties window appears, click on ‘Environment variables’.
Step 2. Find JULIA_NUM_THREADS
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
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.
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