Skip to content

Commit

Permalink
Fix collect_env.py with older version of PyTorch (#48076)
Browse files Browse the repository at this point in the history
Summary:
Inspired by #47993, this fixes the import error in `collect_env.py` with older version of PyTorch when `torch.version` does not have `hip` property.

Pull Request resolved: #48076

Reviewed By: seemethere, xuzhao9

Differential Revision: D25024352

Pulled By: samestep

fbshipit-source-id: 7dff9d2ab80b0bd25f9ca035d8660f38419cdeca
  • Loading branch information
skyline75489 authored and facebook-github-bot committed Nov 19, 2020
1 parent 343b3e5 commit 9b19880
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions torch/utils/collect_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def get_nvidia_driver_version(run_lambda):


def get_gpu_info(run_lambda):
if get_platform() == 'darwin' or (TORCH_AVAILABLE and torch.version.hip is not None):
if get_platform() == 'darwin' or (TORCH_AVAILABLE and hasattr(torch.version, 'hip') and torch.version.hip is not None):
if TORCH_AVAILABLE and torch.cuda.is_available():
return torch.cuda.get_device_name(None)
return None
Expand Down Expand Up @@ -211,7 +211,7 @@ def get_os(run_lambda):
version = get_mac_version(run_lambda)
if version is None:
return None
return 'Mac OSX {} ({})'.format(version, machine())
return 'macOS {} ({})'.format(version, machine())

if platform == 'linux':
# Ubuntu/Debian based
Expand Down Expand Up @@ -270,7 +270,7 @@ def get_env_info():
debug_mode_str = str(torch.version.debug)
cuda_available_str = str(torch.cuda.is_available())
cuda_version_str = torch.version.cuda
if torch.version.hip is None: # cuda version
if not hasattr(torch.version, 'hip') or torch.version.hip is None: # cuda version
hip_compiled_version = hip_runtime_version = miopen_runtime_version = 'N/A'
else: # HIP version
cfg = torch._C._show_config().split('\n')
Expand Down

0 comments on commit 9b19880

Please sign in to comment.