-
Notifications
You must be signed in to change notification settings - Fork 90
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
evaluators.py: Allow MultiprocessingEvaluator to initialize with cpu_count minus N processes #140
Conversation
This commit allows inputting negative integers for n_processes in the MultiprocessingEvaluator defined in evaluators.py. This way the number of logical CPU cores minus that negative number would be used. For example, on a 12 thread processor, -2 results in using 10 threads. There is a guard around the function that always at least one process. The main advantage is that when inputting a negative number, there is always some CPU power available for system and background tasks, which means the system would lag way less. When working in teams or on different devices, you can just leave it to -1 or -2 and always have some computing power to spare.
Another option is was thinking about is allowing a float between 0 and 1, which would indicate the fraction of logical GPU cores that the evaluator is allowed to use. So |
I would prefer to stay as close as possible to how this is handled in e.g. concurrent.futures and multiprocessing. The negative indexing is already a deviation, although a convenient one and in line with negative indexing. Giving a special meaning to floats between 0 and 1 would only confuse in my view. |
That was what I wanted to check, I agree. |
I just pushed the next step for #124. The main question is whether we want to address the visualization also at this stage or leave that for a future release. |
I would suggest moving that to 2.3.0, that we also have some time to discuss what the optimal form is. |
PR quaquel#140 introduced a feature for the MultiprocessingEvaluator to take a negative input for n_processes, which initialize the evaluator with the cpu_count minus that negative integer, leaving that number of cores free. In 7dd1610 this code was refactored, introducing a bug that broke the negative-integer input functionality. When a negative integer is inputted, a AttributeError: 'MultiprocessingEvaluator' object has no attribute 'n_processes' was created. The bug was caused by self.n_processes begin used instead of n_processes, where in earlier code self.n_processes was set equal to n_processes earlier in the process. This commit fixes this behaviour by using n_processes to calculate self.n_processes. Unfortunately this bug landed in the EMAworkbench 2.2.0 release. A cherry pick and new patch release should be considered.
PR #140 introduced a feature for the MultiprocessingEvaluator to take a negative input for n_processes, which initialize the evaluator with the cpu_count minus that negative integer, leaving that number of cores free. In 7dd1610 this code was refactored, introducing a bug that broke the negative-integer input functionality. When a negative integer is inputted, a AttributeError: 'MultiprocessingEvaluator' object has no attribute 'n_processes' was created. The bug was caused by self.n_processes begin used instead of n_processes, where in earlier code self.n_processes was set equal to n_processes earlier in the process. This commit fixes this behaviour by using n_processes to calculate self.n_processes.
PR #140 introduced a feature for the MultiprocessingEvaluator to take a negative input for n_processes, which initialize the evaluator with the cpu_count minus that negative integer, leaving that number of cores free. In 7dd1610 this code was refactored, introducing a bug that broke the negative-integer input functionality. When a negative integer is inputted, a AttributeError: 'MultiprocessingEvaluator' object has no attribute 'n_processes' was created. The bug was caused by self.n_processes begin used instead of n_processes, where in earlier code self.n_processes was set equal to n_processes earlier in the process. This commit fixes this behaviour by using n_processes to calculate self.n_processes.
This commit allows inputting negative integers for
n_processes
in theMultiprocessingEvaluator
. This way the number of logical CPU cores minus that negative number would be used. For example, on a 12 thread processor,-2
results in using 10 threads. There is a guard around the function that always at least one process.The main advantage is that when inputting a negative number, there is always some CPU power available for system and background tasks, which means the system would lag way less. When working in teams or on different devices, you can just leave it to
-1
or-2
and always have some computing power to spare.