Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Julia seems to ignore process affinity settings on Linux #34415

Closed
oschulz opened this issue Jan 17, 2020 · 7 comments · Fixed by #34433
Closed

Julia seems to ignore process affinity settings on Linux #34415

oschulz opened this issue Jan 17, 2020 · 7 comments · Fixed by #34433
Labels
domain:multithreading Base.Threads and related functionality

Comments

@oschulz
Copy link
Contributor

oschulz commented Jan 17, 2020

Julia (tested with v1.0 and v1.3) currently seems to ignore (or escape from) process affinity settings on Linux. This is a problem in HPC computing contexts (but also in other scenarios), e.g. when trying to run one Julia process per NUMA domain.

Let's say we have a machine with 16 virtual cores (8 * 2):

$ numactl -s
policy: default
preferred node: current
physcpubind: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
[...]

Now we use numactl to pin a process to CPUs 1 and 2, that process being a numactl -s to check that the limitation is actually in effect:

$ numactl --physcpubind=1,2 -- numactl -s
policy: default
preferred node: current
physcpubind: 1 2 
[...]

Now with numactl running numactl -s via julia:

$ numactl --physcpubind=1,2 -- julia -E 'run(`numactl -s`)'
policy: default
preferred node: current
physcpubind: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
[...]

Within Julia, the pinning to CPUs 1 and 2 is gone. I see the same when running multi-threaded Julia code (Julia multi-threading or BLAS via Julia): All CPUs are used, instead of just the selected ones.

@Keno
Copy link
Member

Keno commented Jan 18, 2020

cc @kpamnany

@JeffBezanson
Copy link
Sponsor Member

We do call sched_setaffinity during init. But, it looks like that code was removed by #9639, then somehow got added back. It might have been a merge artifact when lots of threading work was happening on branches. So, we should just delete it again.

JeffBezanson added a commit that referenced this issue Jan 18, 2020
This was removed before and added back apparently by mistake.
@ViralBShah ViralBShah added the domain:multithreading Base.Threads and related functionality label Jan 19, 2020
@oschulz
Copy link
Contributor Author

oschulz commented Jan 19, 2020

Thanks, @JeffBezanson !

JeffBezanson added a commit that referenced this issue Jan 19, 2020
This was removed before and added back apparently by mistake.
KristofferC pushed a commit that referenced this issue Jan 20, 2020
This was removed before and added back apparently by mistake.
KristofferC pushed a commit that referenced this issue Jan 20, 2020
This was removed before and added back apparently by mistake.

(cherry picked from commit 5928786)
KristofferC pushed a commit that referenced this issue Apr 11, 2020
This was removed before and added back apparently by mistake.
BioTurboNick pushed a commit to BioTurboNick/julia that referenced this issue Apr 13, 2020
This was removed before and added back apparently by mistake.

(cherry picked from commit 5928786)
@mloubout
Copy link

This issue is still happenning

$ numactl --physcpubind=1,2 -- julia -E 'run(`numactl -s`)'
policy: default
preferred node: current
physcpubind: 0 1 2 3 4 5 6 7 
cpubind: 0 
nodebind: 0 
membind: 0 
Process(`numactl -s`, ProcessExited(0))

@dominikkiese
Copy link

Same for me, on my hpc system, I find that julia schedules tasks to threads which should be permitted by the cpubind

@oschulz
Copy link
Contributor Author

oschulz commented Jul 1, 2020

I usually use numactl, but since Julia v1.4, it has respected the given affinity.

@oschulz
Copy link
Contributor Author

oschulz commented Jul 1, 2020

I get

$ julia -E 'run(`numactl -s`)'
policy: default
preferred node: current
physcpubind: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
cpubind: 0 
nodebind: 0 
membind: 0 
Process(`numactl -s`, ProcessExited(0))

$ numactl --physcpubind=1,2 -- julia -E 'run(`numactl -s`)'
policy: default
preferred node: current
physcpubind: 1 2 
cpubind: 0 
nodebind: 0 
membind: 0 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:multithreading Base.Threads and related functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants