Skip to content

Commit

Permalink
Fix import guard checks (#7126)
Browse files Browse the repository at this point in the history
* Fix import guard checks

Signed-off-by: smajumdar <titu1994@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: smajumdar <titu1994@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: jubick1337 <mattyson.so@gmail.com>
  • Loading branch information
2 people authored and jubick1337 committed Aug 8, 2023
1 parent 4c6f425 commit d029927
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion nemo/utils/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def check_lib_version(lib_name: str, checked_version: str, operator) -> Tuple[Op
f"Could not check version compatibility."
)
return False, msg
except (ImportError, ModuleNotFoundError):
except (AttributeError, ImportError, ModuleNotFoundError):
pass

msg = f"Lib {lib_name} has not been installed. Please use pip or conda to install this package."
Expand Down
20 changes: 14 additions & 6 deletions tests/collections/nlp/test_flash_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,23 @@
except (ImportError, ModuleNotFoundError):
HAVE_TRITON = False

import pynvml
try:
import pynvml

HAVE_PYNVML = True
except (ImportError, ModuleNotFoundError):
HAVE_PYNVML = False


def HAVE_AMPERE_GPU():
pynvml.nvmlInit()
handle = pynvml.nvmlDeviceGetHandleByIndex(0)
device_arch = pynvml.nvmlDeviceGetArchitecture(handle)
pynvml.nvmlShutdown()
return device_arch == pynvml.NVML_DEVICE_ARCH_AMPERE
if HAVE_PYNVML:
pynvml.nvmlInit()
handle = pynvml.nvmlDeviceGetHandleByIndex(0)
device_arch = pynvml.nvmlDeviceGetArchitecture(handle)
pynvml.nvmlShutdown()
return device_arch == pynvml.NVML_DEVICE_ARCH_AMPERE
else:
return False


@pytest.mark.run_only_on('GPU')
Expand Down

0 comments on commit d029927

Please sign in to comment.