Skip to content

Commit

Permalink
[ROCm] Updating ROCM_HOME handling for >ROCm 4.0 (pytorch#55968)
Browse files Browse the repository at this point in the history
Summary:
- This change is required to handle the case when hipcc is
  updated to the latest using update-alternatives.
- Update-alternatives support for few ROCm binaries is available
  from ROCm 4.1 onwards.
- This change doesnt not affect any previous versions of ROCm.

Pull Request resolved: pytorch#55968

Reviewed By: mruberry

Differential Revision: D27785123

Pulled By: ezyang

fbshipit-source-id: 8467e468d8d51277fab9b0c8cbd57e80bbcfc7f7
  • Loading branch information
pruthvistony authored and facebook-github-bot committed Apr 15, 2021
1 parent 5cab3b9 commit b383b63
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions torch/utils/cpp_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ def _find_rocm_home() -> Optional[str]:
if rocm_home is None:
# Guess #2
try:
hipcc = subprocess.check_output(
['which', 'hipcc'], stderr=subprocess.DEVNULL).decode().rstrip('\r\n')
pipe_hipcc = subprocess.Popen(
["which hipcc | xargs readlink -f"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
hipcc, _ = pipe_hipcc.communicate()
# this will be either <ROCM_HOME>/hip/bin/hipcc or <ROCM_HOME>/bin/hipcc
rocm_home = os.path.dirname(os.path.dirname(hipcc))
rocm_home = os.path.dirname(os.path.dirname(hipcc.decode().rstrip('\r\n')))
if os.path.basename(rocm_home) == 'hip':
rocm_home = os.path.dirname(rocm_home)
except Exception:
Expand Down

0 comments on commit b383b63

Please sign in to comment.