-
Notifications
You must be signed in to change notification settings - Fork 15
Allow for CUDA compute capability fallbacks when initialising EESSI #5
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
408dabf
Allow for CUDA compute capability fallbacks when initialising EESSI
ocaisa 467b2ca
Merge remote-tracking branch 'upstream/main' into cuda_fallbacks
ocaisa e8bbaa4
Merge branch 'main' into cuda_fallbacks
ocaisa fc60373
Update verify_eessi_environment.py
ocaisa 39272de
Make CI clearer about how it checks overrides
ocaisa 04a8053
Make sure the environment variable is actually set
ocaisa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import os | ||
| import sys | ||
|
|
||
| class EnvVarError(Exception): | ||
| """Custom exception for environment variable comparison errors.""" | ||
| def __init__(self, message): | ||
| super().__init__(f"ENV VALIDATION ERROR: {message}") | ||
|
|
||
| def get_env_vars(var1, var2): | ||
| val1 = os.environ.get(var1) | ||
| val2 = os.environ.get(var2) | ||
|
|
||
| if val1 is None: | ||
| raise EnvVarError(f"Missing environment variable: '{var1}'") | ||
| if val2 is None: | ||
| raise EnvVarError(f"Missing environment variable: '{var2}'") | ||
|
|
||
| return val1, val2 | ||
|
|
||
| def check_env_equals(var1, var2): | ||
| val1, val2 = get_env_vars(var1, var2) | ||
| if val1 != val2: | ||
| raise EnvVarError(f"'{var1}' must equal '{var2}':\n{var1}='{val1}'\n{var2}='{val2}'") | ||
|
|
||
| def check_env_contains(var1, var2): | ||
| val1, val2 = get_env_vars(var1, var2) | ||
| if val2 not in val1: | ||
| raise EnvVarError(f"'{var1}' must contain '{var2}':\n{var1}='{val1}'\n{var2}='{val2}'") | ||
|
|
||
| def check_env_endswith(var1, var2): | ||
| val1, val2 = get_env_vars(var1, var2) | ||
| if not val1.endswith(val2): | ||
| raise EnvVarError(f"'{var1}' must end with '{var2}':\n{var1}='{val1}'\n{var2}='{val2}'") | ||
|
|
||
| if __name__ == "__main__": | ||
| try: | ||
| # accelerator stuff is not guaranteed to exist | ||
| expected_eessi_accel_arch = os.getenv("EESSI_ACCELERATOR_TARGET_OVERRIDE", default=None) | ||
|
|
||
| # Verify the software and accelerator targets are set correctly | ||
| if os.getenv("EESSI_SOFTWARE_SUBDIR_OVERRIDE", default=None): | ||
| check_env_equals("EESSI_SOFTWARE_SUBDIR_OVERRIDE", "EESSI_SOFTWARE_SUBDIR") | ||
| if expected_eessi_accel_arch: | ||
| # EESSI_ACCEL_SUBDIR is what is detected by archdetect (or respects EESSI_ACCELERATOR_TARGET_OVERRIDE) | ||
| check_env_equals("EESSI_ACCELERATOR_TARGET_OVERRIDE", "EESSI_ACCEL_SUBDIR") | ||
| # special case is where EESSI_ACCELERATOR_TARGET_OVERRIDE may not match the final | ||
| # accelerator architecture chosen. | ||
| # In CI we set FINAL_ACCELERATOR_PATH_EXPECTED to allow us to compare against an expected value. | ||
| check_env_equals("EESSI_ACCELERATOR_TARGET", "FINAL_ACCELERATOR_PATH_EXPECTED") | ||
| # verify the software paths that should exist | ||
| check_env_endswith("EESSI_SOFTWARE_PATH", "EESSI_SOFTWARE_SUBDIR") | ||
| check_env_endswith("EESSI_SITE_SOFTWARE_PATH", "EESSI_SOFTWARE_SUBDIR") | ||
| # verify the module paths that should exist | ||
| check_env_contains("EESSI_MODULEPATH", "EESSI_SOFTWARE_SUBDIR") | ||
| check_env_contains("EESSI_SITE_MODULEPATH", "EESSI_SOFTWARE_SUBDIR") | ||
| if expected_eessi_accel_arch: | ||
| check_env_contains("EESSI_MODULEPATH_ACCEL", "EESSI_SOFTWARE_SUBDIR") | ||
| check_env_contains("EESSI_SITE_MODULEPATH_ACCEL", "EESSI_SOFTWARE_SUBDIR") | ||
| check_env_contains("EESSI_MODULEPATH_ACCEL", "EESSI_ACCELERATOR_TARGET") | ||
| check_env_contains("EESSI_SITE_MODULEPATH_ACCEL", "EESSI_ACCELERATOR_TARGET") | ||
| # Finally, verify that all the expected module path are included | ||
| check_env_contains("MODULEPATH", "EESSI_MODULEPATH") | ||
| check_env_contains("MODULEPATH", "EESSI_SITE_MODULEPATH") | ||
| if expected_eessi_accel_arch: | ||
| check_env_contains("MODULEPATH", "EESSI_MODULEPATH_ACCEL") | ||
| check_env_contains("MODULEPATH", "EESSI_SITE_MODULEPATH_ACCEL") | ||
|
|
||
| # We are done | ||
| print("Environment variable check passed.") | ||
| except EnvVarError as e: | ||
| print(str(e), file=sys.stderr) | ||
| sys.exit(1) |
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the assumption that one can always replace the last digit with a zero. While that may be true, it might be better to define a function for this ... and add a comment about it (maybe even a link to some documentation).
In case the naming does not imply compatibility in the same way as now, one could then also later change the function instead of changing the variable expansion/setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not enough to make a function just here, the same also needs to apply to the EESSI module. That feels overly complicated for now and could be done in a follow-up PR?
I can add a CI test that verifies that the fallback is as expected, that should make a follow-up PR easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With 39272de it should at least be more obvious that this is being checked, so should help sanity checking a follow-up PR