[ROCM] Extend try-catch mechanism for ROCM detection (#99980)

ROCM path detection currently relies on `hipconfig`. On some systems when calling `hipconfig` through `subprocess` python raises a `NotADirectoryError` that isn't catch at the moment. This commit adds `NotADirectoryError` to exceptions catched when calling `hipconfig`.

Fixes #98629

Pull Request resolved: https://github.com/pytorch/pytorch/pull/99980
Approved by: https://github.com/jeffdaily, https://github.com/malfet
This commit is contained in:
Luis Montero 2023-04-25 18:07:29 +00:00 committed by PyTorch MergeBot
parent df3455b716
commit 39ff87c6a4

View File

@ -34,7 +34,7 @@ try:
rocm_path = subprocess.check_output(["hipconfig", "--rocmpath"]).decode("utf-8")
except subprocess.CalledProcessError:
print(f"Warning: hipconfig --rocmpath failed, assuming {rocm_path}")
except (FileNotFoundError, PermissionError):
except (FileNotFoundError, PermissionError, NotADirectoryError):
# Do not print warning. This is okay. This file can also be imported for non-ROCm builds.
pass