Skip to content

Use taskset when GOMP_CPU_AFFINITY is set#430

Merged
robieta merged 2 commits into
masterfrom
robieta/set_affinity
Aug 24, 2021
Merged

Use taskset when GOMP_CPU_AFFINITY is set#430
robieta merged 2 commits into
masterfrom
robieta/set_affinity

Conversation

@robieta
Copy link
Copy Markdown

@robieta robieta commented Aug 24, 2021

Turns out if we don't do this, TorchBench CI will run with a single CPU thread.

Copy link
Copy Markdown
Contributor

@xuzhao9 xuzhao9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done!


When GOMP_CPU_AFFINITY is set, importing `torch` in the main process has
the very surprising effect of changing the threading behavior in the
subprocess. (See https://github.com/pytorch/pytorch/issues/49971 for
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is also worth mentioning using "torch.set_num_threads()" won't saturate the CPU resources?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's a great point!

Comment thread torchbenchmark/__init__.py
@robieta robieta merged commit a114b47 into master Aug 24, 2021
xuzhao9 pushed a commit to xuzhao9/benchmark that referenced this pull request Aug 31, 2021
* use taskset when GOMP_CPU_AFFINITY is set

* expand docstring of Worker
xuzhao9 pushed a commit to xuzhao9/benchmark that referenced this pull request Aug 31, 2021
* use taskset when GOMP_CPU_AFFINITY is set

* expand docstring of Worker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants