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

Fixing the estimation of available cpus for a machine (localhost) #971

Merged
merged 13 commits into from
Dec 19, 2024

Conversation

mikibonacci
Copy link
Member

@mikibonacci mikibonacci commented Dec 15, 2024

This fixes #937
This fixes #888

Issue #937 is fixed here,
while #888 is fixed here

(now under the `machine_cpus` variable, no more `localhost_cpus`)
This is done by using the `get_default_mpiprocs_per_machine` method of the
computer node.
pre-commit-ci bot and others added 4 commits December 15, 2024 13:19
I take the information from the computer setup:

```python
default_mpiprocs = computer.get_default_mpiprocs_per_machine()
```
@mikibonacci mikibonacci changed the title Fixing the estimation of available cpus estimation Fixing the estimation of available cpus for a machine (localhost) Dec 15, 2024
self.num_cpus.value = 1
self.num_cpus.description = "CPUs"
else:
default_mpiprocs = computer.get_default_mpiprocs_per_machine()
self.num_nodes.disabled = False
self.num_cpus.max = default_mpiprocs
self.num_cpus.value = default_mpiprocs
self.num_cpus.value = (
Copy link
Member Author

Choose a reason for hiding this comment

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

this can fix the number of max cpus we can choose for a code, avoid the erroneous os.cpu_count

Copy link
Member

Choose a reason for hiding this comment

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

Why setting num_cpus to 1 if it's localhost?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess (was already 1, before this PR) that the reason is not to use, by default, the whole resources of the host, if localhost. Imagine in the demo server, you will be then always suggest as default to use all the resources, maybe is not the ideal case. But I am open to change it

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation. It sounds reasonable to use 1.

localhost_cpus = os.cpu_count()
machine_cpus = orm.load_node(
pw_code_model.selected
).computer.get_default_mpiprocs_per_machine()
Copy link
Member Author

Choose a reason for hiding this comment

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

I called machine_cpus as is not more only for localhost_cpus

@mikibonacci mikibonacci requested a review from unkcpz December 15, 2024 13:35
Copy link
Member

@superstar54 superstar54 left a comment

Choose a reason for hiding this comment

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

Hi @mikibonacci , thanks for the work. I am not quite understand the fix. Maybe @unkcpz know better on this part, please have a look.

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

Thanks @mikibonacci, for getting the set default CPU number get_default_mpiprocs_per_machine is the correct way I was putting for the computer. So this part looks good to me.

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.

Project coverage is 68.42%. Comparing base (b288780) to head (966c52f).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/aiidalab_qe/common/widgets.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #971      +/-   ##
==========================================
+ Coverage   68.40%   68.42%   +0.01%     
==========================================
  Files         111      111              
  Lines        6293     6289       -4     
==========================================
- Hits         4305     4303       -2     
+ Misses       1988     1986       -2     
Flag Coverage Δ
python-3.11 68.42% <42.85%> (+0.02%) ⬆️
python-3.9 68.44% <42.85%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@edan-bainglass edan-bainglass left a comment

Choose a reason for hiding this comment

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

Simple enough. LGTM!

@mikibonacci mikibonacci merged commit bac49aa into aiidalab:main Dec 19, 2024
7 of 8 checks passed
@mikibonacci mikibonacci deleted the fix/cpu_count branch December 19, 2024 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants