Fix: add runtime check for cudaHostRegister in EXX PW#7157
Merged
mohanchen merged 5 commits intodeepmodeling:developfrom Mar 28, 2026
Merged
Conversation
Add runtime check (PARAM.inp.device == "gpu") before calling cudaHostRegister and cudaHostUnregister to avoid failures when CUDA is enabled but running on CPU device (e.g., on clusters with both CPU and GPU nodes but only compiling once).
There was a problem hiding this comment.
Pull request overview
Adds a runtime guard to prevent CUDA host-memory registration calls from running during EXX PW calculations when the user has selected CPU execution, addressing crashes seen on CPU-only nodes in CUDA-enabled builds (issue #7119).
Changes:
- Wrap
cudaHostRegisterwithif (PARAM.inp.device == "gpu")inget_exx_potential. - Wrap
cudaHostUnregisterwithif (PARAM.inp.device == "gpu")inget_exx_potential. - Apply the same guards in
get_exx_stress_potential.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Collaborator
Author
|
Plz merge this first and then #7166. |
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.
Add runtime check (
PARAM.inp.device == "gpu") before callingcudaHostRegisterandcudaHostUnregisterin EXX PW calculations. This fixes #7119.When ABACUS is compiled with CUDA enabled but runs on CPU devices (e.g., on clusters with both CPU and GPU nodes but only compiling once),
cudaHostRegisterfails because there's no GPU available. This causes EXX PW calculations to crash on CPU-only nodes even when compiled with CUDA support.