Skip to content

Commit bd257a1

Browse files
t-vifacebook-github-bot
authored andcommitted
Add HIP/ROCm version to collect_env.py (pytorch#44106)
Summary: This adds HIP version info to the `collect_env.py` output. Pull Request resolved: pytorch#44106 Reviewed By: VitalyFedyunin Differential Revision: D23652341 Pulled By: zou3519 fbshipit-source-id: a1f5bce8da7ad27a1277a95885934293d0fd43c5
1 parent 7040a07 commit bd257a1

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

torch/utils/collect_env.py

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
'pip_version', # 'pip' or 'pip3'
3333
'pip_packages',
3434
'conda_packages',
35+
'hip_compiled_version',
36+
'hip_runtime_version',
37+
'miopen_runtime_version',
3538
])
3639

3740

@@ -103,7 +106,7 @@ def get_nvidia_driver_version(run_lambda):
103106

104107

105108
def get_gpu_info(run_lambda):
106-
if get_platform() == 'darwin':
109+
if get_platform() == 'darwin' or torch.version.hip is not None:
107110
if TORCH_AVAILABLE and torch.cuda.is_available():
108111
return torch.cuda.get_device_name(None)
109112
return None
@@ -271,29 +274,53 @@ def get_env_info():
271274
else:
272275
version_str = debug_mode_str = cuda_available_str = cuda_version_str = 'N/A'
273276

277+
if torch.version.hip is None: # cuda version
278+
gpu_info = dict(
279+
is_cuda_available=cuda_available_str,
280+
cuda_compiled_version=cuda_version_str,
281+
cuda_runtime_version=get_running_cuda_version(run_lambda),
282+
nvidia_gpu_models=get_gpu_info(run_lambda),
283+
nvidia_driver_version=get_nvidia_driver_version(run_lambda),
284+
cudnn_version=get_cudnn_version(run_lambda),
285+
hip_compiled_version='N/A',
286+
hip_runtime_version='N/A',
287+
miopen_runtime_version='N/A',
288+
)
289+
else: # HIP version
290+
cfg = torch._C._show_config().split('\n')
291+
hip_runtime_version = [s.rsplit(None, 1)[-1] for s in cfg if 'HIP Runtime' in s][0]
292+
miopen_runtime_version = [s.rsplit(None, 1)[-1] for s in cfg if 'MIOpen' in s][0]
293+
gpu_info = dict(
294+
is_cuda_available=cuda_available_str,
295+
cuda_compiled_version='N/A',
296+
hip_compiled_version=torch.version.hip,
297+
hip_runtime_version=hip_runtime_version,
298+
miopen_runtime_version=miopen_runtime_version,
299+
cuda_runtime_version='N/A',
300+
nvidia_gpu_models=get_gpu_info(run_lambda),
301+
nvidia_driver_version=get_nvidia_driver_version(run_lambda),
302+
cudnn_version='N/A',
303+
)
304+
274305
return SystemEnv(
275306
torch_version=version_str,
276307
is_debug_build=debug_mode_str,
277308
python_version='{}.{} ({}-bit runtime)'.format(sys.version_info[0], sys.version_info[1], sys.maxsize.bit_length() + 1),
278-
is_cuda_available=cuda_available_str,
279-
cuda_compiled_version=cuda_version_str,
280-
cuda_runtime_version=get_running_cuda_version(run_lambda),
281-
nvidia_gpu_models=get_gpu_info(run_lambda),
282-
nvidia_driver_version=get_nvidia_driver_version(run_lambda),
283-
cudnn_version=get_cudnn_version(run_lambda),
284309
pip_version=pip_version,
285310
pip_packages=pip_list_output,
286311
conda_packages=get_conda_packages(run_lambda),
287312
os=get_os(run_lambda),
288313
gcc_version=get_gcc_version(run_lambda),
289314
clang_version=get_clang_version(run_lambda),
290315
cmake_version=get_cmake_version(run_lambda),
316+
**gpu_info
291317
)
292318

293319
env_info_fmt = """
294320
PyTorch version: {torch_version}
295321
Is debug build: {is_debug_build}
296322
CUDA used to build PyTorch: {cuda_compiled_version}
323+
ROCM used to build PyTorch: {hip_compiled_version}
297324
298325
OS: {os}
299326
GCC version: {gcc_version}
@@ -306,6 +333,8 @@ def get_env_info():
306333
GPU models and configuration: {nvidia_gpu_models}
307334
Nvidia driver version: {nvidia_driver_version}
308335
cuDNN version: {cudnn_version}
336+
HIP runtime version: {hip_runtime_version}
337+
MIOpen runtime version: {miopen_runtime_version}
309338
310339
Versions of relevant libraries:
311340
{pip_packages}

0 commit comments

Comments
 (0)