Repository navigation
Conversation
Torch takes one intra op thread per core by default. Once several game instances run next to the learner, which is the point of --n_parallel, the machine is oversubscribed and the update step slows down badly. This is easy to miss because nothing fails, the run is just slow, and it gets worse the more cores the machine has. Adds set_torch_threads in core.utils and a --torch_num_threads flag to the sb3 example. Default is None so nothing changes unless the flag is used. The torch import stays inside the helper to keep core.utils free of it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Torch takes one intra op thread per core by default. As soon as several game instances run next to the learner, which is the point of
--n_parallel, the machine is oversubscribed and the update step slows right down. It is easy to miss because nothing fails, the run is just slow, and it gets worse the more cores the machine has. I hit this on a 32 core node where raisingn_parallelstopped buying any throughput at all.examples/stable_baselines3_hp_tuning.py:169already callstorch.set_num_threads(1)for the same reason, so this just makes the knob reachable from the normal training path.Adds
set_torch_threadsincore.utilsand a--torch_num_threadsflag to the sb3 example. The default isNone, so nothing changes unless the flag is passed. The torch import sits inside the helper socore.utilsdoes not pull torch in at import time.